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

Side by Side Diff: components/browser_context_keyed_service/browser_context_keyed_service_factory.h

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android fixes. Created 7 years, 4 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 COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVICE_F ACTORY_H_ 5 #ifndef COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVICE_F ACTORY_H_
6 #define COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVICE_F ACTORY_H_ 6 #define COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVICE_F ACTORY_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 21 matching lines...) Expand all
32 typedef BrowserContextKeyedService* 32 typedef BrowserContextKeyedService*
33 (*FactoryFunction)(content::BrowserContext* context); 33 (*FactoryFunction)(content::BrowserContext* context);
34 34
35 // Associates |factory| with |context| so that |factory| is used to create 35 // Associates |factory| with |context| so that |factory| is used to create
36 // the BrowserContextKeyedService when requested. |factory| can be NULL 36 // the BrowserContextKeyedService when requested. |factory| can be NULL
37 // to signal that BrowserContextKeyedService should be NULL. Multiple calls to 37 // to signal that BrowserContextKeyedService should be NULL. Multiple calls to
38 // SetTestingFactory() are allowed; previous services will be shut down. 38 // SetTestingFactory() are allowed; previous services will be shut down.
39 void SetTestingFactory(content::BrowserContext* context, 39 void SetTestingFactory(content::BrowserContext* context,
40 FactoryFunction factory); 40 FactoryFunction factory);
41 41
42 // Like SetTestingFactory(), but takes effect for all contexts. This is useful
43 // for injecting services that are created as part of context initialization.
44 // Callers should be sure to call ResetGlobalTestingFactory() at the end of
45 // their test to avoid polluting the singletons for future tests.
46 void SetGlobalTestingFactory(FactoryFunction factory);
Elliot Glaysher 2013/08/16 18:07:59 (Other half of code commented on.)
Andrew T Wilson (Slow) 2013/08/19 12:15:56 So, yeah, I'm happy to revert this part of my CL (
47
48 // Clears a global testing factory that was previously set.
49 void ResetGlobalTestingFactory();
50
42 // Associates |factory| with |context| and immediately returns the created 51 // Associates |factory| with |context| and immediately returns the created
43 // BrowserContextKeyedService. Since the factory will be used immediately, 52 // BrowserContextKeyedService. Since the factory will be used immediately,
44 // it may not be NULL. 53 // it may not be NULL.
45 BrowserContextKeyedService* SetTestingFactoryAndUse( 54 BrowserContextKeyedService* SetTestingFactoryAndUse(
46 content::BrowserContext* context, 55 content::BrowserContext* context,
47 FactoryFunction factory); 56 FactoryFunction factory);
48 57
49 protected: 58 protected:
50 // BrowserContextKeyedServiceFactories must communicate with a 59 // BrowserContextKeyedServiceFactories must communicate with a
51 // BrowserContextDependencyManager. For all non-test code, write your subclass 60 // BrowserContextDependencyManager. For all non-test code, write your subclass
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 112
104 private: 113 private:
105 friend class BrowserContextDependencyManager; 114 friend class BrowserContextDependencyManager;
106 friend class BrowserContextDependencyManagerUnittests; 115 friend class BrowserContextDependencyManagerUnittests;
107 116
108 typedef std::map<content::BrowserContext*, BrowserContextKeyedService*> 117 typedef std::map<content::BrowserContext*, BrowserContextKeyedService*>
109 BrowserContextKeyedServices; 118 BrowserContextKeyedServices;
110 typedef std::map<content::BrowserContext*, FactoryFunction> 119 typedef std::map<content::BrowserContext*, FactoryFunction>
111 BrowserContextOverriddenFunctions; 120 BrowserContextOverriddenFunctions;
112 121
122 void CleanupExistingServices(content::BrowserContext* context);
123
113 // The mapping between a BrowserContext and its service. 124 // The mapping between a BrowserContext and its service.
114 std::map<content::BrowserContext*, BrowserContextKeyedService*> mapping_; 125 std::map<content::BrowserContext*, BrowserContextKeyedService*> mapping_;
115 126
116 // The mapping between a BrowserContext and its overridden FactoryFunction. 127 // The mapping between a BrowserContext and its overridden FactoryFunction.
117 std::map<content::BrowserContext*, FactoryFunction> factories_; 128 std::map<content::BrowserContext*, FactoryFunction> factories_;
118 129
130 FactoryFunction global_factory_;
131 bool have_global_factory_;
132
119 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); 133 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory);
120 }; 134 };
121 135
122 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVIC E_FACTORY_H_ 136 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVIC E_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698