Index: extensions/browser/event_router.h |
diff --git a/extensions/browser/event_router.h b/extensions/browser/event_router.h |
index 767dcbcb2e79b52c8012bc4619227f772143e1e8..63ff3100d27a7b7ddd6775bb1340561e08d7ed49 100644 |
--- a/extensions/browser/event_router.h |
+++ b/extensions/browser/event_router.h |
@@ -26,6 +26,7 @@ |
#include "extensions/browser/extension_registry_observer.h" |
#include "extensions/common/event_filtering_info.h" |
#include "ipc/ipc_sender.h" |
+#include "url/gurl.h" |
class GURL; |
class PrefService; |
@@ -85,13 +86,18 @@ class EventRouter : public KeyedService, |
// Sends an event via ipc_sender to the given extension. Can be called on any |
// thread. |
- static void DispatchEvent(IPC::Sender* ipc_sender, |
- void* browser_context_id, |
- const std::string& extension_id, |
- const std::string& event_name, |
- scoped_ptr<base::ListValue> event_args, |
- UserGestureState user_gesture, |
- const EventFilteringInfo& info); |
+ // |
+ // It is very rare to call this function directly. Instead use the instance |
+ // methods BroadcastEvent or DispatchEventToExtension. |
+ static void DispatchEventToSender(IPC::Sender* ipc_sender, |
+ void* browser_context_id, |
+ const GURL& url, |
+ const std::string& extension_id, |
+ events::HistogramValue histogram_value, |
+ const std::string& event_name, |
+ scoped_ptr<base::ListValue> event_args, |
+ UserGestureState user_gesture, |
+ const EventFilteringInfo& info); |
// An EventRouter is shared between |browser_context| and its associated |
// incognito context. |extension_prefs| may be NULL in tests. |
@@ -185,9 +191,31 @@ class EventRouter : public KeyedService, |
void OnEventAck(content::BrowserContext* context, |
const std::string& extension_id); |
+ // Reports UMA for an event dispatched with histogram value |histogram_value|. |
+ // Must be called on the UI thread. |
+ // |
+ // The target of the event - extension background page, view, webui, etc - |
+ // can be determined by the |process_id| and |url| tuple. If the URL is |
Devlin
2015/08/05 21:34:09
What process id?
not at google - send to devlin
2015/08/07 20:55:03
Fixed.
|
+ // unknown, which may be the case for hand-written events (like messaging), |
+ // it may be blank. |
+ // |
+ // |did_enqueue| should be true if the event was queued waiting for a process |
+ // to start, like an event page. |
+ void ReportEvent(events::HistogramValue histogram_value, |
+ const GURL& url, |
+ bool did_enqueue); |
+ |
private: |
friend class EventRouterTest; |
+ enum ExtensionPageType { |
+ EXTENSION_PAGE_NONE, |
+ EXTENSION_PAGE_VIEW, |
+ EXTENSION_PAGE_PERSISTENT_BACKGROUND, |
+ EXTENSION_PAGE_DORMANT_EVENT, |
+ EXTENSION_PAGE_AWAKE_EVENT, |
+ }; |
+ |
// The extension and process that contains the event listener for a given |
// event. |
struct ListenerProcess; |
@@ -212,6 +240,10 @@ class EventRouter : public KeyedService, |
UserGestureState user_gesture, |
const extensions::EventFilteringInfo& info); |
+ ExtensionPageType GetExtensionPageType(const Extension* extension, |
+ const GURL& url, |
+ bool did_enqueue); |
+ |
void Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) override; |
@@ -229,9 +261,9 @@ class EventRouter : public KeyedService, |
const std::string& extension_id, |
const std::string& event_name); |
- // Shared by DispatchEvent*. If |restrict_to_extension_id| is empty, the |
- // event is broadcast. |
- // An event that just came off the pending list may not be delayed again. |
+ // Shared by all event dispatch methods. If |restrict_to_extension_id| is |
+ // empty, the event is broadcast. An event that just came off the pending |
+ // list may not be delayed again. |
void DispatchEventImpl(const std::string& restrict_to_extension_id, |
const linked_ptr<Event>& event); |
@@ -250,7 +282,8 @@ class EventRouter : public KeyedService, |
const GURL& listener_url, |
content::RenderProcessHost* process, |
const linked_ptr<Event>& event, |
- const base::DictionaryValue* listener_filter); |
+ const base::DictionaryValue* listener_filter, |
+ bool did_enqueue); |
// Returns false when the event is scoped to a context and the listening |
// extension does not have access to events from that context. Also fills |
@@ -292,10 +325,13 @@ class EventRouter : public KeyedService, |
const std::string& event_name); |
// static |
- static void IncrementInFlightEventsOnUI(void* browser_context_id, |
- const std::string& extension_id, |
- int event_id, |
- const std::string& event_name); |
+ static void DoDispatchEventToSenderBookkeepingOnUI( |
+ void* browser_context_id, |
+ const std::string& extension_id, |
+ const GURL& url, |
+ int event_id, |
+ events::HistogramValue histogram_value, |
+ const std::string& event_name); |
void DispatchPendingEvent(const linked_ptr<Event>& event, |
ExtensionHost* host); |