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

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

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: thakis comment, renamed LAZY_INSTANCE_INITIALIZER 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/renderer_extension_bindings.h" 5 #include "chrome/renderer/extensions/renderer_extension_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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 std::vector<v8::Handle<v8::Value> > arguments; 286 std::vector<v8::Handle<v8::Value> > arguments;
287 arguments.push_back(v8::String::New(message.c_str(), message.size())); 287 arguments.push_back(v8::String::New(message.c_str(), message.size()));
288 arguments.push_back(port_id_handle); 288 arguments.push_back(port_id_handle);
289 CHECK((*it)->CallChromeHiddenMethod("Port.dispatchOnMessage", 289 CHECK((*it)->CallChromeHiddenMethod("Port.dispatchOnMessage",
290 arguments.size(), 290 arguments.size(),
291 &arguments[0], 291 &arguments[0],
292 NULL)); 292 NULL));
293 } 293 }
294 } 294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698