Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: ipc/ipc_message_pipe_reader.cc

Issue 2167973002: Revert of Support early associated interface binding on ChannelMojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicit-channel-ipc-task-runner
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_message_pipe_reader.h ('k') | ipc/ipc_mojo_bootstrap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 DISALLOW_COPY_AND_ASSIGN(MessageSerializer); 49 DISALLOW_COPY_AND_ASSIGN(MessageSerializer);
50 }; 50 };
51 51
52 } // namespace 52 } // namespace
53 53
54 MessagePipeReader::MessagePipeReader( 54 MessagePipeReader::MessagePipeReader(
55 mojo::MessagePipeHandle pipe, 55 mojo::MessagePipeHandle pipe,
56 mojom::ChannelAssociatedPtr sender, 56 mojom::ChannelAssociatedPtr sender,
57 mojo::AssociatedInterfaceRequest<mojom::Channel> receiver, 57 mojo::AssociatedInterfaceRequest<mojom::Channel> receiver,
58 base::ProcessId peer_pid,
58 MessagePipeReader::Delegate* delegate) 59 MessagePipeReader::Delegate* delegate)
59 : delegate_(delegate), 60 : delegate_(delegate),
61 peer_pid_(peer_pid),
60 sender_(std::move(sender)), 62 sender_(std::move(sender)),
61 binding_(this, std::move(receiver)), 63 binding_(this, std::move(receiver)),
62 sender_interface_id_(sender_.interface_id()), 64 sender_interface_id_(sender_.interface_id()),
63 sender_pipe_(pipe) { 65 sender_pipe_(pipe) {
64 sender_.set_connection_error_handler( 66 sender_.set_connection_error_handler(
65 base::Bind(&MessagePipeReader::OnPipeError, base::Unretained(this), 67 base::Bind(&MessagePipeReader::OnPipeError, base::Unretained(this),
66 MOJO_RESULT_FAILED_PRECONDITION)); 68 MOJO_RESULT_FAILED_PRECONDITION));
67 binding_.set_connection_error_handler( 69 binding_.set_connection_error_handler(
68 base::Bind(&MessagePipeReader::OnPipeError, base::Unretained(this), 70 base::Bind(&MessagePipeReader::OnPipeError, base::Unretained(this),
69 MOJO_RESULT_FAILED_PRECONDITION)); 71 MOJO_RESULT_FAILED_PRECONDITION));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 116 }
115 117
116 void MessagePipeReader::GetRemoteInterface( 118 void MessagePipeReader::GetRemoteInterface(
117 const std::string& name, 119 const std::string& name,
118 mojo::ScopedInterfaceEndpointHandle handle) { 120 mojo::ScopedInterfaceEndpointHandle handle) {
119 mojom::GenericInterfaceAssociatedRequest request; 121 mojom::GenericInterfaceAssociatedRequest request;
120 request.Bind(std::move(handle)); 122 request.Bind(std::move(handle));
121 sender_->GetAssociatedInterface(name, std::move(request)); 123 sender_->GetAssociatedInterface(name, std::move(request));
122 } 124 }
123 125
124 void MessagePipeReader::SetPeerPid(int32_t peer_pid) {
125 peer_pid_ = peer_pid;
126 delegate_->OnPeerPidReceived();
127 }
128
129 void MessagePipeReader::Receive( 126 void MessagePipeReader::Receive(
130 mojo::Array<uint8_t> data, 127 mojo::Array<uint8_t> data,
131 mojo::Array<mojom::SerializedHandlePtr> handles) { 128 mojo::Array<mojom::SerializedHandlePtr> handles) {
132 DCHECK_NE(peer_pid_, base::kNullProcessId);
133 Message message( 129 Message message(
134 data.size() == 0 ? "" : reinterpret_cast<const char*>(&data[0]), 130 data.size() == 0 ? "" : reinterpret_cast<const char*>(&data[0]),
135 static_cast<uint32_t>(data.size())); 131 static_cast<uint32_t>(data.size()));
136 message.set_sender_pid(peer_pid_); 132 message.set_sender_pid(peer_pid_);
137 133
138 DVLOG(4) << "Receive " << message.type() << ": " << message.size(); 134 DVLOG(4) << "Receive " << message.type() << ": " << message.size();
139 MojoResult write_result = 135 MojoResult write_result =
140 ChannelMojo::WriteToMessageAttachmentSet(std::move(handles), &message); 136 ChannelMojo::WriteToMessageAttachmentSet(std::move(handles), &message);
141 if (write_result != MOJO_RESULT_OK) { 137 if (write_result != MOJO_RESULT_OK) {
142 OnPipeError(write_result); 138 OnPipeError(write_result);
(...skipping 10 matching lines...) Expand all
153 void MessagePipeReader::GetAssociatedInterface( 149 void MessagePipeReader::GetAssociatedInterface(
154 const mojo::String& name, 150 const mojo::String& name,
155 mojom::GenericInterfaceAssociatedRequest request) { 151 mojom::GenericInterfaceAssociatedRequest request) {
156 DCHECK(thread_checker_.CalledOnValidThread()); 152 DCHECK(thread_checker_.CalledOnValidThread());
157 if (delegate_) 153 if (delegate_)
158 delegate_->OnAssociatedInterfaceRequest(name, request.PassHandle()); 154 delegate_->OnAssociatedInterfaceRequest(name, request.PassHandle());
159 } 155 }
160 156
161 void MessagePipeReader::OnPipeError(MojoResult error) { 157 void MessagePipeReader::OnPipeError(MojoResult error) {
162 DCHECK(thread_checker_.CalledOnValidThread()); 158 DCHECK(thread_checker_.CalledOnValidThread());
163
164 Close();
165
166 // NOTE: The delegate call below may delete |this|.
167 if (delegate_) 159 if (delegate_)
168 delegate_->OnPipeError(); 160 delegate_->OnPipeError();
161 Close();
162 }
163
164 void MessagePipeReader::DelayedDeleter::operator()(
165 MessagePipeReader* ptr) const {
166 ptr->Close();
167 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
168 base::Bind(&DeleteNow, ptr));
169 } 169 }
170 170
171 } // namespace internal 171 } // namespace internal
172 } // namespace IPC 172 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_message_pipe_reader.h ('k') | ipc/ipc_mojo_bootstrap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698