| 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/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/debug/dump_without_crashing.h" | 10 #include "base/debug/dump_without_crashing.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "content/browser/histogram_message_filter.h" | 18 #include "content/browser/histogram_message_filter.h" |
| 19 #include "content/browser/loader/resource_message_filter.h" | 19 #include "content/browser/loader/resource_message_filter.h" |
| 20 #include "content/browser/memory/memory_message_filter.h" | 20 #include "content/browser/memory/memory_message_filter.h" |
| 21 #include "content/browser/profiler_message_filter.h" | 21 #include "content/browser/profiler_message_filter.h" |
| 22 #include "content/browser/tracing/trace_message_filter.h" | 22 #include "content/browser/tracing/trace_message_filter.h" |
| 23 #include "content/common/child_process_host_impl.h" | 23 #include "content/common/child_process_host_impl.h" |
| 24 #include "content/common/child_process_messages.h" |
| 24 #include "content/public/browser/browser_child_process_host_delegate.h" | 25 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 25 #include "content/public/browser/browser_child_process_observer.h" | 26 #include "content/public/browser/browser_child_process_observer.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/child_process_data.h" | 28 #include "content/public/browser/child_process_data.h" |
| 28 #include "content/public/browser/content_browser_client.h" | 29 #include "content/public/browser/content_browser_client.h" |
| 29 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
| 30 #include "content/public/common/process_type.h" | 31 #include "content/public/common/process_type.h" |
| 31 #include "content/public/common/result_codes.h" | 32 #include "content/public/common/result_codes.h" |
| 32 #include "ipc/attachment_broker.h" | 33 #include "ipc/attachment_broker.h" |
| 33 #include "ipc/attachment_broker_privileged.h" | 34 #include "ipc/attachment_broker_privileged.h" |
| 35 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 34 | 36 |
| 35 #if defined(OS_MACOSX) | 37 #if defined(OS_MACOSX) |
| 36 #include "content/browser/mach_broker_mac.h" | 38 #include "content/browser/mach_broker_mac.h" |
| 37 #endif | 39 #endif |
| 38 | 40 |
| 39 namespace content { | 41 namespace content { |
| 40 namespace { | 42 namespace { |
| 41 | 43 |
| 42 static base::LazyInstance<BrowserChildProcessHostImpl::BrowserChildProcessList> | 44 static base::LazyInstance<BrowserChildProcessHostImpl::BrowserChildProcessList> |
| 43 g_child_process_list = LAZY_INSTANCE_INITIALIZER; | 45 g_child_process_list = LAZY_INSTANCE_INITIALIZER; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 delete delegate_; // Will delete us | 395 delete delegate_; // Will delete us |
| 394 } | 396 } |
| 395 | 397 |
| 396 void BrowserChildProcessHostImpl::OnProcessLaunched() { | 398 void BrowserChildProcessHostImpl::OnProcessLaunched() { |
| 397 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 399 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 398 | 400 |
| 399 const base::Process& process = child_process_->GetProcess(); | 401 const base::Process& process = child_process_->GetProcess(); |
| 400 DCHECK(process.IsValid()); | 402 DCHECK(process.IsValid()); |
| 401 | 403 |
| 402 #if defined(OS_WIN) | 404 #if defined(OS_WIN) |
| 405 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { |
| 406 HANDLE client_pipe = mojo::embedder::ChildProcessLaunched(process.Handle()); |
| 407 Send(new ChildProcessMsg_SetMojoParentPipeHandle( |
| 408 IPC::GetFileHandleForProcess(client_pipe, process.Handle(), true))); |
| 409 } |
| 410 |
| 403 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the | 411 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the |
| 404 // child process exits. This watcher is stopped once the IPC channel is | 412 // child process exits. This watcher is stopped once the IPC channel is |
| 405 // connected and the exit of the child process is detecter by an error on the | 413 // connected and the exit of the child process is detecter by an error on the |
| 406 // IPC channel thereafter. | 414 // IPC channel thereafter. |
| 407 DCHECK(!early_exit_watcher_.GetWatchedObject()); | 415 DCHECK(!early_exit_watcher_.GetWatchedObject()); |
| 408 early_exit_watcher_.StartWatchingOnce(process.Handle(), this); | 416 early_exit_watcher_.StartWatchingOnce(process.Handle(), this); |
| 409 #endif | 417 #endif |
| 410 | 418 |
| 411 // TODO(rvargas) crbug.com/417532: Don't store a handle. | 419 // TODO(rvargas) crbug.com/417532: Don't store a handle. |
| 412 data_.handle = process.Handle(); | 420 data_.handle = process.Handle(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 427 | 435 |
| 428 #if defined(OS_WIN) | 436 #if defined(OS_WIN) |
| 429 | 437 |
| 430 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 438 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
| 431 OnChildDisconnected(); | 439 OnChildDisconnected(); |
| 432 } | 440 } |
| 433 | 441 |
| 434 #endif | 442 #endif |
| 435 | 443 |
| 436 } // namespace content | 444 } // namespace content |
| OLD | NEW |