| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/extensions/api/messaging/message_service.h" | 5 #include "chrome/browser/extensions/api/messaging/message_service.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 DispatchOnDisconnect(source, receiver_port_id, kMissingPermissionError); | 316 DispatchOnDisconnect(source, receiver_port_id, kMissingPermissionError); |
| 317 return; | 317 return; |
| 318 } | 318 } |
| 319 | 319 |
| 320 scoped_ptr<MessageChannel> channel(new MessageChannel()); | 320 scoped_ptr<MessageChannel> channel(new MessageChannel()); |
| 321 channel->opener.reset(new ExtensionMessagePort(source, MSG_ROUTING_CONTROL, | 321 channel->opener.reset(new ExtensionMessagePort(source, MSG_ROUTING_CONTROL, |
| 322 source_extension_id)); | 322 source_extension_id)); |
| 323 | 323 |
| 324 scoped_ptr<NativeMessageProcessHost> native_process = | 324 scoped_ptr<NativeMessageProcessHost> native_process = |
| 325 NativeMessageProcessHost::Create( | 325 NativeMessageProcessHost::Create( |
| 326 source_process_id, source_routing_id, |
| 326 base::WeakPtr<NativeMessageProcessHost::Client>( | 327 base::WeakPtr<NativeMessageProcessHost::Client>( |
| 327 weak_factory_.GetWeakPtr()), | 328 weak_factory_.GetWeakPtr()), |
| 328 source_extension_id, native_app_name, receiver_port_id); | 329 source_extension_id, native_app_name, receiver_port_id); |
| 329 | 330 |
| 330 // Abandon the channel. | 331 // Abandon the channel. |
| 331 if (!native_process.get()) { | 332 if (!native_process.get()) { |
| 332 LOG(ERROR) << "Failed to create native process."; | 333 LOG(ERROR) << "Failed to create native process."; |
| 333 DispatchOnDisconnect( | 334 DispatchOnDisconnect( |
| 334 source, receiver_port_id, kReceivingEndDoesntExistError); | 335 source, receiver_port_id, kReceivingEndDoesntExistError); |
| 335 return; | 336 return; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 } | 596 } |
| 596 | 597 |
| 597 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, | 598 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, |
| 598 int port_id, | 599 int port_id, |
| 599 const std::string& error_message) { | 600 const std::string& error_message) { |
| 600 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); | 601 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); |
| 601 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); | 602 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); |
| 602 } | 603 } |
| 603 | 604 |
| 604 } // namespace extensions | 605 } // namespace extensions |
| OLD | NEW |