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_readers.h" | 5 #include "ipc/mojo/ipc_channel_mojo_readers.h" |
6 | 6 |
7 #include "ipc/mojo/ipc_channel_mojo.h" | 7 #include "ipc/mojo/ipc_channel_mojo.h" |
8 #include "mojo/embedder/embedder.h" | 8 #include "mojo/embedder/embedder.h" |
9 | 9 |
10 #if defined(OS_POSIX) && !defined(OS_NACL) | 10 #if defined(OS_POSIX) && !defined(OS_NACL) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 #if defined(OS_POSIX) && !defined(OS_NACL) | 139 #if defined(OS_POSIX) && !defined(OS_NACL) |
140 MojoResult read_result = | 140 MojoResult read_result = |
141 ChannelMojo::ReadFromFileDescriptorSet(*message, &handles); | 141 ChannelMojo::ReadFromFileDescriptorSet(*message, &handles); |
142 if (read_result != MOJO_RESULT_OK) { | 142 if (read_result != MOJO_RESULT_OK) { |
143 std::for_each(handles.begin(), handles.end(), &MojoClose); | 143 std::for_each(handles.begin(), handles.end(), &MojoClose); |
144 CloseWithError(read_result); | 144 CloseWithError(read_result); |
145 return false; | 145 return false; |
146 } | 146 } |
147 #endif | 147 #endif |
148 MojoResult write_result = | 148 MojoResult write_result = |
149 MojoWriteMessage(handle(), | 149 WriteMessageToPipe(message->data(), |
150 message->data(), | 150 static_cast<uint32>(message->size()), |
151 static_cast<uint32>(message->size()), | 151 handles.empty() ? NULL : &handles[0], |
152 handles.empty() ? NULL : &handles[0], | 152 static_cast<uint32>(handles.size()), |
153 static_cast<uint32>(handles.size()), | 153 MOJO_WRITE_MESSAGE_FLAG_NONE); |
154 MOJO_WRITE_MESSAGE_FLAG_NONE); | |
155 if (MOJO_RESULT_OK != write_result) { | 154 if (MOJO_RESULT_OK != write_result) { |
156 std::for_each(handles.begin(), handles.end(), &MojoClose); | 155 std::for_each(handles.begin(), handles.end(), &MojoClose); |
157 CloseWithError(write_result); | 156 CloseWithError(write_result); |
158 return false; | 157 return false; |
159 } | 158 } |
160 | 159 |
161 return true; | 160 return true; |
162 } | 161 } |
163 | 162 |
| 163 MojoResult MessageReader::WriteMessageToPipe( |
| 164 const void* bytes, |
| 165 uint32_t num_bytes, |
| 166 const MojoHandle* handles, |
| 167 uint32_t num_handles, |
| 168 MojoWriteMessageFlags flags) { |
| 169 return MojoWriteMessage(handle(), |
| 170 bytes, num_bytes, |
| 171 handles, num_handles, |
| 172 flags); |
| 173 } |
| 174 |
164 //------------------------------------------------------------------------------ | 175 //------------------------------------------------------------------------------ |
165 | 176 |
166 ControlReader::ControlReader(mojo::ScopedMessagePipeHandle pipe, | 177 ControlReader::ControlReader(mojo::ScopedMessagePipeHandle pipe, |
167 ChannelMojo* owner) | 178 ChannelMojo* owner) |
168 : internal::MessagePipeReader(pipe.Pass()), owner_(owner) { | 179 : internal::MessagePipeReader(pipe.Pass()), owner_(owner) { |
169 } | 180 } |
170 | 181 |
171 void ControlReader::OnPipeClosed() { | 182 void ControlReader::OnPipeClosed() { |
172 if (!owner_) | 183 if (!owner_) |
173 return; | 184 return; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 323 |
313 MojoResult result = RespondHelloRequest(handle_buffer[0]); | 324 MojoResult result = RespondHelloRequest(handle_buffer[0]); |
314 if (result != MOJO_RESULT_OK) { | 325 if (result != MOJO_RESULT_OK) { |
315 DLOG(ERROR) << "Failed to respond Hello request. Closing: " << result; | 326 DLOG(ERROR) << "Failed to respond Hello request. Closing: " << result; |
316 CloseWithError(result); | 327 CloseWithError(result); |
317 } | 328 } |
318 } | 329 } |
319 | 330 |
320 } // namespace internal | 331 } // namespace internal |
321 } // namespace IPC | 332 } // namespace IPC |
OLD | NEW |