| 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 "ipc/mojo/ipc_channel_mojo.h" | 5 #include "ipc/mojo/ipc_channel_mojo.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <memory> | 10 #include <memory> |
| 8 | 11 |
| 9 #include "base/bind.h" | 12 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 12 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/macros.h" |
| 13 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 18 #include "build/build_config.h" |
| 14 #include "ipc/ipc_listener.h" | 19 #include "ipc/ipc_listener.h" |
| 15 #include "ipc/ipc_logging.h" | 20 #include "ipc/ipc_logging.h" |
| 16 #include "ipc/ipc_message_attachment_set.h" | 21 #include "ipc/ipc_message_attachment_set.h" |
| 17 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
| 18 #include "ipc/mojo/client_channel.mojom.h" | 23 #include "ipc/mojo/client_channel.mojom.h" |
| 19 #include "ipc/mojo/ipc_mojo_bootstrap.h" | 24 #include "ipc/mojo/ipc_mojo_bootstrap.h" |
| 20 #include "ipc/mojo/ipc_mojo_handle_attachment.h" | 25 #include "ipc/mojo/ipc_mojo_handle_attachment.h" |
| 21 #include "mojo/public/cpp/bindings/binding.h" | 26 #include "mojo/public/cpp/bindings/binding.h" |
| 22 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 27 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 23 | 28 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const ChannelHandle& handle, | 67 const ChannelHandle& handle, |
| 63 Listener* listener) | 68 Listener* listener) |
| 64 : ChannelMojo(io_runner, handle, Channel::MODE_CLIENT, listener), | 69 : ChannelMojo(io_runner, handle, Channel::MODE_CLIENT, listener), |
| 65 binding_(this), | 70 binding_(this), |
| 66 weak_factory_(this) { | 71 weak_factory_(this) { |
| 67 } | 72 } |
| 68 ~ClientChannelMojo() override {} | 73 ~ClientChannelMojo() override {} |
| 69 | 74 |
| 70 // MojoBootstrap::Delegate implementation | 75 // MojoBootstrap::Delegate implementation |
| 71 void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle, | 76 void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle, |
| 72 int32 peer_pid) override { | 77 int32_t peer_pid) override { |
| 73 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { | 78 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { |
| 74 InitMessageReader(mojo::embedder::CreateChannel( | 79 InitMessageReader(mojo::embedder::CreateChannel( |
| 75 handle.Pass(), base::Callback<void(mojo::embedder::ChannelInfo*)>(), | 80 handle.Pass(), base::Callback<void(mojo::embedder::ChannelInfo*)>(), |
| 76 scoped_refptr<base::TaskRunner>()), peer_pid); | 81 scoped_refptr<base::TaskRunner>()), peer_pid); |
| 77 return; | 82 return; |
| 78 } | 83 } |
| 79 CreateMessagingPipe(handle.Pass(), base::Bind(&ClientChannelMojo::BindPipe, | 84 CreateMessagingPipe(handle.Pass(), base::Bind(&ClientChannelMojo::BindPipe, |
| 80 weak_factory_.GetWeakPtr())); | 85 weak_factory_.GetWeakPtr())); |
| 81 } | 86 } |
| 82 | 87 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 112 Listener* listener) | 117 Listener* listener) |
| 113 : ChannelMojo(io_runner, handle, Channel::MODE_SERVER, listener), | 118 : ChannelMojo(io_runner, handle, Channel::MODE_SERVER, listener), |
| 114 weak_factory_(this) { | 119 weak_factory_(this) { |
| 115 } | 120 } |
| 116 ~ServerChannelMojo() override { | 121 ~ServerChannelMojo() override { |
| 117 Close(); | 122 Close(); |
| 118 } | 123 } |
| 119 | 124 |
| 120 // MojoBootstrap::Delegate implementation | 125 // MojoBootstrap::Delegate implementation |
| 121 void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle, | 126 void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle, |
| 122 int32 peer_pid) override { | 127 int32_t peer_pid) override { |
| 123 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { | 128 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { |
| 124 message_pipe_ = mojo::embedder::CreateChannel( | 129 message_pipe_ = mojo::embedder::CreateChannel( |
| 125 handle.Pass(), base::Callback<void(mojo::embedder::ChannelInfo*)>(), | 130 handle.Pass(), base::Callback<void(mojo::embedder::ChannelInfo*)>(), |
| 126 scoped_refptr<base::TaskRunner>()); | 131 scoped_refptr<base::TaskRunner>()); |
| 127 if (!message_pipe_.is_valid()) { | 132 if (!message_pipe_.is_valid()) { |
| 128 LOG(WARNING) << "mojo::CreateMessagePipe failed: "; | 133 LOG(WARNING) << "mojo::CreateMessagePipe failed: "; |
| 129 listener()->OnChannelError(); | 134 listener()->OnChannelError(); |
| 130 return; | 135 return; |
| 131 } | 136 } |
| 132 InitMessageReader(message_pipe_.Pass(), peer_pid); | 137 InitMessageReader(message_pipe_.Pass(), peer_pid); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 if (!ok) { | 538 if (!ok) { |
| 534 LOG(ERROR) << "Failed to add new Mojo handle."; | 539 LOG(ERROR) << "Failed to add new Mojo handle."; |
| 535 return MOJO_RESULT_UNKNOWN; | 540 return MOJO_RESULT_UNKNOWN; |
| 536 } | 541 } |
| 537 } | 542 } |
| 538 | 543 |
| 539 return MOJO_RESULT_OK; | 544 return MOJO_RESULT_OK; |
| 540 } | 545 } |
| 541 | 546 |
| 542 } // namespace IPC | 547 } // namespace IPC |
| OLD | NEW |