| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/runner/child/runner_connection.h" | 5 #include "mojo/runner/child/runner_connection.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 DCHECK(!connection->controller()); | 144 DCHECK(!connection->controller()); |
| 145 | 145 |
| 146 scoped_ptr<ChildControllerImpl> impl( | 146 scoped_ptr<ChildControllerImpl> impl( |
| 147 new ChildControllerImpl(connection, callback, unblocker)); | 147 new ChildControllerImpl(connection, callback, unblocker)); |
| 148 | 148 |
| 149 impl->Bind(runner_handle.Pass()); | 149 impl->Bind(runner_handle.Pass()); |
| 150 | 150 |
| 151 connection->set_controller(impl.Pass()); | 151 connection->set_controller(impl.Pass()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void Bind(ScopedMessagePipeHandle handle) { binding_.Bind(handle.Pass()); } | 154 void Bind(ScopedMessagePipeHandle handle) { |
| 155 binding_.Bind(handle.Pass()); |
| 156 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); |
| 157 } |
| 155 | 158 |
| 156 void OnConnectionError() { | 159 void OnConnectionError() { |
| 157 // A connection error means the connection to the shell is lost. This is not | 160 // A connection error means the connection to the shell is lost. This is not |
| 158 // recoverable. | 161 // recoverable. |
| 159 LOG(ERROR) << "Connection error to the shell."; | 162 LOG(ERROR) << "Connection error to the shell."; |
| 160 _exit(1); | 163 _exit(1); |
| 161 } | 164 } |
| 162 | 165 |
| 163 // |ChildController| methods: | 166 // |ChildController| methods: |
| 164 void StartApp(InterfaceRequest<Application> application_request, | 167 void StartApp(InterfaceRequest<Application> application_request, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 177 } | 180 } |
| 178 | 181 |
| 179 private: | 182 private: |
| 180 ChildControllerImpl(RunnerConnectionImpl* connection, | 183 ChildControllerImpl(RunnerConnectionImpl* connection, |
| 181 const GotApplicationRequestCallback& callback, | 184 const GotApplicationRequestCallback& callback, |
| 182 const Blocker::Unblocker& unblocker) | 185 const Blocker::Unblocker& unblocker) |
| 183 : connection_(connection), | 186 : connection_(connection), |
| 184 callback_(callback), | 187 callback_(callback), |
| 185 unblocker_(unblocker), | 188 unblocker_(unblocker), |
| 186 channel_info_(nullptr), | 189 channel_info_(nullptr), |
| 187 binding_(this) { | 190 binding_(this) {} |
| 188 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); | |
| 189 } | |
| 190 | 191 |
| 191 static void ReturnApplicationRequestOnMainThread( | 192 static void ReturnApplicationRequestOnMainThread( |
| 192 const GotApplicationRequestCallback& callback, | 193 const GotApplicationRequestCallback& callback, |
| 193 InterfaceRequest<Application> application_request) { | 194 InterfaceRequest<Application> application_request) { |
| 194 callback.Run(application_request.Pass()); | 195 callback.Run(application_request.Pass()); |
| 195 } | 196 } |
| 196 | 197 |
| 197 base::ThreadChecker thread_checker_; | 198 base::ThreadChecker thread_checker_; |
| 198 RunnerConnectionImpl* const connection_; | 199 RunnerConnectionImpl* const connection_; |
| 199 GotApplicationRequestCallback callback_; | 200 GotApplicationRequestCallback callback_; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 delete connection; | 279 delete connection; |
| 279 return nullptr; | 280 return nullptr; |
| 280 } | 281 } |
| 281 return connection; | 282 return connection; |
| 282 } | 283 } |
| 283 | 284 |
| 284 RunnerConnection::RunnerConnection() {} | 285 RunnerConnection::RunnerConnection() {} |
| 285 | 286 |
| 286 } // namespace runner | 287 } // namespace runner |
| 287 } // namespace mojo | 288 } // namespace mojo |
| OLD | NEW |