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

Side by Side Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.h

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
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/profile_keyed_api_factory.h"
15 #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"
16 #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"
17 #include "chrome/browser/extensions/chrome_extension_function.h" 16 #include "chrome/browser/extensions/chrome_extension_function.h"
18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 17 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
19 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "extensions/browser/browser_context_keyed_api_factory.h"
21 #include "google_apis/gaia/google_service_auth_error.h" 21 #include "google_apis/gaia/google_service_auth_error.h"
22 #include "google_apis/gaia/oauth2_token_service.h" 22 #include "google_apis/gaia/oauth2_token_service.h"
23 23
24 class Profile; 24 class Profile;
25 25
26 namespace content { 26 namespace content {
27 class BrowserContext; 27 class BrowserContext;
28 } 28 }
29 29
30 namespace extensions { 30 namespace extensions {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 OVERRIDE; 104 OVERRIDE;
105 virtual void OnObfuscatedGaiaIdFetchFailure( 105 virtual void OnObfuscatedGaiaIdFetchFailure(
106 const GoogleServiceAuthError& error) OVERRIDE; 106 const GoogleServiceAuthError& error) OVERRIDE;
107 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; 107 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_;
108 bool interactive_; 108 bool interactive_;
109 scoped_ptr<OAuth2TokenService::Request> fetcher_access_token_request_; 109 scoped_ptr<OAuth2TokenService::Request> fetcher_access_token_request_;
110 110
111 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); 111 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction);
112 }; 112 };
113 113
114 class PushMessagingAPI : public ProfileKeyedAPI, 114 class PushMessagingAPI : public BrowserContextKeyedAPI,
115 public content::NotificationObserver { 115 public content::NotificationObserver {
116 public: 116 public:
117 explicit PushMessagingAPI(content::BrowserContext* context); 117 explicit PushMessagingAPI(content::BrowserContext* context);
118 virtual ~PushMessagingAPI(); 118 virtual ~PushMessagingAPI();
119 119
120 // Convenience method to get the PushMessagingAPI for a profile. 120 // Convenience method to get the PushMessagingAPI for a profile.
121 static PushMessagingAPI* Get(content::BrowserContext* context); 121 static PushMessagingAPI* Get(content::BrowserContext* context);
122 122
123 // BrowserContextKeyedService implementation. 123 // BrowserContextKeyedService implementation.
124 virtual void Shutdown() OVERRIDE; 124 virtual void Shutdown() OVERRIDE;
125 125
126 // ProfileKeyedAPI implementation. 126 // BrowserContextKeyedAPI implementation.
127 static ProfileKeyedAPIFactory<PushMessagingAPI>* GetFactoryInstance(); 127 static BrowserContextKeyedAPIFactory<PushMessagingAPI>* GetFactoryInstance();
128 128
129 // For testing purposes. 129 // For testing purposes.
130 PushMessagingEventRouter* GetEventRouterForTest() const { 130 PushMessagingEventRouter* GetEventRouterForTest() const {
131 return event_router_.get(); 131 return event_router_.get();
132 } 132 }
133 PushMessagingInvalidationMapper* GetMapperForTest() const { 133 PushMessagingInvalidationMapper* GetMapperForTest() const {
134 return handler_.get(); 134 return handler_.get();
135 } 135 }
136 void SetMapperForTest(scoped_ptr<PushMessagingInvalidationMapper> mapper); 136 void SetMapperForTest(scoped_ptr<PushMessagingInvalidationMapper> mapper);
137 137
138 private: 138 private:
139 friend class ProfileKeyedAPIFactory<PushMessagingAPI>; 139 friend class BrowserContextKeyedAPIFactory<PushMessagingAPI>;
140 140
141 // ProfileKeyedAPI implementation. 141 // BrowserContextKeyedAPI implementation.
142 static const char* service_name() { 142 static const char* service_name() {
143 return "PushMessagingAPI"; 143 return "PushMessagingAPI";
144 } 144 }
145 static const bool kServiceIsNULLWhileTesting = true; 145 static const bool kServiceIsNULLWhileTesting = true;
146 146
147 // content::NotificationDelegate implementation. 147 // content::NotificationDelegate implementation.
148 virtual void Observe(int type, 148 virtual void Observe(int type,
149 const content::NotificationSource& source, 149 const content::NotificationSource& source,
150 const content::NotificationDetails& details) OVERRIDE; 150 const content::NotificationDetails& details) OVERRIDE;
151 151
152 // Created lazily when an app or extension with the push messaging permission 152 // Created lazily when an app or extension with the push messaging permission
153 // is loaded. 153 // is loaded.
154 scoped_ptr<PushMessagingEventRouter> event_router_; 154 scoped_ptr<PushMessagingEventRouter> event_router_;
155 scoped_ptr<PushMessagingInvalidationMapper> handler_; 155 scoped_ptr<PushMessagingInvalidationMapper> handler_;
156 156
157 content::NotificationRegistrar registrar_; 157 content::NotificationRegistrar registrar_;
158 158
159 Profile* profile_; 159 Profile* profile_;
160 160
161 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI); 161 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI);
162 }; 162 };
163 163
164 template <> 164 template <>
165 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies(); 165 void BrowserContextKeyedAPIFactory<
166 PushMessagingAPI>::DeclareFactoryDependencies();
166 167
167 } // namespace extensions 168 } // namespace extensions
168 169
169 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ 170 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698