OLD | NEW |
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 &files_to_register); | 237 &files_to_register); |
237 | 238 |
238 StartChildProcess(cmd_line->argv(), files_to_register, | 239 StartChildProcess(cmd_line->argv(), files_to_register, |
239 base::Bind(&ChildProcessLauncher::Context::OnChildProcessStarted, | 240 base::Bind(&ChildProcessLauncher::Context::OnChildProcessStarted, |
240 this_object, client_thread_id, begin_launch_time)); | 241 this_object, client_thread_id, begin_launch_time)); |
241 | 242 |
242 #elif defined(OS_POSIX) | 243 #elif defined(OS_POSIX) |
243 base::ProcessHandle handle = base::kNullProcessHandle; | 244 base::ProcessHandle handle = base::kNullProcessHandle; |
244 // We need to close the client end of the IPC channel to reliably detect | 245 // We need to close the client end of the IPC channel to reliably detect |
245 // child termination. | 246 // child termination. |
246 file_util::ScopedFD ipcfd_closer(&ipcfd); | 247 base::ScopedFD ipcfd_closer(ipcfd); |
247 | 248 |
248 #if !defined(OS_MACOSX) | 249 #if !defined(OS_MACOSX) |
249 GetContentClient()->browser()-> | 250 GetContentClient()->browser()-> |
250 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id, | 251 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id, |
251 &files_to_register); | 252 &files_to_register); |
252 if (use_zygote) { | 253 if (use_zygote) { |
253 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(), | 254 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(), |
254 files_to_register, | 255 files_to_register, |
255 process_type); | 256 process_type); |
256 } else | 257 } else |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 #endif // !defined(OS_ANDROID) | 328 #endif // !defined(OS_ANDROID) |
328 } | 329 } |
329 | 330 |
330 void Notify( | 331 void Notify( |
331 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 332 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
332 bool zygote, | 333 bool zygote, |
333 #endif | 334 #endif |
334 base::ProcessHandle handle) { | 335 base::ProcessHandle handle) { |
335 #if defined(OS_ANDROID) | 336 #if defined(OS_ANDROID) |
336 // Finally close the ipcfd | 337 // Finally close the ipcfd |
337 file_util::ScopedFD ipcfd_closer(&ipcfd_); | 338 base::ScopedFD ipcfd_closer(ipcfd_); |
338 #endif | 339 #endif |
339 starting_ = false; | 340 starting_ = false; |
340 process_.set_handle(handle); | 341 process_.set_handle(handle); |
341 if (!handle) | 342 if (!handle) |
342 LOG(ERROR) << "Failed to launch child process"; | 343 LOG(ERROR) << "Failed to launch child process"; |
343 | 344 |
344 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 345 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
345 zygote_ = zygote; | 346 zygote_ = zygote; |
346 #endif | 347 #endif |
347 if (client_) { | 348 if (client_) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 GetHandle(), background)); | 529 GetHandle(), background)); |
529 } | 530 } |
530 | 531 |
531 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 532 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
532 bool terminate_on_shutdown) { | 533 bool terminate_on_shutdown) { |
533 if (context_.get()) | 534 if (context_.get()) |
534 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 535 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
535 } | 536 } |
536 | 537 |
537 } // namespace content | 538 } // namespace content |
OLD | NEW |