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

Unified Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.h

Issue 11496004: Lazy initialization for PushMessagingEventRouter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: patch3 Created 8 years 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/api/push_messaging/push_messaging_api.h
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_api.h b/chrome/browser/extensions/api/push_messaging/push_messaging_api.h
index dc9c7cb9426d879da4154e82b9f099dcbdead4e4..8b7d0e15791b2b4ae8f147fa86243163bbe577fc 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.h
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.h
@@ -13,7 +13,9 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h"
#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_delegate.h"
+#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_function.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -104,6 +106,31 @@ class PushMessagingGetChannelIdFunction
DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction);
};
+class PushMessagingAPI : public ProfileKeyedService,
+ public extensions::EventRouter::Observer {
+ public:
+ explicit PushMessagingAPI(Profile* profile);
+ virtual ~PushMessagingAPI();
+
+ // Convenience method to get the PushMessagingAPI for a profile.
+ static PushMessagingAPI* Get(Profile* profile);
+
+ PushMessagingEventRouter* push_messaging_event_router();
akalin 2012/12/10 23:44:13 looks like this is used only for testing. Can you
Joe Thomas 2012/12/11 21:57:04 Done. Initializing the event router on SetUpOnMain
+
+ // ProfileKeyedService implementation.
+ virtual void Shutdown() OVERRIDE;
+
+ // EventRouter::Observer implementation.
+ virtual void OnListenerAdded(const extensions::EventListenerInfo& details)
+ OVERRIDE;
+
+ private:
+ Profile* profile_;
+
+ // Created lazily upon OnListenerAdded.
+ scoped_ptr<PushMessagingEventRouter> push_messaging_event_router_;
+};
+
} // namespace extension
#endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__

Powered by Google App Engine
This is Rietveld 408576698