OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ | 5 #ifndef COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ |
6 #define COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ | 6 #define COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // implementors must explicitly state which services are depended on. | 25 // implementors must explicitly state which services are depended on. |
26 class KEYED_SERVICE_EXPORT BrowserContextKeyedServiceFactory | 26 class KEYED_SERVICE_EXPORT BrowserContextKeyedServiceFactory |
27 : public BrowserContextKeyedBaseFactory { | 27 : public BrowserContextKeyedBaseFactory { |
28 public: | 28 public: |
29 // A function that supplies the instance of a KeyedService for a given | 29 // A function that supplies the instance of a KeyedService for a given |
30 // BrowserContext. This is used primarily for testing, where we want to feed | 30 // BrowserContext. This is used primarily for testing, where we want to feed |
31 // a specific mock into the BCKSF system. | 31 // a specific mock into the BCKSF system. |
32 typedef KeyedService* (*TestingFactoryFunction)( | 32 typedef KeyedService* (*TestingFactoryFunction)( |
33 content::BrowserContext* context); | 33 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 the |
36 // the KeyedService when requested. |factory| can be NULL to signal that | 36 // KeyedService when requested. |factory| can be NULL to signal that the |
37 // KeyedService should be NULL. Multiple calls to SetTestingFactory() are | 37 // KeyedService should be NULL. |context| can be NULL to signal that the |
38 // allowed; previous services will be shut down. | 38 // factory should be used for all contexts. Multiple calls to |
| 39 // SetTestingFactory() are allowed; previous services will be shut down. |
39 void SetTestingFactory(content::BrowserContext* context, | 40 void SetTestingFactory(content::BrowserContext* context, |
40 TestingFactoryFunction factory); | 41 TestingFactoryFunction factory); |
41 | 42 |
42 // Associates |factory| with |context| and immediately returns the created | 43 // Associates |factory| with |context| and immediately returns the created |
43 // KeyedService. Since the factory will be used immediately, it may not be | 44 // KeyedService. Since the factory will be used immediately, it may not be |
44 // NULL. | 45 // NULL. |
45 KeyedService* SetTestingFactoryAndUse(content::BrowserContext* context, | 46 KeyedService* SetTestingFactoryAndUse(content::BrowserContext* context, |
46 TestingFactoryFunction factory); | 47 TestingFactoryFunction factory); |
47 | 48 |
48 protected: | 49 protected: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 BrowserContextKeyedServices mapping_; | 115 BrowserContextKeyedServices mapping_; |
115 | 116 |
116 // The mapping between a BrowserContext and its overridden | 117 // The mapping between a BrowserContext and its overridden |
117 // TestingFactoryFunction. | 118 // TestingFactoryFunction. |
118 BrowserContextOverriddenTestingFunctions testing_factories_; | 119 BrowserContextOverriddenTestingFunctions testing_factories_; |
119 | 120 |
120 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); | 121 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); |
121 }; | 122 }; |
122 | 123 |
123 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTOR
Y_H_ | 124 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTOR
Y_H_ |
OLD | NEW |