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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "ipc/ipc_listener.h" | 10 #include "ipc/ipc_listener.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ServerChannelMojo::~ServerChannelMojo() { | 134 ServerChannelMojo::~ServerChannelMojo() { |
135 Close(); | 135 Close(); |
136 } | 136 } |
137 | 137 |
138 void ServerChannelMojo::OnPipeAvailable( | 138 void ServerChannelMojo::OnPipeAvailable( |
139 mojo::embedder::ScopedPlatformHandle handle) { | 139 mojo::embedder::ScopedPlatformHandle handle) { |
140 mojo::ScopedMessagePipeHandle peer; | 140 mojo::ScopedMessagePipeHandle peer; |
141 MojoResult create_result = | 141 MojoResult create_result = |
142 mojo::CreateMessagePipe(nullptr, &message_pipe_, &peer); | 142 mojo::CreateMessagePipe(nullptr, &message_pipe_, &peer); |
143 if (create_result != MOJO_RESULT_OK) { | 143 if (create_result != MOJO_RESULT_OK) { |
144 DLOG(WARNING) << "mojo::CreateMessagePipe failed: " << create_result; | 144 LOG(WARNING) << "mojo::CreateMessagePipe failed: " << create_result; |
145 listener()->OnChannelError(); | 145 listener()->OnChannelError(); |
146 return; | 146 return; |
147 } | 147 } |
148 | 148 |
149 client_channel_.Bind(CreateMessagingPipe(handle.Pass())); | 149 client_channel_.Bind(CreateMessagingPipe(handle.Pass())); |
150 client_channel_.set_error_handler(this); | 150 client_channel_.set_error_handler(this); |
151 client_channel_->Init( | 151 client_channel_->Init( |
152 peer.Pass(), | 152 peer.Pass(), |
153 static_cast<int32_t>(GetSelfPID()), | 153 static_cast<int32_t>(GetSelfPID()), |
154 base::Bind(&ServerChannelMojo::ClientChannelWasInitialized, | 154 base::Bind(&ServerChannelMojo::ClientChannelWasInitialized, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 set->CommitAll(); | 385 set->CommitAll(); |
386 return MOJO_RESULT_UNKNOWN; | 386 return MOJO_RESULT_UNKNOWN; |
387 } | 387 } |
388 | 388 |
389 MojoHandle wrapped_handle; | 389 MojoHandle wrapped_handle; |
390 MojoResult wrap_result = CreatePlatformHandleWrapper( | 390 MojoResult wrap_result = CreatePlatformHandleWrapper( |
391 mojo::embedder::ScopedPlatformHandle( | 391 mojo::embedder::ScopedPlatformHandle( |
392 mojo::embedder::PlatformHandle(file.release())), | 392 mojo::embedder::PlatformHandle(file.release())), |
393 &wrapped_handle); | 393 &wrapped_handle); |
394 if (MOJO_RESULT_OK != wrap_result) { | 394 if (MOJO_RESULT_OK != wrap_result) { |
395 DLOG(WARNING) << "Pipe failed to wrap handles. Closing: " | 395 LOG(WARNING) << "Pipe failed to wrap handles. Closing: " |
396 << wrap_result; | 396 << wrap_result; |
397 set->CommitAll(); | 397 set->CommitAll(); |
398 return wrap_result; | 398 return wrap_result; |
399 } | 399 } |
400 | 400 |
401 handles->push_back(wrapped_handle); | 401 handles->push_back(wrapped_handle); |
402 } | 402 } |
403 #else | 403 #else |
404 NOTREACHED(); | 404 NOTREACHED(); |
405 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 405 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
406 break; | 406 break; |
(...skipping 15 matching lines...) Expand all Loading... |
422 // static | 422 // static |
423 MojoResult ChannelMojo::WriteToMessageAttachmentSet( | 423 MojoResult ChannelMojo::WriteToMessageAttachmentSet( |
424 const std::vector<MojoHandle>& handle_buffer, | 424 const std::vector<MojoHandle>& handle_buffer, |
425 Message* message) { | 425 Message* message) { |
426 for (size_t i = 0; i < handle_buffer.size(); ++i) { | 426 for (size_t i = 0; i < handle_buffer.size(); ++i) { |
427 bool ok = message->attachment_set()->AddAttachment( | 427 bool ok = message->attachment_set()->AddAttachment( |
428 new IPC::internal::MojoHandleAttachment( | 428 new IPC::internal::MojoHandleAttachment( |
429 mojo::MakeScopedHandle(mojo::Handle(handle_buffer[i])))); | 429 mojo::MakeScopedHandle(mojo::Handle(handle_buffer[i])))); |
430 DCHECK(ok); | 430 DCHECK(ok); |
431 if (!ok) { | 431 if (!ok) { |
432 DLOG(ERROR) << "Failed to add new Mojo handle."; | 432 LOG(ERROR) << "Failed to add new Mojo handle."; |
433 return MOJO_RESULT_UNKNOWN; | 433 return MOJO_RESULT_UNKNOWN; |
434 } | 434 } |
435 } | 435 } |
436 | 436 |
437 return MOJO_RESULT_OK; | 437 return MOJO_RESULT_OK; |
438 } | 438 } |
439 | 439 |
440 } // namespace IPC | 440 } // namespace IPC |
OLD | NEW |