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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche r.h" 14 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche r.h"
15 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler_delegate.h" 15 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler_delegate.h"
16 #include "chrome/browser/extensions/event_router.h"
16 #include "chrome/browser/extensions/extension_function.h" 17 #include "chrome/browser/extensions/extension_function.h"
18 #include "chrome/browser/profiles/profile_keyed_service.h"
17 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 19 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
18 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
20 #include "google_apis/gaia/google_service_auth_error.h" 22 #include "google_apis/gaia/google_service_auth_error.h"
21 23
22 class Profile; 24 class Profile;
23 25
24 namespace extensions { 26 namespace extensions {
25 27
26 class PushMessagingInvalidationMapper; 28 class PushMessagingInvalidationMapper;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) 99 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id)
98 OVERRIDE; 100 OVERRIDE;
99 virtual void OnObfuscatedGaiaIdFetchFailure( 101 virtual void OnObfuscatedGaiaIdFetchFailure(
100 const GoogleServiceAuthError& error) OVERRIDE; 102 const GoogleServiceAuthError& error) OVERRIDE;
101 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; 103 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_;
102 bool interactive_; 104 bool interactive_;
103 105
104 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); 106 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction);
105 }; 107 };
106 108
109 class PushMessagingAPI : public ProfileKeyedService,
110 public extensions::EventRouter::Observer {
111 public:
112 explicit PushMessagingAPI(Profile* profile);
113 virtual ~PushMessagingAPI();
114
115 // Convenience method to get the PushMessagingAPI for a profile.
116 static PushMessagingAPI* Get(Profile* profile);
117
118 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
119
120 // ProfileKeyedService implementation.
121 virtual void Shutdown() OVERRIDE;
122
123 // EventRouter::Observer implementation.
124 virtual void OnListenerAdded(const extensions::EventListenerInfo& details)
125 OVERRIDE;
126
127 private:
128 Profile* profile_;
129
130 // Created lazily upon OnListenerAdded.
131 scoped_ptr<PushMessagingEventRouter> push_messaging_event_router_;
132 };
133
107 } // namespace extension 134 } // namespace extension
108 135
109 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ 136 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698