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

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

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: onMessage event fix Created 3 years, 5 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
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_BINDINGS_API_EVENT_HANDLER_H_ 5 #ifndef EXTENSIONS_RENDERER_BINDINGS_API_EVENT_HANDLER_H_
6 #define EXTENSIONS_RENDERER_BINDINGS_API_EVENT_HANDLER_H_ 6 #define EXTENSIONS_RENDERER_BINDINGS_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 10 matching lines...) Expand all
21 namespace extensions { 21 namespace extensions {
22 class ExceptionHandler; 22 class ExceptionHandler;
23 struct EventFilteringInfo; 23 struct EventFilteringInfo;
24 24
25 // The object to handle API events. This includes vending v8::Objects for the 25 // The object to handle API events. This includes vending v8::Objects for the
26 // event; handling adding, removing, and querying listeners; and firing events 26 // event; handling adding, removing, and querying listeners; and firing events
27 // to subscribed listeners. Designed to be used across JS contexts, but on a 27 // to subscribed listeners. Designed to be used across JS contexts, but on a
28 // single thread. 28 // single thread.
29 class APIEventHandler { 29 class APIEventHandler {
30 public: 30 public:
31 // The callback to be called when event listeners change. |was_manual| 31 // The callback to be called when event listeners change.
32 // indicates that the change was due to an extension calling addListener or 32 // |update_lazy_listeners| indicates that the change was due to an extension
33 // removeListener, rather than through something like context destruction. 33 // calling addListener or removeListener on an event that supports lazy
34 // listeners, rather than through something like context destruction or
35 // removing a listener from an event that doesn't support lazy listeners.
34 // See also APIEventListeners. 36 // See also APIEventListeners.
35 using EventListenersChangedMethod = 37 using EventListenersChangedMethod =
36 base::Callback<void(const std::string& event_name, 38 base::Callback<void(const std::string& event_name,
37 binding::EventListenersChanged, 39 binding::EventListenersChanged,
38 const base::DictionaryValue* filter, 40 const base::DictionaryValue* filter,
39 bool was_manual, 41 bool update_lazy_listeners,
40 v8::Local<v8::Context>)>; 42 v8::Local<v8::Context>)>;
41 43
42 APIEventHandler(const binding::RunJSFunction& call_js, 44 APIEventHandler(const binding::RunJSFunction& call_js,
43 const binding::RunJSFunctionSync& call_js_sync, 45 const binding::RunJSFunctionSync& call_js_sync,
44 const EventListenersChangedMethod& listeners_changed, 46 const EventListenersChangedMethod& listeners_changed,
45 ExceptionHandler* exception_handler); 47 ExceptionHandler* exception_handler);
46 ~APIEventHandler(); 48 ~APIEventHandler();
47 49
48 // Returns a new v8::Object for an event with the given |event_name|. If 50 // Returns a new v8::Object for an event with the given |event_name|. If
49 // |notify_on_change| is true, notifies whenever listeners state is changed. 51 // |notify_on_change| is true, notifies whenever listeners state is changed.
52 // TODO(devlin): Maybe worth creating a Params struct to hold the event
53 // information?
50 v8::Local<v8::Object> CreateEventInstance(const std::string& event_name, 54 v8::Local<v8::Object> CreateEventInstance(const std::string& event_name,
51 bool supports_filters, 55 bool supports_filters,
56 bool supports_lazy_listeners,
52 int max_listeners, 57 int max_listeners,
53 bool notify_on_change, 58 bool notify_on_change,
54 v8::Local<v8::Context> context); 59 v8::Local<v8::Context> context);
55 60
56 // Creates a new event without any name. This is used by custom bindings when 61 // Creates a new event without any name. This is used by custom bindings when
57 // the entirety of the logic for the event is contained in the renderer. These 62 // the entirety of the logic for the event is contained in the renderer. These
58 // events do not notify of new/removed listeners or allow for dispatching 63 // events do not notify of new/removed listeners or allow for dispatching
59 // through FireEventInContext(). 64 // through FireEventInContext().
60 v8::Local<v8::Object> CreateAnonymousEventInstance( 65 v8::Local<v8::Object> CreateAnonymousEventInstance(
61 v8::Local<v8::Context> context); 66 v8::Local<v8::Context> context);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // The exception handler associated with the bindings system; guaranteed to 114 // The exception handler associated with the bindings system; guaranteed to
110 // outlive this object. 115 // outlive this object.
111 ExceptionHandler* const exception_handler_; 116 ExceptionHandler* const exception_handler_;
112 117
113 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); 118 DISALLOW_COPY_AND_ASSIGN(APIEventHandler);
114 }; 119 };
115 120
116 } // namespace extensions 121 } // namespace extensions
117 122
118 #endif // EXTENSIONS_RENDERER_BINDINGS_API_EVENT_HANDLER_H_ 123 #endif // EXTENSIONS_RENDERER_BINDINGS_API_EVENT_HANDLER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/bindings/api_binding_js_util.cc ('k') | extensions/renderer/bindings/api_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698