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

Side by Side Diff: chrome/renderer/extensions/chrome_v8_extension.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments + rebase Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698