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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 | 207 |
208 scoped_ptr<MessageChannel> channel(new MessageChannel()); | 208 scoped_ptr<MessageChannel> channel(new MessageChannel()); |
209 channel->opener.reset(new ExtensionMessagePort(source, MSG_ROUTING_CONTROL, | 209 channel->opener.reset(new ExtensionMessagePort(source, MSG_ROUTING_CONTROL, |
210 source_extension_id)); | 210 source_extension_id)); |
211 | 211 |
212 scoped_ptr<NativeMessageProcessHost> native_process = | 212 scoped_ptr<NativeMessageProcessHost> native_process = |
213 NativeMessageProcessHost::Create( | 213 NativeMessageProcessHost::Create( |
214 base::WeakPtr<NativeMessageProcessHost::Client>( | 214 base::WeakPtr<NativeMessageProcessHost::Client>( |
215 weak_factory_.GetWeakPtr()), | 215 weak_factory_.GetWeakPtr()), |
216 source_extension_id, native_app_name, receiver_port_id); | 216 native_app_name, receiver_port_id); |
217 | 217 |
218 // Abandon the channel | 218 // Abandon the channel |
219 if (!native_process.get()) { | 219 if (!native_process.get()) { |
220 LOG(ERROR) << "Failed to create native process."; | 220 LOG(ERROR) << "Failed to create native process."; |
221 // Treat it as a disconnect. | 221 // Treat it as a disconnect. |
222 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); | 222 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); |
223 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(receiver_port_id), true); | 223 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(receiver_port_id), true); |
224 return; | 224 return; |
225 } | 225 } |
226 channel->receiver.reset(new NativeMessagePort(native_process.release())); | 226 channel->receiver.reset(new NativeMessagePort(native_process.release())); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 return; | 483 return; |
484 | 484 |
485 params->source = source; | 485 params->source = source; |
486 params->receiver.reset(new ExtensionMessagePort(host->render_process_host(), | 486 params->receiver.reset(new ExtensionMessagePort(host->render_process_host(), |
487 MSG_ROUTING_CONTROL, | 487 MSG_ROUTING_CONTROL, |
488 params->target_extension_id)); | 488 params->target_extension_id)); |
489 OpenChannelImpl(params.Pass()); | 489 OpenChannelImpl(params.Pass()); |
490 } | 490 } |
491 | 491 |
492 } // namespace extensions | 492 } // namespace extensions |
OLD | NEW |