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

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 memory leak 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/extensions/extension_event_router.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..99ca416617fe544c8f131f1f7d8fd00fb1b37f91 100644
--- a/chrome/browser/extensions/extension_event_router.h
+++ b/chrome/browser/extensions/extension_event_router.h
@@ -10,6 +10,7 @@
#include <set>
#include <string>
+#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
@@ -65,7 +66,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 +88,22 @@ 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 linked_ptr<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 linked_ptr<ExtensionEvent>& event);
+ void DispatchPendingEvents(const std::string& extension_id);
private:
// An extension listening to an event.
@@ -116,6 +124,13 @@ class ExtensionEventRouter : public NotificationObserver {
typedef std::map<std::string, std::set<EventListener> > ListenerMap;
ListenerMap listeners_;
+ // A map between an extension id and the queue of events pending
+ // the load of it's background page.
+ typedef std::vector<linked_ptr<ExtensionEvent> > PendingEventsList;
+ typedef std::map<std::string,
+ linked_ptr<PendingEventsList> > PendingEventsPerExtMap;
+ PendingEventsPerExtMap pending_events_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter);
};
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/extensions/extension_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698