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.
5 #include "mojo/shell/app_child_process_host.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h"
10 #include "mojo/embedder/embedder.h"
11 #include "mojo/public/cpp/system/core.h"
12 #include "mojo/shell/context.h"
13 #include "mojo/shell/task_runners.h"
18 AppChildProcessHost::AppChildProcessHost(
20 AppChildControllerClient
* controller_client
)
21 : ChildProcessHost(context
, this, ChildProcess::TYPE_APP
),
22 controller_client_(controller_client
),
26 AppChildProcessHost::~AppChildProcessHost() {
29 void AppChildProcessHost::WillStart() {
30 DCHECK(platform_channel()->is_valid());
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()));
39 controller_
.Bind(handle
.Pass());
40 controller_
.set_client(controller_client_
);
43 void AppChildProcessHost::DidStart(bool success
) {
44 DVLOG(2) << "AppChildProcessHost::DidStart()";
47 LOG(ERROR
) << "Failed to start app child process";
48 controller_client_
->AppCompleted(MOJO_RESULT_UNKNOWN
);
53 // Callback for |embedder::CreateChannel()|.
54 void AppChildProcessHost::DidCreateChannel(
55 embedder::ChannelInfo
* channel_info
) {
56 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()";
59 channel_info_
= channel_info
;