OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |