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

Side by Side Diff: shell/app_child_process_host.cc

Issue 1056593002: Merge AppChildProcessHost into ChildProcessHost. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 | « shell/app_child_process_host.h ('k') | 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 "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 "shell/context.h"
13 #include "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 controller_.set_error_handler(this);
55 }
56
57 void AppChildProcessHost::DidStart(bool success) {
58 DVLOG(2) << "AppChildProcessHost::DidStart()";
59
60 if (!success) {
61 LOG(ERROR) << "Failed to start app child process";
62 AppCompleted(MOJO_RESULT_UNKNOWN);
63 return;
64 }
65 }
66
67 void AppChildProcessHost::OnConnectionError() {
68 AppCompleted(MOJO_RESULT_UNKNOWN);
69 }
70
71 // Callback for |embedder::CreateChannel()|.
72 void AppChildProcessHost::DidCreateChannel(
73 embedder::ChannelInfo* channel_info) {
74 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()";
75
76 CHECK(channel_info);
77 channel_info_ = channel_info;
78 }
79
80 void AppChildProcessHost::AppCompleted(int32_t result) {
81 if (!on_app_complete_.is_null()) {
82 auto on_app_complete = on_app_complete_;
83 on_app_complete_.reset();
84 on_app_complete.Run(result);
85 }
86 }
87
88 } // namespace shell
89 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/app_child_process_host.h ('k') | shell/app_child_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698