| 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 "mojo/shell/app_child_process.h" | 5 #include "mojo/shell/app_child_process.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 base::Thread controller_thread_; | 150 base::Thread controller_thread_; |
| 151 scoped_refptr<base::SingleThreadTaskRunner> controller_runner_; | 151 scoped_refptr<base::SingleThreadTaskRunner> controller_runner_; |
| 152 | 152 |
| 153 DISALLOW_COPY_AND_ASSIGN(AppContext); | 153 DISALLOW_COPY_AND_ASSIGN(AppContext); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 // AppChildControllerImpl ------------------------------------------------------ | 156 // AppChildControllerImpl ------------------------------------------------------ |
| 157 | 157 |
| 158 class AppChildControllerImpl : public InterfaceImpl<AppChildController> { | 158 class AppChildControllerImpl : public InterfaceImpl<AppChildController> { |
| 159 public: | 159 public: |
| 160 virtual ~AppChildControllerImpl() { | 160 ~AppChildControllerImpl() override { |
| 161 DCHECK(thread_checker_.CalledOnValidThread()); | 161 DCHECK(thread_checker_.CalledOnValidThread()); |
| 162 | 162 |
| 163 // TODO(vtl): Pass in the result from |MainMain()|. | 163 // TODO(vtl): Pass in the result from |MainMain()|. |
| 164 client()->AppCompleted(MOJO_RESULT_UNIMPLEMENTED); | 164 client()->AppCompleted(MOJO_RESULT_UNIMPLEMENTED); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // To be executed on the controller thread. Creates the |AppChildController|, | 167 // To be executed on the controller thread. Creates the |AppChildController|, |
| 168 // etc. | 168 // etc. |
| 169 static void Init( | 169 static void Init( |
| 170 AppContext* app_context, | 170 AppContext* app_context, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 183 app_context->io_runner(), | 183 app_context->io_runner(), |
| 184 base::Bind(&AppChildControllerImpl::DidCreateChannel, | 184 base::Bind(&AppChildControllerImpl::DidCreateChannel, |
| 185 base::Unretained(impl.get())), | 185 base::Unretained(impl.get())), |
| 186 base::MessageLoopProxy::current())); | 186 base::MessageLoopProxy::current())); |
| 187 | 187 |
| 188 BindToPipe(impl.get(), host_message_pipe.Pass()); | 188 BindToPipe(impl.get(), host_message_pipe.Pass()); |
| 189 | 189 |
| 190 app_context->set_controller(impl.Pass()); | 190 app_context->set_controller(impl.Pass()); |
| 191 } | 191 } |
| 192 | 192 |
| 193 virtual void OnConnectionError() override { | 193 void OnConnectionError() override { |
| 194 // TODO(darin): How should we handle a connection error here? | 194 // TODO(darin): How should we handle a connection error here? |
| 195 } | 195 } |
| 196 | 196 |
| 197 // |AppChildController| methods: | 197 // |AppChildController| methods: |
| 198 virtual void StartApp(const String& app_path, | 198 void StartApp(const String& app_path, |
| 199 ScopedMessagePipeHandle service) override { | 199 ScopedMessagePipeHandle service) override { |
| 200 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)"; | 200 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)"; |
| 201 DCHECK(thread_checker_.CalledOnValidThread()); | 201 DCHECK(thread_checker_.CalledOnValidThread()); |
| 202 | 202 |
| 203 unblocker_.Unblock(base::Bind(&AppChildControllerImpl::StartAppOnMainThread, | 203 unblocker_.Unblock(base::Bind(&AppChildControllerImpl::StartAppOnMainThread, |
| 204 base::FilePath::FromUTF8Unsafe(app_path), | 204 base::FilePath::FromUTF8Unsafe(app_path), |
| 205 base::Passed(&service))); | 205 base::Passed(&service))); |
| 206 } | 206 } |
| 207 | 207 |
| 208 private: | 208 private: |
| 209 AppChildControllerImpl(AppContext* app_context, | 209 AppChildControllerImpl(AppContext* app_context, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), | 283 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), |
| 284 base::Passed(platform_channel()), blocker.GetUnblocker())); | 284 base::Passed(platform_channel()), blocker.GetUnblocker())); |
| 285 // This will block, then run whatever the controller wants. | 285 // This will block, then run whatever the controller wants. |
| 286 blocker.Block(); | 286 blocker.Block(); |
| 287 | 287 |
| 288 app_context.Shutdown(); | 288 app_context.Shutdown(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 } // namespace shell | 291 } // namespace shell |
| 292 } // namespace mojo | 292 } // namespace mojo |
| OLD | NEW |