OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/extensions/chrome_v8_extension.h" | 5 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 const char kChromeHidden[] = "chromeHidden"; | 28 const char kChromeHidden[] = "chromeHidden"; |
29 | 29 |
30 #ifndef NDEBUG | 30 #ifndef NDEBUG |
31 const char kValidateCallbacks[] = "validateCallbacks"; | 31 const char kValidateCallbacks[] = "validateCallbacks"; |
32 #endif | 32 #endif |
33 | 33 |
34 typedef std::map<int, std::string> StringMap; | 34 typedef std::map<int, std::string> StringMap; |
35 static base::LazyInstance<StringMap> g_string_map(base::LINKER_INITIALIZED); | 35 static base::LazyInstance<StringMap> g_string_map = LAZY_INSTANCE_INITIALIZER; |
36 | 36 |
37 static base::LazyInstance<ChromeV8Extension::InstanceSet> g_instances( | 37 static base::LazyInstance<ChromeV8Extension::InstanceSet> g_instances = |
38 base::LINKER_INITIALIZED); | 38 LAZY_INSTANCE_INITIALIZER; |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 | 42 |
43 // static | 43 // static |
44 const char* ChromeV8Extension::GetStringResource(int resource_id) { | 44 const char* ChromeV8Extension::GetStringResource(int resource_id) { |
45 StringMap* strings = g_string_map.Pointer(); | 45 StringMap* strings = g_string_map.Pointer(); |
46 StringMap::iterator it = strings->find(resource_id); | 46 StringMap::iterator it = strings->find(resource_id); |
47 if (it == strings->end()) { | 47 if (it == strings->end()) { |
48 it = strings->insert(std::make_pair( | 48 it = strings->insert(std::make_pair( |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (args.Length() < 1) | 236 if (args.Length() < 1) |
237 return v8::Undefined(); | 237 return v8::Undefined(); |
238 | 238 |
239 std::vector<std::string> components; | 239 std::vector<std::string> components; |
240 for (int i = 0; i < args.Length(); ++i) | 240 for (int i = 0; i < args.Length(); ++i) |
241 components.push_back(*v8::String::Utf8Value(args[i]->ToString())); | 241 components.push_back(*v8::String::Utf8Value(args[i]->ToString())); |
242 | 242 |
243 LOG(ERROR) << JoinString(components, ','); | 243 LOG(ERROR) << JoinString(components, ','); |
244 return v8::Undefined(); | 244 return v8::Undefined(); |
245 } | 245 } |
OLD | NEW |