summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_event_router.h
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 20:10:45 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 20:10:45 +0000
commit61f5fc846af0f1a88eb4752ca0be166049331042 (patch)
tree3f2c0765b90445d6c61932baba0f84866e203fc5 /chrome/browser/extensions/extension_event_router.h
parentc24c7c8dcfaeafe953ec7e0d6067769a7f3172ff (diff)
downloadchromium_src-61f5fc846af0f1a88eb4752ca0be166049331042.zip
chromium_src-61f5fc846af0f1a88eb4752ca0be166049331042.tar.gz
chromium_src-61f5fc846af0f1a88eb4752ca0be166049331042.tar.bz2
Persist lazy background event listeners to the Prefs file.
Also only start the lazy bg page on extension install (via dispatching the onInstalled event). BUG=81752 TEST=no Review URL: https://chromiumcodereview.appspot.com/9383024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122133 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_event_router.h')
-rw-r--r--chrome/browser/extensions/extension_event_router.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/chrome/browser/extensions/extension_event_router.h b/chrome/browser/extensions/extension_event_router.h
index b142198..daef554 100644
--- a/chrome/browser/extensions/extension_event_router.h
+++ b/chrome/browser/extensions/extension_event_router.h
@@ -118,8 +118,8 @@ class ExtensionEventRouter : public content::NotificationObserver {
const linked_ptr<ExtensionEvent>& event,
bool was_pending);
- // Ensures that all non-persistent background pages that are interested in the
- // given event are loaded, and queues the event if the page is not ready yet.
+ // Ensures that all lazy background pages that are interested in the given
+ // event are loaded, and queues the event if the page is not ready yet.
// If |extension_id| is non-empty, we load only that extension's page
// (assuming it is interested in the event).
void LoadLazyBackgroundPagesForEvent(
@@ -136,27 +136,37 @@ class ExtensionEventRouter : public content::NotificationObserver {
void DispatchPendingEvents(const std::string& extension_id);
private:
- // An extension listening to an event.
- struct EventListener;
+ // The extension and process that contains the event listener for a given
+ // event.
+ struct ListenerProcess;
+
+ // A map between an event name and a set of extensions that are listening
+ // to that event.
+ typedef std::map<std::string, std::set<ListenerProcess> > ListenerMap;
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // Returns true if the given listener map contains a event listeners for
+ // the given event. If |extension_id| is non-empty, we also check that that
+ // extension is one of the listeners.
+ bool HasEventListenerImpl(const ListenerMap& listeners,
+ const std::string& extension_id,
+ const std::string& event_name);
+
Profile* profile_;
content::NotificationRegistrar registrar_;
scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_;
- // 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;
+ // The list of active extension processes that are listening to events.
ListenerMap listeners_;
- // Keeps track of all the non-persistent background pages that are listening
- // to events.
- // TODO(mpcomplete): save to disk.
+ // The list of all the lazy (non-persistent) background pages that are
+ // listening to events. This is just a cache of the real list, which is
+ // stored on disk in the extension prefs.
ListenerMap lazy_listeners_;
// A map between an extension id and the queue of events pending