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