| 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/ipc_message_pipe_reader.h" | 5 #include "ipc/ipc_message_pipe_reader.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 void MessagePipeReader::GetRemoteInterface( | 77 void MessagePipeReader::GetRemoteInterface( |
| 78 const std::string& name, | 78 const std::string& name, |
| 79 mojo::ScopedInterfaceEndpointHandle handle) { | 79 mojo::ScopedInterfaceEndpointHandle handle) { |
| 80 if (!sender_.is_bound()) | 80 if (!sender_.is_bound()) |
| 81 return; | 81 return; |
| 82 mojom::GenericInterfaceAssociatedRequest request; | 82 mojom::GenericInterfaceAssociatedRequest request; |
| 83 request.Bind(std::move(handle)); | 83 request.Bind(std::move(handle)); |
| 84 sender_->GetAssociatedInterface(name, std::move(request)); | 84 sender_->GetAssociatedInterface(name, std::move(request)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void MessagePipeReader::SendEventToSignal(mojo::common::mojom::EventPtr event) { |
| 88 if (!sender_.is_bound()) |
| 89 return; |
| 90 sender_->SignalEvent(std::move(event)); |
| 91 } |
| 92 |
| 87 void MessagePipeReader::SetPeerPid(int32_t peer_pid) { | 93 void MessagePipeReader::SetPeerPid(int32_t peer_pid) { |
| 88 peer_pid_ = peer_pid; | 94 peer_pid_ = peer_pid; |
| 89 delegate_->OnPeerPidReceived(); | 95 delegate_->OnPeerPidReceived(); |
| 90 } | 96 } |
| 91 | 97 |
| 92 void MessagePipeReader::Receive( | 98 void MessagePipeReader::Receive( |
| 93 const std::vector<uint8_t>& data, | 99 const std::vector<uint8_t>& data, |
| 94 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) { | 100 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) { |
| 95 DCHECK_NE(peer_pid_, base::kNullProcessId); | 101 DCHECK_NE(peer_pid_, base::kNullProcessId); |
| 96 Message message( | 102 Message message( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 114 } | 120 } |
| 115 | 121 |
| 116 void MessagePipeReader::GetAssociatedInterface( | 122 void MessagePipeReader::GetAssociatedInterface( |
| 117 const std::string& name, | 123 const std::string& name, |
| 118 mojom::GenericInterfaceAssociatedRequest request) { | 124 mojom::GenericInterfaceAssociatedRequest request) { |
| 119 DCHECK(thread_checker_.CalledOnValidThread()); | 125 DCHECK(thread_checker_.CalledOnValidThread()); |
| 120 if (delegate_) | 126 if (delegate_) |
| 121 delegate_->OnAssociatedInterfaceRequest(name, request.PassHandle()); | 127 delegate_->OnAssociatedInterfaceRequest(name, request.PassHandle()); |
| 122 } | 128 } |
| 123 | 129 |
| 130 void MessagePipeReader::SignalEvent(mojo::common::mojom::EventPtr event) { |
| 131 event->Signal(); |
| 132 } |
| 133 |
| 124 void MessagePipeReader::OnPipeError(MojoResult error) { | 134 void MessagePipeReader::OnPipeError(MojoResult error) { |
| 125 DCHECK(thread_checker_.CalledOnValidThread()); | 135 DCHECK(thread_checker_.CalledOnValidThread()); |
| 126 | 136 |
| 127 Close(); | 137 Close(); |
| 128 | 138 |
| 129 // NOTE: The delegate call below may delete |this|. | 139 // NOTE: The delegate call below may delete |this|. |
| 130 if (delegate_) | 140 if (delegate_) |
| 131 delegate_->OnPipeError(); | 141 delegate_->OnPipeError(); |
| 132 } | 142 } |
| 133 | 143 |
| 134 } // namespace internal | 144 } // namespace internal |
| 135 } // namespace IPC | 145 } // namespace IPC |
| OLD | NEW |