Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: extensions/renderer/api_event_handler.h

Issue 2921013002: [Extensions Bindings] Return result from event dispatch (Closed)
Patch Set: add listener count todo Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/api_bindings_system.cc ('k') | extensions/renderer/api_event_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 5 #ifndef EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 21 matching lines...) Expand all
32 // removeListener, rather than through something like context destruction. 32 // removeListener, rather than through something like context destruction.
33 // See also APIEventListeners. 33 // See also APIEventListeners.
34 using EventListenersChangedMethod = 34 using EventListenersChangedMethod =
35 base::Callback<void(const std::string& event_name, 35 base::Callback<void(const std::string& event_name,
36 binding::EventListenersChanged, 36 binding::EventListenersChanged,
37 const base::DictionaryValue* filter, 37 const base::DictionaryValue* filter,
38 bool was_manual, 38 bool was_manual,
39 v8::Local<v8::Context>)>; 39 v8::Local<v8::Context>)>;
40 40
41 APIEventHandler(const binding::RunJSFunction& call_js, 41 APIEventHandler(const binding::RunJSFunction& call_js,
42 const binding::RunJSFunctionSync& call_js_sync,
42 const EventListenersChangedMethod& listeners_changed); 43 const EventListenersChangedMethod& listeners_changed);
43 ~APIEventHandler(); 44 ~APIEventHandler();
44 45
45 // Returns a new v8::Object for an event with the given |event_name|. If 46 // Returns a new v8::Object for an event with the given |event_name|. If
46 // |notify_on_change| is true, notifies whenever listeners state is changed. 47 // |notify_on_change| is true, notifies whenever listeners state is changed.
47 v8::Local<v8::Object> CreateEventInstance(const std::string& event_name, 48 v8::Local<v8::Object> CreateEventInstance(const std::string& event_name,
48 bool supports_filters, 49 bool supports_filters,
49 int max_listeners, 50 int max_listeners,
50 bool notify_on_change, 51 bool notify_on_change,
51 v8::Local<v8::Context> context); 52 v8::Local<v8::Context> context);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 // Invalidates listeners for the given |context|. It's a shame we have to 85 // Invalidates listeners for the given |context|. It's a shame we have to
85 // have this separately (as opposed to hooking into e.g. a PerContextData 86 // have this separately (as opposed to hooking into e.g. a PerContextData
86 // destructor), but we need to do this before the context is fully removed 87 // destructor), but we need to do this before the context is fully removed
87 // (because the associated extension ScriptContext needs to be valid). 88 // (because the associated extension ScriptContext needs to be valid).
88 void InvalidateContext(v8::Local<v8::Context> context); 89 void InvalidateContext(v8::Local<v8::Context> context);
89 90
90 private: 91 private:
91 // Method to run a given v8::Function. Curried in for testing. 92 // Method to run a given v8::Function. Curried in for testing.
92 binding::RunJSFunction call_js_; 93 binding::RunJSFunction call_js_;
94 binding::RunJSFunctionSync call_js_sync_;
93 95
94 EventListenersChangedMethod listeners_changed_; 96 EventListenersChangedMethod listeners_changed_;
95 97
96 // The associated EventFilter; shared across all contexts and events. 98 // The associated EventFilter; shared across all contexts and events.
97 EventFilter event_filter_; 99 EventFilter event_filter_;
98 100
99 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); 101 DISALLOW_COPY_AND_ASSIGN(APIEventHandler);
100 }; 102 };
101 103
102 } // namespace extensions 104 } // namespace extensions
103 105
104 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 106 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api_bindings_system.cc ('k') | extensions/renderer/api_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698