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

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

Issue 191673003: Implement ScopedFD in terms of ScopedGeneric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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/child_process_launcher.h" 5 #include "content/browser/child_process_launcher.h"
6 6
7 #include <utility> // For std::pair. 7 #include <utility> // For std::pair.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_file.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
15 #include "base/process/process.h" 16 #include "base/process/process.h"
16 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
20 #include "content/public/common/content_descriptors.h" 21 #include "content/public/common/content_descriptors.h"
21 #include "content/public/common/content_switches.h" 22 #include "content/public/common/content_switches.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 &files_to_register); 222 &files_to_register);
222 223
223 StartChildProcess(cmd_line->argv(), files_to_register, 224 StartChildProcess(cmd_line->argv(), files_to_register,
224 base::Bind(&ChildProcessLauncher::Context::OnChildProcessStarted, 225 base::Bind(&ChildProcessLauncher::Context::OnChildProcessStarted,
225 this_object, client_thread_id, begin_launch_time)); 226 this_object, client_thread_id, begin_launch_time));
226 227
227 #elif defined(OS_POSIX) 228 #elif defined(OS_POSIX)
228 base::ProcessHandle handle = base::kNullProcessHandle; 229 base::ProcessHandle handle = base::kNullProcessHandle;
229 // We need to close the client end of the IPC channel to reliably detect 230 // We need to close the client end of the IPC channel to reliably detect
230 // child termination. 231 // child termination.
231 file_util::ScopedFD ipcfd_closer(&ipcfd); 232 base::ScopedFD ipcfd_closer(ipcfd);
232 233
233 #if !defined(OS_MACOSX) 234 #if !defined(OS_MACOSX)
234 GetContentClient()->browser()-> 235 GetContentClient()->browser()->
235 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id, 236 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id,
236 &files_to_register); 237 &files_to_register);
237 if (use_zygote) { 238 if (use_zygote) {
238 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(), 239 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(),
239 files_to_register, 240 files_to_register,
240 process_type); 241 process_type);
241 } else 242 } else
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 #endif // !defined(OS_ANDROID) 313 #endif // !defined(OS_ANDROID)
313 } 314 }
314 315
315 void Notify( 316 void Notify(
316 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 317 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
317 bool zygote, 318 bool zygote,
318 #endif 319 #endif
319 base::ProcessHandle handle) { 320 base::ProcessHandle handle) {
320 #if defined(OS_ANDROID) 321 #if defined(OS_ANDROID)
321 // Finally close the ipcfd 322 // Finally close the ipcfd
322 file_util::ScopedFD ipcfd_closer(&ipcfd_); 323 base::ScopedFD ipcfd_closer(ipcfd_);
323 #endif 324 #endif
324 starting_ = false; 325 starting_ = false;
325 process_.set_handle(handle); 326 process_.set_handle(handle);
326 if (!handle) 327 if (!handle)
327 LOG(ERROR) << "Failed to launch child process"; 328 LOG(ERROR) << "Failed to launch child process";
328 329
329 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 330 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
330 zygote_ = zygote; 331 zygote_ = zygote;
331 #endif 332 #endif
332 if (client_) { 333 if (client_) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 GetHandle(), background)); 498 GetHandle(), background));
498 } 499 }
499 500
500 void ChildProcessLauncher::SetTerminateChildOnShutdown( 501 void ChildProcessLauncher::SetTerminateChildOnShutdown(
501 bool terminate_on_shutdown) { 502 bool terminate_on_shutdown) {
502 if (context_.get()) 503 if (context_.get())
503 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); 504 context_->set_terminate_child_on_shutdown(terminate_on_shutdown);
504 } 505 }
505 506
506 } // namespace content 507 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698