| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Is the client launched? | 77 // Is the client launched? |
| 78 if (client_process_ == base::kNullProcessHandle) | 78 if (client_process_ == base::kNullProcessHandle) |
| 79 return; | 79 return; |
| 80 // Has the bootstrap channel been made? | 80 // Has the bootstrap channel been made? |
| 81 if (!connected_) | 81 if (!connected_) |
| 82 return; | 82 return; |
| 83 SendClientPipe(); | 83 SendClientPipe(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void MojoServerBootstrap::OnClientLaunched(base::ProcessHandle process) { | 86 void MojoServerBootstrap::OnClientLaunched(base::ProcessHandle process) { |
| 87 if (HasFailed()) |
| 88 return; |
| 89 |
| 87 DCHECK_EQ(state(), STATE_INITIALIZED); | 90 DCHECK_EQ(state(), STATE_INITIALIZED); |
| 88 DCHECK_NE(process, base::kNullProcessHandle); | 91 DCHECK_NE(process, base::kNullProcessHandle); |
| 89 client_process_ = process; | 92 client_process_ = process; |
| 90 SendClientPipeIfReady(); | 93 SendClientPipeIfReady(); |
| 91 } | 94 } |
| 92 | 95 |
| 93 void MojoServerBootstrap::OnChannelConnected(int32 peer_pid) { | 96 void MojoServerBootstrap::OnChannelConnected(int32 peer_pid) { |
| 94 DCHECK_EQ(state(), STATE_INITIALIZED); | 97 DCHECK_EQ(state(), STATE_INITIALIZED); |
| 95 connected_ = true; | 98 connected_ = true; |
| 96 SendClientPipeIfReady(); | 99 SendClientPipeIfReady(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return; | 198 return; |
| 196 DLOG(WARNING) << "Detected error on Mojo bootstrap channel."; | 199 DLOG(WARNING) << "Detected error on Mojo bootstrap channel."; |
| 197 Fail(); | 200 Fail(); |
| 198 } | 201 } |
| 199 | 202 |
| 200 void MojoBootstrap::Fail() { | 203 void MojoBootstrap::Fail() { |
| 201 set_state(STATE_ERROR); | 204 set_state(STATE_ERROR); |
| 202 delegate()->OnBootstrapError(); | 205 delegate()->OnBootstrapError(); |
| 203 } | 206 } |
| 204 | 207 |
| 208 bool MojoBootstrap::HasFailed() const { |
| 209 return state() == STATE_ERROR; |
| 210 } |
| 211 |
| 205 bool MojoBootstrap::Send(Message* message) { | 212 bool MojoBootstrap::Send(Message* message) { |
| 206 return channel_->Send(message); | 213 return channel_->Send(message); |
| 207 } | 214 } |
| 208 | 215 |
| 209 #if defined(OS_POSIX) && !defined(OS_NACL) | 216 #if defined(OS_POSIX) && !defined(OS_NACL) |
| 210 int MojoBootstrap::GetClientFileDescriptor() const { | 217 int MojoBootstrap::GetClientFileDescriptor() const { |
| 211 return channel_->GetClientFileDescriptor(); | 218 return channel_->GetClientFileDescriptor(); |
| 212 } | 219 } |
| 213 | 220 |
| 214 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { | 221 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { |
| 215 return channel_->TakeClientFileDescriptor(); | 222 return channel_->TakeClientFileDescriptor(); |
| 216 } | 223 } |
| 217 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 224 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 218 | 225 |
| 219 } // namespace IPC | 226 } // namespace IPC |
| OLD | NEW |