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

Side by Side Diff: ipc/ipc_message_pipe_reader.cc

Issue 2137353002: Adds associated interface support to IPC::Channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@channel-bindings-1
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 DCHECK_LE(num_handles, std::numeric_limits<uint32_t>::max()); 108 DCHECK_LE(num_handles, std::numeric_limits<uint32_t>::max());
109 109
110 mojo_message->set_interface_id(sender_interface_id_); 110 mojo_message->set_interface_id(sender_interface_id_);
111 result = mojo::WriteMessageNew(sender_pipe_, mojo_message->TakeMojoMessage(), 111 result = mojo::WriteMessageNew(sender_pipe_, mojo_message->TakeMojoMessage(),
112 MOJO_WRITE_MESSAGE_FLAG_NONE); 112 MOJO_WRITE_MESSAGE_FLAG_NONE);
113 113
114 DVLOG(4) << "Send " << message->type() << ": " << message->size(); 114 DVLOG(4) << "Send " << message->type() << ": " << message->size();
115 return result == MOJO_RESULT_OK; 115 return result == MOJO_RESULT_OK;
116 } 116 }
117 117
118 void MessagePipeReader::GetRemoteInterface(
119 const std::string& name,
120 mojo::ScopedInterfaceEndpointHandle handle) {
121 mojom::GenericInterfaceAssociatedRequest request;
122 request.Bind(std::move(handle));
123 sender_->GetAssociatedInterface(name, std::move(request));
124 }
125
118 void MessagePipeReader::Receive( 126 void MessagePipeReader::Receive(
119 mojo::Array<uint8_t> data, 127 mojo::Array<uint8_t> data,
120 mojo::Array<mojom::SerializedHandlePtr> handles) { 128 mojo::Array<mojom::SerializedHandlePtr> handles) {
121 Message message( 129 Message message(
122 data.size() == 0 ? "" : reinterpret_cast<const char*>(&data[0]), 130 data.size() == 0 ? "" : reinterpret_cast<const char*>(&data[0]),
123 static_cast<uint32_t>(data.size())); 131 static_cast<uint32_t>(data.size()));
124 message.set_sender_pid(peer_pid_); 132 message.set_sender_pid(peer_pid_);
125 133
126 DVLOG(4) << "Receive " << message.type() << ": " << message.size(); 134 DVLOG(4) << "Receive " << message.type() << ": " << message.size();
127 MojoResult write_result = 135 MojoResult write_result =
128 ChannelMojo::WriteToMessageAttachmentSet(std::move(handles), &message); 136 ChannelMojo::WriteToMessageAttachmentSet(std::move(handles), &message);
129 if (write_result != MOJO_RESULT_OK) { 137 if (write_result != MOJO_RESULT_OK) {
130 OnPipeError(write_result); 138 OnPipeError(write_result);
131 return; 139 return;
132 } 140 }
133 141
134 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"), 142 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"),
135 "MessagePipeReader::Receive", 143 "MessagePipeReader::Receive",
136 message.flags(), 144 message.flags(),
137 TRACE_EVENT_FLAG_FLOW_IN); 145 TRACE_EVENT_FLAG_FLOW_IN);
138 delegate_->OnMessageReceived(message); 146 delegate_->OnMessageReceived(message);
139 } 147 }
140 148
149 void MessagePipeReader::GetAssociatedInterface(
150 const mojo::String& name,
151 mojom::GenericInterfaceAssociatedRequest request) {
152 DCHECK(thread_checker_.CalledOnValidThread());
153 if (delegate_)
154 delegate_->OnAssociatedInterfaceRequest(name, request.PassHandle());
155 }
156
141 void MessagePipeReader::OnPipeError(MojoResult error) { 157 void MessagePipeReader::OnPipeError(MojoResult error) {
142 DCHECK(thread_checker_.CalledOnValidThread()); 158 DCHECK(thread_checker_.CalledOnValidThread());
143 if (delegate_) 159 if (delegate_)
144 delegate_->OnPipeError(); 160 delegate_->OnPipeError();
145 Close(); 161 Close();
146 } 162 }
147 163
148 void MessagePipeReader::DelayedDeleter::operator()( 164 void MessagePipeReader::DelayedDeleter::operator()(
149 MessagePipeReader* ptr) const { 165 MessagePipeReader* ptr) const {
150 ptr->Close(); 166 ptr->Close();
151 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 167 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
152 base::Bind(&DeleteNow, ptr)); 168 base::Bind(&DeleteNow, ptr));
153 } 169 }
154 170
155 } // namespace internal 171 } // namespace internal
156 } // 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