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

Side by Side Diff: chrome/browser/extensions/api/profile_keyed_api_factory.h

Issue 171813010: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 1). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: browser_context_ Created 6 years, 10 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
« no previous file with comments | « chrome/browser/extensions/api/feedback_private/feedback_private_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PROFILE_KEYED_API_FACTORY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_
7 7
8 #include "chrome/browser/profiles/incognito_helpers.h" 8 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // } 54 // }
55 }; 55 };
56 56
57 // A template for factories for BrowserContextKeyedServices that manage 57 // A template for factories for BrowserContextKeyedServices that manage
58 // extension APIs. T is a BrowserContextKeyedService that uses this factory 58 // extension APIs. T is a BrowserContextKeyedService that uses this factory
59 // template instead of its own separate factory definition to manage its 59 // template instead of its own separate factory definition to manage its
60 // per-profile instances. 60 // per-profile instances.
61 template <typename T> 61 template <typename T>
62 class ProfileKeyedAPIFactory : public BrowserContextKeyedServiceFactory { 62 class ProfileKeyedAPIFactory : public BrowserContextKeyedServiceFactory {
63 public: 63 public:
64 // TODO(yoz): Delete this one.
64 static T* GetForProfile(Profile* profile) { 65 static T* GetForProfile(Profile* profile) {
65 return static_cast<T*>( 66 return static_cast<T*>(
66 T::GetFactoryInstance()->GetServiceForBrowserContext(profile, true)); 67 T::GetFactoryInstance()->GetServiceForBrowserContext(profile, true));
67 } 68 }
68 69
70 static T* GetForProfile(content::BrowserContext* context) {
71 return static_cast<T*>(T::GetFactoryInstance()->GetServiceForBrowserContext(
72 Profile::FromBrowserContext(context), true));
73 }
74
69 // Declare dependencies on other factories. 75 // Declare dependencies on other factories.
70 // By default, ExtensionSystemFactory is the only dependency; however, 76 // By default, ExtensionSystemFactory is the only dependency; however,
71 // specializations can override this. Declare your specialization in 77 // specializations can override this. Declare your specialization in
72 // your header file after the ProfileKeyedAPI class definition. 78 // your header file after the ProfileKeyedAPI class definition.
73 // Then in the cc file (or inline in the header), define it, e.g.: 79 // Then in the cc file (or inline in the header), define it, e.g.:
74 // template <> 80 // template <>
75 // ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { 81 // ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() {
76 // DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 82 // DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
77 // DependsOn(ProfileSyncServiceFactory::GetInstance()); 83 // DependsOn(ProfileSyncServiceFactory::GetInstance());
78 // } 84 // }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { 123 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE {
118 return T::kServiceIsNULLWhileTesting; 124 return T::kServiceIsNULLWhileTesting;
119 } 125 }
120 126
121 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); 127 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory);
122 }; 128 };
123 129
124 } // namespace extensions 130 } // namespace extensions
125 131
126 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ 132 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/feedback_private/feedback_private_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698