Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: mojo/shell/app_child_process_host.cc

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/shell/app_child_process_host.h ('k') | mojo/shell/app_child_process_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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(Context* context)
19 : ChildProcessHost(context), channel_info_(nullptr) {
20 }
21
22 AppChildProcessHost::~AppChildProcessHost() {
23 }
24
25 void AppChildProcessHost::StartApp(
26 const String& app_path,
27 bool clean_app_path,
28 InterfaceRequest<Application> application_request,
29 const AppChildController::StartAppCallback& on_app_complete) {
30 DCHECK(controller_);
31
32 on_app_complete_ = on_app_complete;
33 controller_->StartApp(
34 app_path, clean_app_path, application_request.Pass(),
35 base::Bind(&AppChildProcessHost::AppCompleted, base::Unretained(this)));
36 }
37
38 void AppChildProcessHost::ExitNow(int32_t exit_code) {
39 DCHECK(controller_);
40
41 controller_->ExitNow(exit_code);
42 }
43
44 void AppChildProcessHost::WillStart() {
45 DCHECK(platform_channel()->is_valid());
46
47 ScopedMessagePipeHandle handle(embedder::CreateChannel(
48 platform_channel()->Pass(), context()->task_runners()->io_runner(),
49 base::Bind(&AppChildProcessHost::DidCreateChannel,
50 base::Unretained(this)),
51 base::MessageLoop::current()->message_loop_proxy()));
52
53 controller_.Bind(handle.Pass());
54 }
55
56 void AppChildProcessHost::DidStart(bool success) {
57 DVLOG(2) << "AppChildProcessHost::DidStart()";
58
59 if (!success) {
60 LOG(ERROR) << "Failed to start app child process";
61 AppCompleted(MOJO_RESULT_UNKNOWN);
62 return;
63 }
64 }
65
66 // Callback for |embedder::CreateChannel()|.
67 void AppChildProcessHost::DidCreateChannel(
68 embedder::ChannelInfo* channel_info) {
69 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()";
70
71 CHECK(channel_info);
72 channel_info_ = channel_info;
73 }
74
75 void AppChildProcessHost::AppCompleted(int32_t result) {
76 if (!on_app_complete_.is_null()) {
77 auto on_app_complete = on_app_complete_;
78 on_app_complete_.reset();
79 on_app_complete.Run(result);
80 }
81 }
82
83 } // namespace shell
84 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/app_child_process_host.h ('k') | mojo/shell/app_child_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698