| 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/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 Loading... |
| 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 LINKER_ZERO_INITIALIZED; |
| 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 Loading... |
| 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 } |
| OLD | NEW |