| OLD | NEW |
| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" | 12 #include "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" |
| 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 14 #include "components/browser_context_keyed_service/browser_context_keyed_service
_export.h" |
| 14 | 15 |
| 15 class BrowserContextDependencyManager; | 16 class BrowserContextDependencyManager; |
| 16 class BrowserContextKeyedService; | 17 class BrowserContextKeyedService; |
| 17 | 18 |
| 18 // Base class for Factories that take a BrowserContext object and return some | 19 // Base class for Factories that take a BrowserContext object and return some |
| 19 // service on a one-to-one mapping. Each factory that derives from this class | 20 // service on a one-to-one mapping. Each factory that derives from this class |
| 20 // *must* be a Singleton (only unit tests don't do that). | 21 // *must* be a Singleton (only unit tests don't do that). |
| 21 // | 22 // |
| 22 // We do this because services depend on each other and we need to control | 23 // We do this because services depend on each other and we need to control |
| 23 // shutdown/destruction order. In each derived classes' constructors, the | 24 // shutdown/destruction order. In each derived classes' constructors, the |
| 24 // implementors must explicitly state which services are depended on. | 25 // implementors must explicitly state which services are depended on. |
| 25 class BrowserContextKeyedServiceFactory | 26 class BROWSER_CONTEXT_KEYED_SERVICE_EXPORT BrowserContextKeyedServiceFactory |
| 26 : public BrowserContextKeyedBaseFactory { | 27 : public BrowserContextKeyedBaseFactory { |
| 27 public: | 28 public: |
| 28 // A function that supplies the instance of a BrowserContextKeyedService | 29 // A function that supplies the instance of a BrowserContextKeyedService |
| 29 // for a given BrowserContext. This is used primarily for testing, where | 30 // for a given BrowserContext. This is used primarily for testing, where |
| 30 // we want to feed a specific mock into the BCKSF system. | 31 // we want to feed a specific mock into the BCKSF system. |
| 31 typedef BrowserContextKeyedService* | 32 typedef BrowserContextKeyedService* |
| 32 (*FactoryFunction)(content::BrowserContext* context); | 33 (*FactoryFunction)(content::BrowserContext* context); |
| 33 | 34 |
| 34 // Associates |factory| with |context| so that |factory| is used to create | 35 // Associates |factory| with |context| so that |factory| is used to create |
| 35 // the BrowserContextKeyedService when requested. |factory| can be NULL | 36 // the BrowserContextKeyedService when requested. |factory| can be NULL |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // The mapping between a BrowserContext and its service. | 112 // The mapping between a BrowserContext and its service. |
| 112 std::map<content::BrowserContext*, BrowserContextKeyedService*> mapping_; | 113 std::map<content::BrowserContext*, BrowserContextKeyedService*> mapping_; |
| 113 | 114 |
| 114 // The mapping between a BrowserContext and its overridden FactoryFunction. | 115 // The mapping between a BrowserContext and its overridden FactoryFunction. |
| 115 std::map<content::BrowserContext*, FactoryFunction> factories_; | 116 std::map<content::BrowserContext*, FactoryFunction> factories_; |
| 116 | 117 |
| 117 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); | 118 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVIC
E_FACTORY_H_ | 121 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVIC
E_FACTORY_H_ |
| OLD | NEW |