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