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

Unified Diff: chrome/browser/extensions/extension_event_router.h

Issue 7672009: Lazy creating of background pages --enable-lazy-background-pages) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix broken test Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
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..21bc21351d9103bf2b3c0127f7889896a430ada7 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"
@@ -95,7 +97,23 @@ class ExtensionEventRouter : public NotificationObserver {
const std::string& event_args,
Profile* restrict_to_profile,
const std::string& cross_incognito_args,
- const GURL& event_url);
+ const GURL& event_url,
+ bool was_pending);
+
+ // Dispatch may be delayed if the extension has a lazy background page.
+ // An event that just came off the pending list may not be delayed again.
+ bool CanDispatchEventNow(const std::string& extension_id,
+ bool was_pending);
+
+ // Store the event so that it can be dispatched (in order recieved)
+ // when the background page is done loading.
+ void AppendEvent(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);
+ void DispatchPendingEvents(const std::string& extension_id);
private:
// An extension listening to an event.
@@ -111,11 +129,20 @@ class ExtensionEventRouter : public NotificationObserver {
scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_;
+ ScopedRunnableMethodFactory<ExtensionEventRouter> task_factory_;
+
// 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);
};

Powered by Google App Engine
This is Rietveld 408576698