| 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_host.h" | 5 #include "shell/app_child_process_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/edk/embedder/embedder.h" | 10 #include "mojo/edk/embedder/embedder.h" |
| 11 #include "mojo/public/cpp/system/core.h" | 11 #include "mojo/public/cpp/system/core.h" |
| 12 #include "mojo/shell/context.h" | 12 #include "shell/context.h" |
| 13 #include "mojo/shell/task_runners.h" | 13 #include "shell/task_runners.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace shell { | 16 namespace shell { |
| 17 | 17 |
| 18 AppChildProcessHost::AppChildProcessHost( | 18 AppChildProcessHost::AppChildProcessHost( |
| 19 Context* context, | 19 Context* context, |
| 20 AppChildControllerClient* controller_client) | 20 AppChildControllerClient* controller_client) |
| 21 : ChildProcessHost(context, this, ChildProcess::TYPE_APP), | 21 : ChildProcessHost(context, this, ChildProcess::TYPE_APP), |
| 22 controller_client_(controller_client), | 22 controller_client_(controller_client), |
| 23 channel_info_(NULL) { | 23 channel_info_(NULL) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 AppChildProcessHost::~AppChildProcessHost() { | 26 AppChildProcessHost::~AppChildProcessHost() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 void AppChildProcessHost::WillStart() { | 29 void AppChildProcessHost::WillStart() { |
| 30 DCHECK(platform_channel()->is_valid()); | 30 DCHECK(platform_channel()->is_valid()); |
| 31 | 31 |
| 32 mojo::ScopedMessagePipeHandle handle(embedder::CreateChannel( | 32 mojo::ScopedMessagePipeHandle handle(embedder::CreateChannel( |
| 33 platform_channel()->Pass(), | 33 platform_channel()->Pass(), context()->task_runners()->io_runner(), |
| 34 context()->task_runners()->io_runner(), | |
| 35 base::Bind(&AppChildProcessHost::DidCreateChannel, | 34 base::Bind(&AppChildProcessHost::DidCreateChannel, |
| 36 base::Unretained(this)), | 35 base::Unretained(this)), |
| 37 base::MessageLoop::current()->message_loop_proxy())); | 36 base::MessageLoop::current()->message_loop_proxy())); |
| 38 | 37 |
| 39 controller_.Bind(handle.Pass()); | 38 controller_.Bind(handle.Pass()); |
| 40 controller_.set_client(controller_client_); | 39 controller_.set_client(controller_client_); |
| 41 } | 40 } |
| 42 | 41 |
| 43 void AppChildProcessHost::DidStart(bool success) { | 42 void AppChildProcessHost::DidStart(bool success) { |
| 44 DVLOG(2) << "AppChildProcessHost::DidStart()"; | 43 DVLOG(2) << "AppChildProcessHost::DidStart()"; |
| 45 | 44 |
| 46 if (!success) { | 45 if (!success) { |
| 47 LOG(ERROR) << "Failed to start app child process"; | 46 LOG(ERROR) << "Failed to start app child process"; |
| 48 controller_client_->AppCompleted(MOJO_RESULT_UNKNOWN); | 47 controller_client_->AppCompleted(MOJO_RESULT_UNKNOWN); |
| 49 return; | 48 return; |
| 50 } | 49 } |
| 51 } | 50 } |
| 52 | 51 |
| 53 // Callback for |embedder::CreateChannel()|. | 52 // Callback for |embedder::CreateChannel()|. |
| 54 void AppChildProcessHost::DidCreateChannel( | 53 void AppChildProcessHost::DidCreateChannel( |
| 55 embedder::ChannelInfo* channel_info) { | 54 embedder::ChannelInfo* channel_info) { |
| 56 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; | 55 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; |
| 57 | 56 |
| 58 CHECK(channel_info); | 57 CHECK(channel_info); |
| 59 channel_info_ = channel_info; | 58 channel_info_ = channel_info; |
| 60 } | 59 } |
| 61 | 60 |
| 62 } // namespace shell | 61 } // namespace shell |
| 63 } // namespace mojo | 62 } // namespace mojo |
| OLD | NEW |