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_REFCOUNTED_BROWSER_CONTEXT_KEYED_SERVIC
E_FACTORY_H_ | 5 #ifndef COMPONENTS_KEYED_SERVICE_CONTENT_REFCOUNTED_BROWSER_CONTEXT_KEYED_SERVIC
E_FACTORY_H_ |
6 #define COMPONENTS_KEYED_SERVICE_CONTENT_REFCOUNTED_BROWSER_CONTEXT_KEYED_SERVIC
E_FACTORY_H_ | 6 #define COMPONENTS_KEYED_SERVICE_CONTENT_REFCOUNTED_BROWSER_CONTEXT_KEYED_SERVIC
E_FACTORY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // object destruction can happen anywhere. | 29 // object destruction can happen anywhere. |
30 class KEYED_SERVICE_EXPORT RefcountedBrowserContextKeyedServiceFactory | 30 class KEYED_SERVICE_EXPORT RefcountedBrowserContextKeyedServiceFactory |
31 : public BrowserContextKeyedBaseFactory { | 31 : public BrowserContextKeyedBaseFactory { |
32 public: | 32 public: |
33 // A function that supplies the instance of a KeyedService for a given | 33 // A function that supplies the instance of a KeyedService for a given |
34 // BrowserContext. This is used primarily for testing, where we want to feed | 34 // BrowserContext. This is used primarily for testing, where we want to feed |
35 // a specific mock into the BCKSF system. | 35 // a specific mock into the BCKSF system. |
36 typedef scoped_refptr<RefcountedBrowserContextKeyedService>( | 36 typedef scoped_refptr<RefcountedBrowserContextKeyedService>( |
37 *TestingFactoryFunction)(content::BrowserContext* context); | 37 *TestingFactoryFunction)(content::BrowserContext* context); |
38 | 38 |
39 // Associates |factory| with |context| so that |factory| is used to create | 39 // Associates |factory| with |context| so that |factory| is used to create the |
40 // the KeyedService when requested. |factory| can be NULL to signal that | 40 // KeyedService when requested. |factory| can be NULL to signal that the |
41 // KeyedService should be NULL. Multiple calls to SetTestingFactory() are | 41 // KeyedService should be NULL. |context| can be NULL to signal that the |
42 // allowed; previous services will be shut down. | 42 // factory should be used for all contexts. Multiple calls to |
| 43 // SetTestingFactory() are allowed; previous services will be shut down. |
43 void SetTestingFactory(content::BrowserContext* context, | 44 void SetTestingFactory(content::BrowserContext* context, |
44 TestingFactoryFunction factory); | 45 TestingFactoryFunction factory); |
45 | 46 |
46 // Associates |factory| with |context| and immediately returns the created | 47 // Associates |factory| with |context| and immediately returns the created |
47 // KeyedService. Since the factory will be used immediately, it may not be | 48 // KeyedService. Since the factory will be used immediately, it may not be |
48 // NULL. | 49 // NULL. |
49 scoped_refptr<RefcountedBrowserContextKeyedService> SetTestingFactoryAndUse( | 50 scoped_refptr<RefcountedBrowserContextKeyedService> SetTestingFactoryAndUse( |
50 content::BrowserContext* context, | 51 content::BrowserContext* context, |
51 TestingFactoryFunction factory); | 52 TestingFactoryFunction factory); |
52 | 53 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 RefCountedStorage mapping_; | 91 RefCountedStorage mapping_; |
91 | 92 |
92 // The mapping between a BrowserContext and its overridden | 93 // The mapping between a BrowserContext and its overridden |
93 // TestingFactoryFunction. | 94 // TestingFactoryFunction. |
94 BrowserContextOverriddenTestingFunctions testing_factories_; | 95 BrowserContextOverriddenTestingFunctions testing_factories_; |
95 | 96 |
96 DISALLOW_COPY_AND_ASSIGN(RefcountedBrowserContextKeyedServiceFactory); | 97 DISALLOW_COPY_AND_ASSIGN(RefcountedBrowserContextKeyedServiceFactory); |
97 }; | 98 }; |
98 | 99 |
99 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_REFCOUNTED_BROWSER_CONTEXT_KEYED_SER
VICE_FACTORY_H_ | 100 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_REFCOUNTED_BROWSER_CONTEXT_KEYED_SER
VICE_FACTORY_H_ |
OLD | NEW |