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

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

Issue 11682005: Remove some Profile-keyed factory boilerplate: management omnibox preference push_messaging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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"
14 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche r.h" 15 #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" 16 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler_delegate.h"
16 #include "chrome/browser/extensions/extension_function.h" 17 #include "chrome/browser/extensions/extension_function.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 18 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 #include "google_apis/gaia/google_service_auth_error.h" 21 #include "google_apis/gaia/google_service_auth_error.h"
22 22
23 class Profile; 23 class Profile;
24 24
25 namespace extensions { 25 namespace extensions {
26 26
27 class PushMessagingInvalidationMapper; 27 class PushMessagingInvalidationMapper;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) 96 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id)
97 OVERRIDE; 97 OVERRIDE;
98 virtual void OnObfuscatedGaiaIdFetchFailure( 98 virtual void OnObfuscatedGaiaIdFetchFailure(
99 const GoogleServiceAuthError& error) OVERRIDE; 99 const GoogleServiceAuthError& error) OVERRIDE;
100 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; 100 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_;
101 bool interactive_; 101 bool interactive_;
102 102
103 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); 103 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction);
104 }; 104 };
105 105
106 class PushMessagingAPI : public ProfileKeyedService { 106 class PushMessagingAPI : public ProfileKeyedAPI {
107 public: 107 public:
108 explicit PushMessagingAPI(Profile* profile); 108 explicit PushMessagingAPI(Profile* profile);
109 virtual ~PushMessagingAPI(); 109 virtual ~PushMessagingAPI();
110 110
111 // Convenience method to get the PushMessagingAPI for a profile. 111 // Convenience method to get the PushMessagingAPI for a profile.
112 static PushMessagingAPI* Get(Profile* profile); 112 static PushMessagingAPI* Get(Profile* profile);
113 113
114 // ProfileKeyedService implementation. 114 // ProfileKeyedService implementation.
115 virtual void Shutdown() OVERRIDE; 115 virtual void Shutdown() OVERRIDE;
116 116
117 // ProfileKeyedAPI implementation.
118 static ProfileKeyedAPIFactory<PushMessagingAPI>* GetFactoryInstance();
119
117 // For testing purposes. 120 // For testing purposes.
118 PushMessagingEventRouter* GetEventRouterForTest(); 121 PushMessagingEventRouter* GetEventRouterForTest();
119 122
120 private: 123 private:
124 friend class ProfileKeyedAPIFactory<PushMessagingAPI>;
125
126 // ProfileKeyedAPI implementation.
127 static const char* service_name() {
128 return "PushMessagingAPI";
129 }
130 static const bool kServiceIsCreatedWithProfile = false;
131 static const bool kServiceIsNULLWhileTesting = true;
132
121 // Created at ExtensionService startup. 133 // Created at ExtensionService startup.
122 scoped_ptr<PushMessagingEventRouter> push_messaging_event_router_; 134 scoped_ptr<PushMessagingEventRouter> push_messaging_event_router_;
123 135
124 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI); 136 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI);
125 }; 137 };
126 138
127 } // namespace extension 139 template <>
140 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies();
141
142 } // namespace extensions
128 143
129 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ 144 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698