| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "mojo/edk/system/node_controller.h" | 5 #include "mojo/edk/system/node_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 void NodeController::ConnectToParent(ScopedPlatformHandle platform_handle) { | 195 void NodeController::ConnectToParent(ScopedPlatformHandle platform_handle) { |
| 196 // TODO(amistry): Consider the need for a broker on Windows. | 196 // TODO(amistry): Consider the need for a broker on Windows. |
| 197 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_NACL) | 197 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_NACL) |
| 198 // On posix, use the bootstrap channel for the broker and receive the node's | 198 // On posix, use the bootstrap channel for the broker and receive the node's |
| 199 // channel synchronously as the first message from the broker. | 199 // channel synchronously as the first message from the broker. |
| 200 base::ElapsedTimer timer; | 200 base::ElapsedTimer timer; |
| 201 broker_.reset(new Broker(std::move(platform_handle))); | 201 broker_.reset(new Broker(std::move(platform_handle))); |
| 202 platform_handle = broker_->GetParentPlatformHandle(); | 202 platform_handle = broker_->GetParentPlatformHandle(); |
| 203 UMA_HISTOGRAM_TIMES("Mojo.System.GetParentPlatformHandleSyncTime", | 203 UMA_HISTOGRAM_TIMES("Mojo.System.GetParentPlatformHandleSyncTime", |
| 204 timer.Elapsed()); | 204 timer.Elapsed()); |
| 205 |
| 206 if (!platform_handle.is_valid()) { |
| 207 // Most likely the browser side of the channel has already been closed and |
| 208 // the broker was unable to negotiate a NodeChannel pipe. In this case we |
| 209 // can cancel parent connection. |
| 210 DVLOG(1) << "Cannot connect to invalid parent channel."; |
| 211 return; |
| 212 } |
| 205 #endif | 213 #endif |
| 206 | 214 |
| 207 io_task_runner_->PostTask( | 215 io_task_runner_->PostTask( |
| 208 FROM_HERE, | 216 FROM_HERE, |
| 209 base::Bind(&NodeController::ConnectToParentOnIOThread, | 217 base::Bind(&NodeController::ConnectToParentOnIOThread, |
| 210 base::Unretained(this), | 218 base::Unretained(this), |
| 211 base::Passed(&platform_handle))); | 219 base::Passed(&platform_handle))); |
| 212 } | 220 } |
| 213 | 221 |
| 214 void NodeController::SetPortObserver( | 222 void NodeController::SetPortObserver( |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 shutdown_callback_flag_.Set(false); | 1136 shutdown_callback_flag_.Set(false); |
| 1129 } | 1137 } |
| 1130 | 1138 |
| 1131 DCHECK(!callback.is_null()); | 1139 DCHECK(!callback.is_null()); |
| 1132 | 1140 |
| 1133 callback.Run(); | 1141 callback.Run(); |
| 1134 } | 1142 } |
| 1135 | 1143 |
| 1136 } // namespace edk | 1144 } // namespace edk |
| 1137 } // namespace mojo | 1145 } // namespace mojo |
| OLD | NEW |