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

Side by Side Diff: content/browser/browser_child_process_host_impl.cc

Issue 98603007: Launches a privileged utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleans up edge cases and error handling. Fixes nits. Created 6 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/browser_child_process_host_impl.h" 5 #include "content/browser/browser_child_process_host_impl.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/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
122 // Make a copy since the BrowserChildProcessHost dtor mutates the original 122 // Make a copy since the BrowserChildProcessHost dtor mutates the original
123 // list. 123 // list.
124 BrowserChildProcessList copy = g_child_process_list.Get(); 124 BrowserChildProcessList copy = g_child_process_list.Get();
125 for (BrowserChildProcessList::iterator it = copy.begin(); 125 for (BrowserChildProcessList::iterator it = copy.begin();
126 it != copy.end(); ++it) { 126 it != copy.end(); ++it) {
127 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl. 127 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl.
128 } 128 }
129 } 129 }
130 130
131 #if defined(OS_WIN)
132 void BrowserChildProcessHostImpl::LaunchElevated(CommandLine* cmd_line) {
133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
134
135 GetContentClient()->browser()->AppendExtraCommandLineSwitches(
136 cmd_line, data_.id);
137
138 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
139 static const char* kForwardSwitches[] = {
140 switches::kDisableLogging,
141 switches::kEnableDCHECK,
142 switches::kEnableLogging,
143 switches::kLoggingLevel,
144 switches::kTraceToConsole,
145 switches::kV,
146 switches::kVModule,
147 switches::kEnableHighResolutionTime,
148 };
149 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
150 arraysize(kForwardSwitches));
151
152 child_process_.reset(ChildProcessLauncher::CreateElevated(
153 cmd_line,
154 data_.id,
155 this));
156 }
157 #endif
158
131 void BrowserChildProcessHostImpl::Launch( 159 void BrowserChildProcessHostImpl::Launch(
132 #if defined(OS_WIN) 160 #if defined(OS_WIN)
133 SandboxedProcessLauncherDelegate* delegate, 161 SandboxedProcessLauncherDelegate* delegate,
134 #elif defined(OS_POSIX) 162 #elif defined(OS_POSIX)
135 bool use_zygote, 163 bool use_zygote,
136 const base::EnvironmentMap& environ, 164 const base::EnvironmentMap& environ,
137 #endif 165 #endif
138 CommandLine* cmd_line) { 166 CommandLine* cmd_line) {
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
140 168
(...skipping 12 matching lines...) Expand all
153 #if defined(OS_POSIX) 181 #if defined(OS_POSIX)
154 switches::kChildCleanExit, 182 switches::kChildCleanExit,
155 #endif 183 #endif
156 #if defined(OS_WIN) 184 #if defined(OS_WIN)
157 switches::kEnableHighResolutionTime, 185 switches::kEnableHighResolutionTime,
158 #endif 186 #endif
159 }; 187 };
160 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, 188 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
161 arraysize(kForwardSwitches)); 189 arraysize(kForwardSwitches));
162 190
163 child_process_.reset(new ChildProcessLauncher( 191 child_process_.reset(ChildProcessLauncher::Create(
164 #if defined(OS_WIN) 192 #if defined(OS_WIN)
165 delegate, 193 delegate,
166 #elif defined(OS_POSIX) 194 #elif defined(OS_POSIX)
167 use_zygote, 195 use_zygote,
168 environ, 196 environ,
169 child_process_host_->TakeClientFileDescriptor(), 197 child_process_host_->TakeClientFileDescriptor(),
170 #endif 198 #endif
171 cmd_line, 199 cmd_line,
172 data_.id, 200 data_.id,
173 this)); 201 this));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 380
353 void BrowserChildProcessHostImpl::OnProcessExitedEarly( 381 void BrowserChildProcessHostImpl::OnProcessExitedEarly(
354 base::WaitableEvent* event) { 382 base::WaitableEvent* event) {
355 DeleteProcessWaitableEvent(event); 383 DeleteProcessWaitableEvent(event);
356 OnChildDisconnected(); 384 OnChildDisconnected();
357 } 385 }
358 386
359 #endif 387 #endif
360 388
361 } // namespace content 389 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698