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

Side by Side Diff: chrome/renderer/extensions/miscellaneous_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/miscellaneous_bindings.h" 5 #include "chrome/renderer/extensions/miscellaneous_bindings.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 27 matching lines...) Expand all
38 38
39 struct ExtensionData { 39 struct ExtensionData {
40 struct PortData { 40 struct PortData {
41 int ref_count; // how many contexts have a handle to this port 41 int ref_count; // how many contexts have a handle to this port
42 bool disconnected; // true if this port was forcefully disconnected 42 bool disconnected; // true if this port was forcefully disconnected
43 PortData() : ref_count(0), disconnected(false) {} 43 PortData() : ref_count(0), disconnected(false) {}
44 }; 44 };
45 std::map<int, PortData> ports; // port ID -> data 45 std::map<int, PortData> ports; // port ID -> data
46 }; 46 };
47 47
48 static base::LazyInstance<ExtensionData> g_extension_data( 48 static base::LazyInstance<ExtensionData> g_extension_data =
49 base::LINKER_INITIALIZED); 49 LAZY_INSTANCE_INITIALIZER;
50 50
51 static bool HasPortData(int port_id) { 51 static bool HasPortData(int port_id) {
52 return g_extension_data.Get().ports.find(port_id) != 52 return g_extension_data.Get().ports.find(port_id) !=
53 g_extension_data.Get().ports.end(); 53 g_extension_data.Get().ports.end();
54 } 54 }
55 55
56 static ExtensionData::PortData& GetPortData(int port_id) { 56 static ExtensionData::PortData& GetPortData(int port_id) {
57 return g_extension_data.Get().ports[port_id]; 57 return g_extension_data.Get().ports[port_id];
58 } 58 }
59 59
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 arguments.push_back(v8::String::New(message.c_str(), message.size())); 289 arguments.push_back(v8::String::New(message.c_str(), message.size()));
290 arguments.push_back(port_id_handle); 290 arguments.push_back(port_id_handle);
291 CHECK((*it)->CallChromeHiddenMethod("Port.dispatchOnMessage", 291 CHECK((*it)->CallChromeHiddenMethod("Port.dispatchOnMessage",
292 arguments.size(), 292 arguments.size(),
293 &arguments[0], 293 &arguments[0],
294 NULL)); 294 NULL));
295 } 295 }
296 } 296 }
297 297
298 } // namespace extension 298 } // namespace extension
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_helper.cc ('k') | chrome/renderer/extensions/schema_generated_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698