| 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 CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/extension_system_factory.h" | 8 #include "chrome/browser/extensions/extension_system_factory.h" |
| 9 #include "chrome/browser/profiles/incognito_helpers.h" | 9 #include "chrome/browser/profiles/incognito_helpers.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // static ProfileKeyedAPIFactory<ProcessesAPI>* GetFactoryInstance(); | 42 // static ProfileKeyedAPIFactory<ProcessesAPI>* GetFactoryInstance(); |
| 43 // }; | 43 // }; |
| 44 // | 44 // |
| 45 // In the cc file, provide the implementation, e.g.: | 45 // In the cc file, provide the implementation, e.g.: |
| 46 // static base::LazyInstance<ProfileKeyedAPIFactory<ProcessesAPI> > | 46 // static base::LazyInstance<ProfileKeyedAPIFactory<ProcessesAPI> > |
| 47 // g_factory = LAZY_INSTANCE_INITIALIZER; | 47 // g_factory = LAZY_INSTANCE_INITIALIZER; |
| 48 // | 48 // |
| 49 // // static | 49 // // static |
| 50 // ProfileKeyedAPIFactory<ProcessesAPI>* | 50 // ProfileKeyedAPIFactory<ProcessesAPI>* |
| 51 // ProcessesAPI::GetFactoryInstance() { | 51 // ProcessesAPI::GetFactoryInstance() { |
| 52 // return &g_factory.Get(); | 52 // return g_factory.Pointer(); |
| 53 // } | 53 // } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // A template for factories for BrowserContextKeyedServices that manage | 56 // A template for factories for BrowserContextKeyedServices that manage |
| 57 // extension APIs. T is a BrowserContextKeyedService that uses this factory | 57 // extension APIs. T is a BrowserContextKeyedService that uses this factory |
| 58 // template instead of its own separate factory definition to manage its | 58 // template instead of its own separate factory definition to manage its |
| 59 // per-profile instances. | 59 // per-profile instances. |
| 60 template <typename T> | 60 template <typename T> |
| 61 class ProfileKeyedAPIFactory : public BrowserContextKeyedServiceFactory { | 61 class ProfileKeyedAPIFactory : public BrowserContextKeyedServiceFactory { |
| 62 public: | 62 public: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { | 116 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { |
| 117 return T::kServiceIsNULLWhileTesting; | 117 return T::kServiceIsNULLWhileTesting; |
| 118 } | 118 } |
| 119 | 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); | 120 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 } // namespace extensions | 123 } // namespace extensions |
| 124 | 124 |
| 125 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 125 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
| OLD | NEW |