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

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 ChildProcessLauncher implementations. Created 6 years, 10 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void BrowserChildProcessHostImpl::Launch( 131 void BrowserChildProcessHostImpl::Launch(
132 #if defined(OS_WIN) 132 #if defined(OS_WIN)
133 SandboxedProcessLauncherDelegate* delegate, 133 SandboxedProcessLauncherDelegate* delegate,
134 bool launch_elevated,
134 #elif defined(OS_POSIX) 135 #elif defined(OS_POSIX)
135 bool use_zygote, 136 bool use_zygote,
136 const base::EnvironmentMap& environ, 137 const base::EnvironmentMap& environ,
137 #endif 138 #endif
138 CommandLine* cmd_line) { 139 CommandLine* cmd_line) {
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
140 141
141 GetContentClient()->browser()->AppendExtraCommandLineSwitches( 142 GetContentClient()->browser()->AppendExtraCommandLineSwitches(
142 cmd_line, data_.id); 143 cmd_line, data_.id);
143 144
(...skipping 12 matching lines...) Expand all
156 #if defined(OS_WIN) 157 #if defined(OS_WIN)
157 switches::kEnableHighResolutionTime, 158 switches::kEnableHighResolutionTime,
158 #endif 159 #endif
159 }; 160 };
160 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, 161 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
161 arraysize(kForwardSwitches)); 162 arraysize(kForwardSwitches));
162 163
163 child_process_.reset(new ChildProcessLauncher( 164 child_process_.reset(new ChildProcessLauncher(
164 #if defined(OS_WIN) 165 #if defined(OS_WIN)
165 delegate, 166 delegate,
167 launch_elevated,
166 #elif defined(OS_POSIX) 168 #elif defined(OS_POSIX)
167 use_zygote, 169 use_zygote,
168 environ, 170 environ,
169 child_process_host_->TakeClientFileDescriptor(), 171 child_process_host_->TakeClientFileDescriptor(),
170 #endif 172 #endif
171 cmd_line, 173 cmd_line,
172 data_.id, 174 data_.id,
173 this)); 175 this));
174 } 176 }
175 177
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 308 }
307 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 309 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
308 base::Bind(&NotifyProcessHostDisconnected, data_)); 310 base::Bind(&NotifyProcessHostDisconnected, data_));
309 delete delegate_; // Will delete us 311 delete delegate_; // Will delete us
310 } 312 }
311 313
312 bool BrowserChildProcessHostImpl::Send(IPC::Message* message) { 314 bool BrowserChildProcessHostImpl::Send(IPC::Message* message) {
313 return child_process_host_->Send(message); 315 return child_process_host_->Send(message);
314 } 316 }
315 317
318 void BrowserChildProcessHostImpl::OnProcessLaunchFailed() {
319 delegate_->OnProcessLaunchFailed();
jam 2014/01/30 21:41:03 nit: two space indent
Drew Haven 2014/01/31 20:00:12 Done.
320 delete delegate_; // Will delete us
321 }
322
316 void BrowserChildProcessHostImpl::OnProcessLaunched() { 323 void BrowserChildProcessHostImpl::OnProcessLaunched() {
317 base::ProcessHandle handle = child_process_->GetHandle(); 324 base::ProcessHandle handle = child_process_->GetHandle();
318 if (!handle) { 325 if (!handle) {
319 delete delegate_; // Will delete us 326 delete delegate_; // Will delete us
320 return; 327 return;
321 } 328 }
322 329
323 #if defined(OS_WIN) 330 #if defined(OS_WIN)
324 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the 331 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the
325 // child process exits. This watcher is stopped once the IPC channel is 332 // child process exits. This watcher is stopped once the IPC channel is
(...skipping 26 matching lines...) Expand all
352 359
353 void BrowserChildProcessHostImpl::OnProcessExitedEarly( 360 void BrowserChildProcessHostImpl::OnProcessExitedEarly(
354 base::WaitableEvent* event) { 361 base::WaitableEvent* event) {
355 DeleteProcessWaitableEvent(event); 362 DeleteProcessWaitableEvent(event);
356 OnChildDisconnected(); 363 OnChildDisconnected();
357 } 364 }
358 365
359 #endif 366 #endif
360 367
361 } // namespace content 368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698