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 EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ | 5 #ifndef EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ |
6 #define EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ | 6 #define EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ |
7 | 7 |
8 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
9 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 9 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // If set to false, don't start the service at BrowserContext creation time. | 37 // If set to false, don't start the service at BrowserContext creation time. |
38 // (The default differs from the BrowserContextKeyedBaseFactory default, | 38 // (The default differs from the BrowserContextKeyedBaseFactory default, |
39 // because historically, BrowserContextKeyedAPIs often do tasks at startup.) | 39 // because historically, BrowserContextKeyedAPIs often do tasks at startup.) |
40 static const bool kServiceIsCreatedWithBrowserContext = true; | 40 static const bool kServiceIsCreatedWithBrowserContext = true; |
41 | 41 |
42 // If set to true, GetForProfile returns NULL for TestingBrowserContexts. | 42 // If set to true, GetForProfile returns NULL for TestingBrowserContexts. |
43 static const bool kServiceIsNULLWhileTesting = false; | 43 static const bool kServiceIsNULLWhileTesting = false; |
44 | 44 |
45 // Users of this factory template must define a GetFactoryInstance() | 45 // Users of this factory template must define a GetFactoryInstance() |
46 // and manage their own instances (typically using LazyInstance or | 46 // and manage their own instances (using LazyInstance), because those cannot |
47 // Singleton), because those cannot be included in more than one | 47 // be included in more than one translation unit (and thus cannot be |
48 // translation unit (and thus cannot be initialized in a header file). | 48 // initialized in a header file). |
49 // | 49 // |
50 // In the header file, declare GetFactoryInstance(), e.g.: | 50 // In the header file, declare GetFactoryInstance(), e.g.: |
51 // class HistoryAPI { | 51 // class HistoryAPI { |
52 // ... | 52 // ... |
53 // public: | 53 // public: |
54 // static BrowserContextKeyedAPIFactory<HistoryAPI>* GetFactoryInstance(); | 54 // static BrowserContextKeyedAPIFactory<HistoryAPI>* GetFactoryInstance(); |
55 // }; | 55 // }; |
56 // | 56 // |
57 // In the cc file, provide the implementation, e.g.: | 57 // In the cc file, provide the implementation, e.g.: |
58 // static base::LazyInstance<BrowserContextKeyedAPIFactory<HistoryAPI> > | 58 // static base::LazyInstance<BrowserContextKeyedAPIFactory<HistoryAPI> > |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 bool ServiceIsNULLWhileTesting() const override { | 127 bool ServiceIsNULLWhileTesting() const override { |
128 return T::kServiceIsNULLWhileTesting; | 128 return T::kServiceIsNULLWhileTesting; |
129 } | 129 } |
130 | 130 |
131 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedAPIFactory); | 131 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedAPIFactory); |
132 }; | 132 }; |
133 | 133 |
134 } // namespace extensions | 134 } // namespace extensions |
135 | 135 |
136 #endif // EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ | 136 #endif // EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ |
OLD | NEW |