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

Side by Side Diff: shell/child_process_host.cc

Issue 1043123004: Shell: Remove various child process type stuff. (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
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 "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"
16 #include "base/task_runner.h" 15 #include "base/task_runner.h"
17 #include "base/task_runner_util.h" 16 #include "base/task_runner_util.h"
18 #include "shell/context.h" 17 #include "shell/context.h"
19 #include "shell/switches.h" 18 #include "shell/switches.h"
20 19
21 namespace mojo { 20 namespace mojo {
22 namespace shell { 21 namespace shell {
23 22
24 ChildProcessHost::ChildProcessHost(Context* context, 23 ChildProcessHost::ChildProcessHost(Context* context, Delegate* delegate)
25 Delegate* delegate, 24 : context_(context), delegate_(delegate) {
26 ChildProcess::Type type)
27 : context_(context), delegate_(delegate), type_(type) {
28 DCHECK(delegate); 25 DCHECK(delegate);
29 platform_channel_ = platform_channel_pair_.PassServerHandle(); 26 platform_channel_ = platform_channel_pair_.PassServerHandle();
30 CHECK(platform_channel_.is_valid()); 27 CHECK(platform_channel_.is_valid());
31 } 28 }
32 29
33 ChildProcessHost::~ChildProcessHost() { 30 ChildProcessHost::~ChildProcessHost() {
34 if (child_process_.IsValid()) { 31 if (child_process_.IsValid()) {
35 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child"; 32 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child";
36 child_process_.Close(); 33 child_process_.Close();
37 } 34 }
(...skipping 22 matching lines...) Expand all
60 bool ChildProcessHost::DoLaunch() { 57 bool ChildProcessHost::DoLaunch() {
61 static const char* kForwardSwitches[] = { 58 static const char* kForwardSwitches[] = {
62 switches::kTraceToConsole, switches::kV, switches::kVModule, 59 switches::kTraceToConsole, switches::kV, switches::kVModule,
63 }; 60 };
64 61
65 const base::CommandLine* parent_command_line = 62 const base::CommandLine* parent_command_line =
66 base::CommandLine::ForCurrentProcess(); 63 base::CommandLine::ForCurrentProcess();
67 base::CommandLine child_command_line(parent_command_line->GetProgram()); 64 base::CommandLine child_command_line(parent_command_line->GetProgram());
68 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, 65 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches,
69 arraysize(kForwardSwitches)); 66 arraysize(kForwardSwitches));
70 child_command_line.AppendSwitchASCII( 67 child_command_line.AppendSwitch(switches::kChildProcess);
71 switches::kChildProcessType, base::IntToString(static_cast<int>(type_)));
72 68
73 embedder::HandlePassingInformation handle_passing_info; 69 embedder::HandlePassingInformation handle_passing_info;
74 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( 70 platform_channel_pair_.PrepareToPassClientHandleToChildProcess(
75 &child_command_line, &handle_passing_info); 71 &child_command_line, &handle_passing_info);
76 72
77 base::LaunchOptions options; 73 base::LaunchOptions options;
78 #if defined(OS_WIN) 74 #if defined(OS_WIN)
79 options.start_hidden = true; 75 options.start_hidden = true;
80 options.handles_to_inherit = &handle_passing_info; 76 options.handles_to_inherit = &handle_passing_info;
81 #elif defined(OS_POSIX) 77 #elif defined(OS_POSIX)
82 options.fds_to_remap = &handle_passing_info; 78 options.fds_to_remap = &handle_passing_info;
83 #endif 79 #endif
84 DVLOG(2) << "Launching child with command line: " 80 DVLOG(2) << "Launching child with command line: "
85 << child_command_line.GetCommandLineString(); 81 << child_command_line.GetCommandLineString();
86 child_process_ = base::LaunchProcess(child_command_line, options); 82 child_process_ = base::LaunchProcess(child_command_line, options);
87 if (!child_process_.IsValid()) 83 if (!child_process_.IsValid())
88 return false; 84 return false;
89 85
90 platform_channel_pair_.ChildProcessLaunched(); 86 platform_channel_pair_.ChildProcessLaunched();
91 return true; 87 return true;
92 } 88 }
93 89
94 void ChildProcessHost::DidLaunch(bool success) { 90 void ChildProcessHost::DidLaunch(bool success) {
95 delegate_->DidStart(success); 91 delegate_->DidStart(success);
96 } 92 }
97 93
98 } // namespace shell 94 } // namespace shell
99 } // namespace mojo 95 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698