Skip to content

Commit 30a0b2c

Browse files
committed
fix test
1 parent 67bc93b commit 30a0b2c

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

src/inspector/dom_storage_agent.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,25 @@ void DOMStorageAgent::Wire(protocol::UberDispatcher* dispatcher) {
4545
std::make_unique<protocol::DOMStorage::Frontend>(dispatcher->channel());
4646
protocol::DOMStorage::Dispatcher::wire(dispatcher, this);
4747
addEventNotifier("domStorageItemAdded",
48-
(EventNotifier)(&DOMStorageAgent::domStorageItemAdded));
48+
[this](v8::Local<v8::Context> ctx, v8::Local<v8::Object> p) {
49+
this->domStorageItemAdded(ctx, p);
50+
});
4951
addEventNotifier("domStorageItemRemoved",
50-
(EventNotifier)(&DOMStorageAgent::domStorageItemRemoved));
52+
[this](v8::Local<v8::Context> ctx, v8::Local<v8::Object> p) {
53+
this->domStorageItemRemoved(ctx, p);
54+
});
5155
addEventNotifier("domStorageItemUpdated",
52-
(EventNotifier)(&DOMStorageAgent::domStorageItemUpdated));
56+
[this](v8::Local<v8::Context> ctx, v8::Local<v8::Object> p) {
57+
this->domStorageItemUpdated(ctx, p);
58+
});
5359
addEventNotifier("domStorageItemsCleared",
54-
(EventNotifier)(&DOMStorageAgent::domStorageItemsCleared));
60+
[this](v8::Local<v8::Context> ctx, v8::Local<v8::Object> p) {
61+
this->domStorageItemsCleared(ctx, p);
62+
});
5563
addEventNotifier("registerStorage",
56-
(EventNotifier)(&DOMStorageAgent::registerStorage));
64+
[this](v8::Local<v8::Context> ctx, v8::Local<v8::Object> p) {
65+
this->registerStorage(ctx, p);
66+
});
5767
}
5868

5969
protocol::DispatchResponse DOMStorageAgent::enable() {

src/inspector/dom_storage_agent.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class DOMStorageAgent : public protocol::DOMStorage::Backend,
5151

5252
private:
5353
std::unique_ptr<protocol::DOMStorage::Frontend> frontend_;
54-
std::unordered_map<std::string, std::string> local_storage_map_;
55-
std::unordered_map<std::string, std::string> session_storage_map_;
56-
bool enabled_;
54+
std::unordered_map<std::string, std::string> local_storage_map_ = {};
55+
std::unordered_map<std::string, std::string> session_storage_map_ = {};
56+
bool enabled_ = false;
5757
Environment* env_;
5858
};
5959

src/inspector/notification_emitter.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ namespace inspector {
88
NotificationEmitter::NotificationEmitter() {}
99

1010
void NotificationEmitter::emitNotification(v8::Local<v8::Context> context,
11-
const std::string& event,
11+
const EventKey& event,
1212
v8::Local<v8::Object> params) {
1313
auto it = event_notifier_map_.find(event);
14-
if (it != event_notifier_map_.end()) {
15-
(this->*(it->second))(context, params);
14+
if (it != event_notifier_map_.end() && it->second) {
15+
it->second(context, params);
1616
}
1717
}
1818

19-
void NotificationEmitter::addEventNotifier(const protocol::String& event,
19+
void NotificationEmitter::addEventNotifier(const EventKey& event,
2020
EventNotifier notifier) {
2121
event_notifier_map_[event] = notifier;
2222
}

src/inspector/notification_emitter.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,33 @@
33

44
#include <string>
55
#include <unordered_map>
6-
#include "node/inspector/protocol/Protocol.h"
76
#include "v8.h"
87

98
namespace node {
109
namespace inspector {
1110

1211
class NotificationEmitter {
1312
public:
14-
using EventNotifier = void (NotificationEmitter::*)(
15-
v8::Local<v8::Context> context, v8::Local<v8::Object>);
13+
using EventKey = std::string;
14+
using EventNotifier =
15+
std::function<void(v8::Local<v8::Context>, v8::Local<v8::Object>)>;
16+
1617
NotificationEmitter();
1718
virtual ~NotificationEmitter() = default;
1819

1920
void emitNotification(v8::Local<v8::Context> context,
20-
const protocol::String& event,
21+
const EventKey& event,
2122
v8::Local<v8::Object> params);
2223
virtual bool canEmit(const std::string& domain) = 0;
2324

2425
NotificationEmitter(const NotificationEmitter&) = delete;
2526
NotificationEmitter& operator=(const NotificationEmitter&) = delete;
2627

2728
protected:
28-
void addEventNotifier(const protocol::String& event, EventNotifier notifier);
29+
void addEventNotifier(const EventKey& event, EventNotifier notifier);
2930

3031
private:
31-
std::unordered_map<protocol::String, EventNotifier> event_notifier_map_;
32+
std::unordered_map<EventKey, EventNotifier> event_notifier_map_ = {};
3233
};
3334

3435
} // namespace inspector

0 commit comments

Comments
 (0)