| 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_mojo_bootstrap.h" | 5 #include "ipc/mojo/ipc_mojo_bootstrap.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/process/process_handle.h" | 8 #include "base/process/process_handle.h" |
| 9 #include "ipc/ipc_message_utils.h" | 9 #include "ipc/ipc_message_utils.h" |
| 10 #include "ipc/ipc_platform_file.h" | 10 #include "ipc/ipc_platform_file.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #else | 54 #else |
| 55 channel_pair.PassClientHandle().release().handle, | 55 channel_pair.PassClientHandle().release().handle, |
| 56 #endif | 56 #endif |
| 57 client_process_, | 57 client_process_, |
| 58 true); | 58 true); |
| 59 if (client_pipe == IPC::InvalidPlatformFileForTransit()) { | 59 if (client_pipe == IPC::InvalidPlatformFileForTransit()) { |
| 60 #if !defined(OS_WIN) | 60 #if !defined(OS_WIN) |
| 61 // GetFileHandleForProcess() only fails on Windows. | 61 // GetFileHandleForProcess() only fails on Windows. |
| 62 NOTREACHED(); | 62 NOTREACHED(); |
| 63 #endif | 63 #endif |
| 64 DLOG(WARNING) << "Failed to translate file handle for client process."; | 64 LOG(WARNING) << "Failed to translate file handle for client process."; |
| 65 Fail(); | 65 Fail(); |
| 66 return; | 66 return; |
| 67 } | 67 } |
| 68 | 68 |
| 69 scoped_ptr<Message> message(new Message()); | 69 scoped_ptr<Message> message(new Message()); |
| 70 ParamTraits<PlatformFileForTransit>::Write(message.get(), client_pipe); | 70 ParamTraits<PlatformFileForTransit>::Write(message.get(), client_pipe); |
| 71 Send(message.release()); | 71 Send(message.release()); |
| 72 | 72 |
| 73 set_state(STATE_WAITING_ACK); | 73 set_state(STATE_WAITING_ACK); |
| 74 } | 74 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 bool MojoClientBootstrap::OnMessageReceived(const Message& message) { | 136 bool MojoClientBootstrap::OnMessageReceived(const Message& message) { |
| 137 if (state() != STATE_INITIALIZED) { | 137 if (state() != STATE_INITIALIZED) { |
| 138 set_state(STATE_ERROR); | 138 set_state(STATE_ERROR); |
| 139 LOG(ERROR) << "Got inconsistent message from server."; | 139 LOG(ERROR) << "Got inconsistent message from server."; |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 PlatformFileForTransit pipe; | 143 PlatformFileForTransit pipe; |
| 144 PickleIterator iter(message); | 144 PickleIterator iter(message); |
| 145 if (!ParamTraits<PlatformFileForTransit>::Read(&message, &iter, &pipe)) { | 145 if (!ParamTraits<PlatformFileForTransit>::Read(&message, &iter, &pipe)) { |
| 146 DLOG(WARNING) << "Failed to read a file handle from bootstrap channel."; | 146 LOG(WARNING) << "Failed to read a file handle from bootstrap channel."; |
| 147 message.set_dispatch_error(); | 147 message.set_dispatch_error(); |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Sends ACK back. | 151 // Sends ACK back. |
| 152 Send(new Message()); | 152 Send(new Message()); |
| 153 set_state(STATE_READY); | 153 set_state(STATE_READY); |
| 154 delegate()->OnPipeAvailable( | 154 delegate()->OnPipeAvailable( |
| 155 mojo::embedder::ScopedPlatformHandle(mojo::embedder::PlatformHandle( | 155 mojo::embedder::ScopedPlatformHandle(mojo::embedder::PlatformHandle( |
| 156 PlatformFileForTransitToPlatformFile(pipe)))); | 156 PlatformFileForTransitToPlatformFile(pipe)))); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 int MojoBootstrap::GetClientFileDescriptor() const { | 232 int MojoBootstrap::GetClientFileDescriptor() const { |
| 233 return channel_->GetClientFileDescriptor(); | 233 return channel_->GetClientFileDescriptor(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { | 236 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { |
| 237 return channel_->TakeClientFileDescriptor(); | 237 return channel_->TakeClientFileDescriptor(); |
| 238 } | 238 } |
| 239 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 239 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 240 | 240 |
| 241 } // namespace IPC | 241 } // namespace IPC |
| OLD | NEW |