| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "ipc/ipc_channel.h" | 6 #include "ipc/ipc_channel.h" |
| 7 #include "ipc/ipc_channel_mojo.h" | 7 #include "ipc/ipc_channel_mojo.h" |
| 8 #include "mojo/public/cpp/system/message_pipe.h" |
| 8 | 9 |
| 9 namespace IPC { | 10 namespace IPC { |
| 10 | 11 |
| 11 // static | 12 // static |
| 12 std::unique_ptr<Channel> Channel::CreateClient( | 13 std::unique_ptr<Channel> Channel::CreateClient( |
| 13 const IPC::ChannelHandle& channel_handle, | 14 const IPC::ChannelHandle& channel_handle, |
| 14 Listener* listener) { | 15 Listener* listener) { |
| 15 if (channel_handle.mojo_handle.is_valid()) { | 16 if (channel_handle.mojo_handle.is_valid()) { |
| 16 return ChannelMojo::Create( | 17 return ChannelMojo::Create( |
| 17 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle), | 18 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 const IPC::ChannelHandle& channel_handle, | 50 const IPC::ChannelHandle& channel_handle, |
| 50 Listener* listener) { | 51 Listener* listener) { |
| 51 if (channel_handle.mojo_handle.is_valid()) { | 52 if (channel_handle.mojo_handle.is_valid()) { |
| 52 return ChannelMojo::Create( | 53 return ChannelMojo::Create( |
| 53 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle), | 54 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle), |
| 54 Channel::MODE_SERVER, listener); | 55 Channel::MODE_SERVER, listener); |
| 55 } | 56 } |
| 56 return Channel::Create(channel_handle, Channel::MODE_SERVER, listener); | 57 return Channel::Create(channel_handle, Channel::MODE_SERVER, listener); |
| 57 } | 58 } |
| 58 | 59 |
| 60 // static |
| 61 void Channel::GenerateMojoChannelHandlePair( |
| 62 const std::string& name_postfix, |
| 63 IPC::ChannelHandle* handle0, |
| 64 IPC::ChannelHandle* handle1) { |
| 65 DCHECK_NE(handle0, handle1); |
| 66 // |name| is only used for logging and to aid developers in debugging. It |
| 67 // doesn't _need_ to be unique, but this string is probably more useful than a |
| 68 // generic "ChannelMojo". |
| 69 #if !defined(OS_NACL_SFI) |
| 70 std::string name = "ChannelMojo-" + GenerateUniqueRandomChannelID(); |
| 71 #else |
| 72 std::string name = "ChannelMojo"; |
| 73 #endif |
| 74 if (!name_postfix.empty()) { |
| 75 name += "-" + name_postfix; |
| 76 } |
| 77 mojo::MessagePipe message_pipe; |
| 78 *handle0 = ChannelHandle(name); |
| 79 handle0->mojo_handle = message_pipe.handle0.release(); |
| 80 *handle1 = ChannelHandle(name); |
| 81 handle1->mojo_handle = message_pipe.handle1.release(); |
| 82 } |
| 83 |
| 59 Channel::~Channel() { | 84 Channel::~Channel() { |
| 60 } | 85 } |
| 61 | 86 |
| 62 bool Channel::IsSendThreadSafe() const { | 87 bool Channel::IsSendThreadSafe() const { |
| 63 return false; | 88 return false; |
| 64 } | 89 } |
| 65 | 90 |
| 66 void Channel::OnSetAttachmentBrokerEndpoint() { | 91 void Channel::OnSetAttachmentBrokerEndpoint() { |
| 67 CHECK(!did_start_connect_); | 92 CHECK(!did_start_connect_); |
| 68 } | 93 } |
| 69 | 94 |
| 70 void Channel::WillConnect() { | 95 void Channel::WillConnect() { |
| 71 did_start_connect_ = true; | 96 did_start_connect_ = true; |
| 72 } | 97 } |
| 73 | 98 |
| 74 } // namespace IPC | 99 } // namespace IPC |
| 75 | 100 |
| OLD | NEW |