Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: extensions/browser/browser_context_keyed_api_factory.h

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
Nico 2017/03/07 21:43:02 should this recommend the leaky version?
scottmg 2017/03/07 21:56:30 I changed the lazy_instance.h one to recommend lea
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698