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

Side by Side Diff: shell/child_process_host.cc

Issue 775343004: Move //mojo/shell to //shell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/child_process_host.h ('k') | shell/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
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/child_process_host.h" 5 #include "shell/child_process_host.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/process/kill.h" 13 #include "base/process/kill.h"
14 #include "base/process/launch.h" 14 #include "base/process/launch.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/task_runner.h" 16 #include "base/task_runner.h"
17 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
18 #include "mojo/shell/context.h" 18 #include "shell/context.h"
19 #include "mojo/shell/switches.h" 19 #include "shell/switches.h"
20 20
21 namespace mojo { 21 namespace mojo {
22 namespace shell { 22 namespace shell {
23 23
24 ChildProcessHost::ChildProcessHost(Context* context, 24 ChildProcessHost::ChildProcessHost(Context* context,
25 Delegate* delegate, 25 Delegate* delegate,
26 ChildProcess::Type type) 26 ChildProcess::Type type)
27 : context_(context), 27 : context_(context),
28 delegate_(delegate), 28 delegate_(delegate),
29 type_(type), 29 type_(type),
(...skipping 10 matching lines...) Expand all
40 child_process_handle_ = base::kNullProcessHandle; 40 child_process_handle_ = base::kNullProcessHandle;
41 } 41 }
42 } 42 }
43 43
44 void ChildProcessHost::Start() { 44 void ChildProcessHost::Start() {
45 DCHECK_EQ(child_process_handle_, base::kNullProcessHandle); 45 DCHECK_EQ(child_process_handle_, base::kNullProcessHandle);
46 46
47 delegate_->WillStart(); 47 delegate_->WillStart();
48 48
49 CHECK(base::PostTaskAndReplyWithResult( 49 CHECK(base::PostTaskAndReplyWithResult(
50 context_->task_runners()->blocking_pool(), 50 context_->task_runners()->blocking_pool(), FROM_HERE,
51 FROM_HERE,
52 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this)), 51 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this)),
53 base::Bind(&ChildProcessHost::DidLaunch, base::Unretained(this)))); 52 base::Bind(&ChildProcessHost::DidLaunch, base::Unretained(this))));
54 } 53 }
55 54
56 int ChildProcessHost::Join() { 55 int ChildProcessHost::Join() {
57 DCHECK_NE(child_process_handle_, base::kNullProcessHandle); 56 DCHECK_NE(child_process_handle_, base::kNullProcessHandle);
58 int rv = -1; 57 int rv = -1;
59 // Note: |WaitForExitCode()| closes the process handle. 58 // Note: |WaitForExitCode()| closes the process handle.
60 LOG_IF(ERROR, !base::WaitForExitCode(child_process_handle_, &rv)) 59 LOG_IF(ERROR, !base::WaitForExitCode(child_process_handle_, &rv))
61 << "Failed to wait for child process"; 60 << "Failed to wait for child process";
62 child_process_handle_ = base::kNullProcessHandle; 61 child_process_handle_ = base::kNullProcessHandle;
63 return rv; 62 return rv;
64 } 63 }
65 64
66 bool ChildProcessHost::DoLaunch() { 65 bool ChildProcessHost::DoLaunch() {
67 static const char* kForwardSwitches[] = { 66 static const char* kForwardSwitches[] = {
68 switches::kTraceToConsole, 67 switches::kTraceToConsole, switches::kV, switches::kVModule,
69 switches::kV,
70 switches::kVModule,
71 }; 68 };
72 69
73 const base::CommandLine* parent_command_line = 70 const base::CommandLine* parent_command_line =
74 base::CommandLine::ForCurrentProcess(); 71 base::CommandLine::ForCurrentProcess();
75 base::CommandLine child_command_line(parent_command_line->GetProgram()); 72 base::CommandLine child_command_line(parent_command_line->GetProgram());
76 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, 73 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches,
77 arraysize(kForwardSwitches)); 74 arraysize(kForwardSwitches));
78 child_command_line.AppendSwitchASCII( 75 child_command_line.AppendSwitchASCII(
79 switches::kChildProcessType, base::IntToString(static_cast<int>(type_))); 76 switches::kChildProcessType, base::IntToString(static_cast<int>(type_)));
80 77
(...skipping 15 matching lines...) Expand all
96 platform_channel_pair_.ChildProcessLaunched(); 93 platform_channel_pair_.ChildProcessLaunched();
97 return true; 94 return true;
98 } 95 }
99 96
100 void ChildProcessHost::DidLaunch(bool success) { 97 void ChildProcessHost::DidLaunch(bool success) {
101 delegate_->DidStart(success); 98 delegate_->DidStart(success);
102 } 99 }
103 100
104 } // namespace shell 101 } // namespace shell
105 } // namespace mojo 102 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/child_process_host.h ('k') | shell/child_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698