| 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" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
| 17 #include "base/timer/elapsed_timer.h" |
| 17 #include "crypto/random.h" | 18 #include "crypto/random.h" |
| 18 #include "mojo/edk/embedder/embedder_internal.h" | 19 #include "mojo/edk/embedder/embedder_internal.h" |
| 19 #include "mojo/edk/embedder/platform_channel_pair.h" | 20 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 20 #include "mojo/edk/system/broker.h" | 21 #include "mojo/edk/system/broker.h" |
| 21 #include "mojo/edk/system/broker_host.h" | 22 #include "mojo/edk/system/broker_host.h" |
| 22 #include "mojo/edk/system/core.h" | 23 #include "mojo/edk/system/core.h" |
| 23 #include "mojo/edk/system/ports_message.h" | 24 #include "mojo/edk/system/ports_message.h" |
| 24 | 25 |
| 25 namespace mojo { | 26 namespace mojo { |
| 26 namespace edk { | 27 namespace edk { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 base::Unretained(this), | 124 base::Unretained(this), |
| 124 process_handle, | 125 process_handle, |
| 125 base::Passed(&platform_handle))); | 126 base::Passed(&platform_handle))); |
| 126 } | 127 } |
| 127 | 128 |
| 128 void NodeController::ConnectToParent(ScopedPlatformHandle platform_handle) { | 129 void NodeController::ConnectToParent(ScopedPlatformHandle platform_handle) { |
| 129 // TODO(amistry): Consider the need for a broker on Windows. | 130 // TODO(amistry): Consider the need for a broker on Windows. |
| 130 #if defined(OS_POSIX) | 131 #if defined(OS_POSIX) |
| 131 // On posix, use the bootstrap channel for the broker and receive the node's | 132 // On posix, use the bootstrap channel for the broker and receive the node's |
| 132 // channel synchronously as the first message from the broker. | 133 // channel synchronously as the first message from the broker. |
| 134 base::ElapsedTimer timer; |
| 133 broker_.reset(new Broker(std::move(platform_handle))); | 135 broker_.reset(new Broker(std::move(platform_handle))); |
| 134 platform_handle = broker_->GetParentPlatformHandle(); | 136 platform_handle = broker_->GetParentPlatformHandle(); |
| 137 UMA_HISTOGRAM_TIMES("Mojo.System.GetParentPlatformHandleSyncTime", |
| 138 timer.Elapsed()); |
| 135 #endif | 139 #endif |
| 136 | 140 |
| 137 io_task_runner_->PostTask( | 141 io_task_runner_->PostTask( |
| 138 FROM_HERE, | 142 FROM_HERE, |
| 139 base::Bind(&NodeController::ConnectToParentOnIOThread, | 143 base::Bind(&NodeController::ConnectToParentOnIOThread, |
| 140 base::Unretained(this), | 144 base::Unretained(this), |
| 141 base::Passed(&platform_handle))); | 145 base::Passed(&platform_handle))); |
| 142 } | 146 } |
| 143 | 147 |
| 144 void NodeController::SetPortObserver( | 148 void NodeController::SetPortObserver( |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 shutdown_callback_.Reset(); | 910 shutdown_callback_.Reset(); |
| 907 } | 911 } |
| 908 | 912 |
| 909 DCHECK(!callback.is_null()); | 913 DCHECK(!callback.is_null()); |
| 910 | 914 |
| 911 callback.Run(); | 915 callback.Run(); |
| 912 } | 916 } |
| 913 | 917 |
| 914 } // namespace edk | 918 } // namespace edk |
| 915 } // namespace mojo | 919 } // namespace mojo |
| OLD | NEW |