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

Side by Side Diff: extensions/common/extension_api.cc

Issue 2338273005: [Extensions] Make feature-related singletons leaky (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | extensions/common/features/feature_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "extensions/common/extension_api.h" 5 #include "extensions/common/extension_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return NULL; 92 return NULL;
93 } 93 }
94 94
95 struct Static { 95 struct Static {
96 Static() 96 Static()
97 : api(ExtensionAPI::CreateWithDefaultConfiguration()) { 97 : api(ExtensionAPI::CreateWithDefaultConfiguration()) {
98 } 98 }
99 std::unique_ptr<ExtensionAPI> api; 99 std::unique_ptr<ExtensionAPI> api;
100 }; 100 };
101 101
102 base::LazyInstance<Static> g_lazy_instance = LAZY_INSTANCE_INITIALIZER; 102 base::LazyInstance<Static>::Leaky g_lazy_instance = LAZY_INSTANCE_INITIALIZER;
103 103
104 // May override |g_lazy_instance| for a test. 104 // May override |g_lazy_instance| for a test.
105 ExtensionAPI* g_shared_instance_for_test = NULL; 105 ExtensionAPI* g_shared_instance_for_test = NULL;
106 106
107 } // namespace 107 } // namespace
108 108
109 // static 109 // static
110 ExtensionAPI* ExtensionAPI::GetSharedInstance() { 110 ExtensionAPI* ExtensionAPI::GetSharedInstance() {
111 return g_shared_instance_for_test ? g_shared_instance_for_test 111 return g_shared_instance_for_test ? g_shared_instance_for_test
112 : g_lazy_instance.Get().api.get(); 112 : g_lazy_instance.Get().api.get();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return std::string(); 306 return std::string();
307 } 307 }
308 308
309 bool ExtensionAPI::IsKnownAPI(const std::string& name, 309 bool ExtensionAPI::IsKnownAPI(const std::string& name,
310 ExtensionsClient* client) { 310 ExtensionsClient* client) {
311 return schemas_.find(name) != schemas_.end() || 311 return schemas_.find(name) != schemas_.end() ||
312 client->IsAPISchemaGenerated(name); 312 client->IsAPISchemaGenerated(name);
313 } 313 }
314 314
315 } // namespace extensions 315 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/common/features/feature_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698