Index: chrome/browser/extensions/extension_event_router.h |
diff --git a/chrome/browser/extensions/extension_event_router.h b/chrome/browser/extensions/extension_event_router.h |
index d46e05f867ec08594d42aa179dc5f9ca832f2f23..e65fc316eddc8e1a72310376a2d05538f523dcf8 100644 |
--- a/chrome/browser/extensions/extension_event_router.h |
+++ b/chrome/browser/extensions/extension_event_router.h |
@@ -10,7 +10,9 @@ |
#include <set> |
#include <string> |
+#include "base/memory/linked_ptr.h" |
#include "base/memory/ref_counted.h" |
+#include "base/task.h" |
#include "content/common/notification_observer.h" |
#include "content/common/notification_registrar.h" |
#include "ipc/ipc_message.h" |
@@ -65,7 +67,7 @@ class ExtensionEventRouter : public NotificationObserver { |
const GURL& event_url); |
// Same as above, except only send the event to the given extension. |
- void DispatchEventToExtension( |
+ virtual void DispatchEventToExtension( |
const std::string& extension_id, |
const std::string& event_name, |
const std::string& event_args, |
@@ -87,15 +89,21 @@ class ExtensionEventRouter : public NotificationObserver { |
const GURL& event_url); |
protected: |
+ // The details of an event to be dispatched. |
+ struct ExtensionEvent; |
+ |
// Shared by DispatchEvent*. If |extension_id| is empty, the event is |
// broadcast. |
- virtual void DispatchEventImpl( |
- const std::string& extension_id, |
- const std::string& event_name, |
- const std::string& event_args, |
- Profile* restrict_to_profile, |
- const std::string& cross_incognito_args, |
- const GURL& event_url); |
+ // An event that just came off the pending list may not be delayed again. |
+ void DispatchEventImpl(const ExtensionEvent& event, bool was_pending); |
+ |
+ // Dispatch may be delayed if the extension has a lazy background page. |
+ bool CanDispatchEventNow(const std::string& extension_id); |
+ |
+ // Store the event so that it can be dispatched (in order received) |
+ // when the background page is done loading. |
+ void AppendEvent(const ExtensionEvent& pending_event); |
+ void DispatchPendingEvents(const std::string& extension_id); |
private: |
// An extension listening to an event. |
@@ -111,11 +119,20 @@ class ExtensionEventRouter : public NotificationObserver { |
scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_; |
+ ScopedRunnableMethodFactory<ExtensionEventRouter> task_factory_; |
Matt Perry
2011/08/26 00:13:00
You don't need a task factory in this case. The pu
Matt Perry
2011/08/26 00:13:00
And actually, since you're only using the Tasks fo
Tessa MacDuff
2011/08/26 01:12:53
Thanks for explaining task factories.
I think add
|
+ |
// A map between an event name and a set of extensions that are listening |
// to that event. |
typedef std::map<std::string, std::set<EventListener> > ListenerMap; |
ListenerMap listeners_; |
+ // A map between an extension id and the queue of tasks pending |
+ // the load of it's background page. |
+ typedef std::vector<linked_ptr<Task> > PendingTasksList; |
+ typedef std::map<std::string, |
+ linked_ptr<PendingTasksList> > PendingTasksPerExtMap; |
+ PendingTasksPerExtMap pending_tasks_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); |
}; |