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

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

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan 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_webstore_bindings.h" 5 #include "chrome/renderer/extensions/chrome_webstore_bindings.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/common/extensions/extension.h" 9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/renderer/extensions/extension_helper.h" 10 #include "chrome/renderer/extensions/extension_helper.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const char kNoWebstoreItemLinkFoundError[] = 43 const char kNoWebstoreItemLinkFoundError[] =
44 "No Chrome Web Store item link found."; 44 "No Chrome Web Store item link found.";
45 const char kInvalidWebstoreItemUrlError[] = 45 const char kInvalidWebstoreItemUrlError[] =
46 "Invalid Chrome Web Store item URL."; 46 "Invalid Chrome Web Store item URL.";
47 47
48 // chrome.webstore.install() calls generate an install ID so that the install's 48 // chrome.webstore.install() calls generate an install ID so that the install's
49 // callbacks may be fired when the browser notifies us of install completion 49 // callbacks may be fired when the browser notifies us of install completion
50 // (successful or not) via HandleInstallResponse. 50 // (successful or not) via HandleInstallResponse.
51 int g_next_install_id = 0; 51 int g_next_install_id = 0;
52 52
53 base::LazyInstance<WeakV8FunctionMap> g_success_callbacks( 53 base::LazyInstance<WeakV8FunctionMap> g_success_callbacks =
54 base::LINKER_INITIALIZED); 54 LAZY_INSTANCE_INITIALIZER;
55 base::LazyInstance<WeakV8FunctionMap> g_failure_callbacks( 55 base::LazyInstance<WeakV8FunctionMap> g_failure_callbacks =
56 base::LINKER_INITIALIZED); 56 LAZY_INSTANCE_INITIALIZER;
57 57
58 } // anonymous namespace 58 } // anonymous namespace
59 59
60 class ExtensionImpl : public v8::Extension { 60 class ExtensionImpl : public v8::Extension {
61 public: 61 public:
62 ExtensionImpl() : 62 ExtensionImpl() :
63 v8::Extension( 63 v8::Extension(
64 kWebstoreV8ExtensionName, 64 kWebstoreV8ExtensionName,
65 "var chrome = chrome || {};" 65 "var chrome = chrome || {};"
66 "if (!chrome.webstore) {" 66 "if (!chrome.webstore) {"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 v8::Persistent<v8::Function> function = callback_map.Remove(install_id); 240 v8::Persistent<v8::Function> function = callback_map.Remove(install_id);
241 if (function.IsEmpty()) 241 if (function.IsEmpty())
242 return; 242 return;
243 243
244 v8::HandleScope handle_scope; 244 v8::HandleScope handle_scope;
245 v8::Context::Scope context_scope(function->CreationContext()); 245 v8::Context::Scope context_scope(function->CreationContext());
246 v8::Handle<v8::Value> argv[1]; 246 v8::Handle<v8::Value> argv[1];
247 argv[0] = v8::String::New(error.c_str()); 247 argv[0] = v8::String::New(error.c_str());
248 function->Call(v8::Object::New(), arraysize(argv), argv); 248 function->Call(v8::Object::New(), arraysize(argv), argv);
249 } 249 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_extension.cc ('k') | chrome/renderer/extensions/event_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698