| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // initialized in a header file). | 49 // initialized in a header file). |
| 50 // | 50 // |
| 51 // In the header file, declare GetFactoryInstance(), e.g.: | 51 // In the header file, declare GetFactoryInstance(), e.g.: |
| 52 // class HistoryAPI { | 52 // class HistoryAPI { |
| 53 // ... | 53 // ... |
| 54 // public: | 54 // public: |
| 55 // static BrowserContextKeyedAPIFactory<HistoryAPI>* GetFactoryInstance(); | 55 // static BrowserContextKeyedAPIFactory<HistoryAPI>* GetFactoryInstance(); |
| 56 // }; | 56 // }; |
| 57 // | 57 // |
| 58 // In the cc file, provide the implementation, e.g.: | 58 // In the cc file, provide the implementation, e.g.: |
| 59 // static base::LazyInstance<BrowserContextKeyedAPIFactory<HistoryAPI> > | 59 // static base::LazyInstance<BrowserContextKeyedAPIFactory<HistoryAPI>>:: |
| 60 // g_factory = LAZY_INSTANCE_INITIALIZER; | 60 // DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; |
| 61 // | 61 // |
| 62 // // static | 62 // // static |
| 63 // BrowserContextKeyedAPIFactory<HistoryAPI>* | 63 // BrowserContextKeyedAPIFactory<HistoryAPI>* |
| 64 // HistoryAPI::GetFactoryInstance() { | 64 // HistoryAPI::GetFactoryInstance() { |
| 65 // return g_factory.Pointer(); | 65 // return g_factory.Pointer(); |
| 66 // } | 66 // } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // A template for factories for KeyedServices that manage extension APIs. T is | 69 // A template for factories for KeyedServices that manage extension APIs. T is |
| 70 // a KeyedService that uses this factory template instead of its own separate | 70 // a KeyedService that uses this factory template instead of its own separate |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 bool ServiceIsNULLWhileTesting() const override { | 133 bool ServiceIsNULLWhileTesting() const override { |
| 134 return T::kServiceIsNULLWhileTesting; | 134 return T::kServiceIsNULLWhileTesting; |
| 135 } | 135 } |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedAPIFactory); | 137 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedAPIFactory); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 } // namespace extensions | 140 } // namespace extensions |
| 141 | 141 |
| 142 #endif // EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ | 142 #endif // EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ |
| OLD | NEW |