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

Side by Side Diff: extensions/browser/event_router.h

Issue 2940883007: Move lazy event dispatching code out of EventRouter. (Closed)
Patch Set: 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_EVENT_ROUTER_H_ 5 #ifndef EXTENSIONS_BROWSER_EVENT_ROUTER_H_
6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // methods BroadcastEvent or DispatchEventToExtension. 95 // methods BroadcastEvent or DispatchEventToExtension.
96 static void DispatchEventToSender(IPC::Sender* ipc_sender, 96 static void DispatchEventToSender(IPC::Sender* ipc_sender,
97 void* browser_context_id, 97 void* browser_context_id,
98 const std::string& extension_id, 98 const std::string& extension_id,
99 events::HistogramValue histogram_value, 99 events::HistogramValue histogram_value,
100 const std::string& event_name, 100 const std::string& event_name,
101 std::unique_ptr<base::ListValue> event_args, 101 std::unique_ptr<base::ListValue> event_args,
102 UserGestureState user_gesture, 102 UserGestureState user_gesture,
103 const EventFilteringInfo& info); 103 const EventFilteringInfo& info);
104 104
105 // Returns false when the event is scoped to a context and the listening
106 // extension does not have access to events from that context. Also fills
107 // |event_args| with the proper arguments to send, which may differ if
Devlin 2017/06/15 01:37:26 I realize this was copy-paste, but event_args don'
lazyboy 2017/06/15 04:39:22 Done.
108 // the event crosses the incognito boundary.
109 static bool CanDispatchEventToBrowserContext(content::BrowserContext* context,
110 const Extension* extension,
111 const Event& event);
112
105 // An EventRouter is shared between |browser_context| and its associated 113 // An EventRouter is shared between |browser_context| and its associated
106 // incognito context. |extension_prefs| may be NULL in tests. 114 // incognito context. |extension_prefs| may be NULL in tests.
107 EventRouter(content::BrowserContext* browser_context, 115 EventRouter(content::BrowserContext* browser_context,
108 ExtensionPrefs* extension_prefs); 116 ExtensionPrefs* extension_prefs);
109 ~EventRouter() override; 117 ~EventRouter() override;
110 118
111 // Add or remove an extension as an event listener for |event_name|. 119 // Add or remove an extension as an event listener for |event_name|.
112 // 120 //
113 // Note that multiple extensions can share a process due to process 121 // Note that multiple extensions can share a process due to process
114 // collapsing. Also, a single extension can have 2 processes if it is a split 122 // collapsing. Also, a single extension can have 2 processes if it is a split
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Dispatches the event to the specified extension or URL running in 300 // Dispatches the event to the specified extension or URL running in
293 // |process|. 301 // |process|.
294 void DispatchEventToProcess(const std::string& extension_id, 302 void DispatchEventToProcess(const std::string& extension_id,
295 const GURL& listener_url, 303 const GURL& listener_url,
296 content::RenderProcessHost* process, 304 content::RenderProcessHost* process,
297 int worker_thread_id, 305 int worker_thread_id,
298 const linked_ptr<Event>& event, 306 const linked_ptr<Event>& event,
299 const base::DictionaryValue* listener_filter, 307 const base::DictionaryValue* listener_filter,
300 bool did_enqueue); 308 bool did_enqueue);
301 309
302 // Returns false when the event is scoped to a context and the listening
303 // extension does not have access to events from that context. Also fills
304 // |event_args| with the proper arguments to send, which may differ if
305 // the event crosses the incognito boundary.
306 bool CanDispatchEventToBrowserContext(content::BrowserContext* context,
307 const Extension* extension,
308 const linked_ptr<Event>& event);
309
310 // Possibly loads given extension's background page in preparation to 310 // Possibly loads given extension's background page in preparation to
311 // dispatch an event. Returns true if the event was queued for subsequent 311 // dispatch an event. Returns true if the event was queued for subsequent
312 // dispatch, false otherwise. 312 // dispatch, false otherwise.
313 bool MaybeLoadLazyBackgroundPageToDispatchEvent( 313 bool MaybeLoadLazyBackgroundPageToDispatchEvent(
314 content::BrowserContext* context, 314 content::BrowserContext* context,
315 const Extension* extension, 315 const Extension* extension,
316 const linked_ptr<Event>& event, 316 const linked_ptr<Event>& event,
317 const base::DictionaryValue* listener_filter); 317 const base::DictionaryValue* listener_filter);
318 318
319 // Adds a filter to an event. 319 // Adds a filter to an event.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 const std::string event_name; 465 const std::string event_name;
466 466
467 const std::string extension_id; 467 const std::string extension_id;
468 const GURL listener_url; 468 const GURL listener_url;
469 content::BrowserContext* const browser_context; 469 content::BrowserContext* const browser_context;
470 }; 470 };
471 471
472 } // namespace extensions 472 } // namespace extensions
473 473
474 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 474 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698