| 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/profiler/scoped_tracker.h" | 15 #include "base/profiler/scoped_tracker.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 19 #include "content/browser/histogram_message_filter.h" | 19 #include "content/browser/histogram_message_filter.h" |
| 20 #include "content/browser/loader/resource_message_filter.h" | 20 #include "content/browser/loader/resource_message_filter.h" |
| 21 #include "content/browser/memory/memory_message_filter.h" | 21 #include "content/browser/memory/memory_message_filter.h" |
| 22 #include "content/browser/profiler_message_filter.h" | 22 #include "content/browser/profiler_message_filter.h" |
| 23 #include "content/browser/tracing/trace_message_filter.h" | 23 #include "content/browser/tracing/trace_message_filter.h" |
| 24 #include "content/common/child_process_host_impl.h" | 24 #include "content/common/child_process_host_impl.h" |
| 25 #include "content/common/child_process_messages.h" |
| 25 #include "content/public/browser/browser_child_process_host_delegate.h" | 26 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 26 #include "content/public/browser/browser_child_process_observer.h" | 27 #include "content/public/browser/browser_child_process_observer.h" |
| 27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/child_process_data.h" | 29 #include "content/public/browser/child_process_data.h" |
| 29 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
| 30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 31 #include "content/public/common/process_type.h" | 32 #include "content/public/common/process_type.h" |
| 32 #include "content/public/common/result_codes.h" | 33 #include "content/public/common/result_codes.h" |
| 33 #include "ipc/attachment_broker.h" | 34 #include "ipc/attachment_broker.h" |
| 34 #include "ipc/attachment_broker_privileged.h" | 35 #include "ipc/attachment_broker_privileged.h" |
| 36 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 35 | 37 |
| 36 #if defined(OS_MACOSX) | 38 #if defined(OS_MACOSX) |
| 37 #include "content/browser/mach_broker_mac.h" | 39 #include "content/browser/mach_broker_mac.h" |
| 38 #endif | 40 #endif |
| 39 | 41 |
| 40 namespace content { | 42 namespace content { |
| 41 namespace { | 43 namespace { |
| 42 | 44 |
| 43 static base::LazyInstance<BrowserChildProcessHostImpl::BrowserChildProcessList> | 45 static base::LazyInstance<BrowserChildProcessHostImpl::BrowserChildProcessList> |
| 44 g_child_process_list = LAZY_INSTANCE_INITIALIZER; | 46 g_child_process_list = LAZY_INSTANCE_INITIALIZER; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 401 |
| 400 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 | 402 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| 401 // is fixed. | 403 // is fixed. |
| 402 tracked_objects::ScopedTracker tracking_profile( | 404 tracked_objects::ScopedTracker tracking_profile( |
| 403 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 405 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 404 "465841 BrowserChildProcessHostImpl::OnProcessLaunched")); | 406 "465841 BrowserChildProcessHostImpl::OnProcessLaunched")); |
| 405 const base::Process& process = child_process_->GetProcess(); | 407 const base::Process& process = child_process_->GetProcess(); |
| 406 DCHECK(process.IsValid()); | 408 DCHECK(process.IsValid()); |
| 407 | 409 |
| 408 #if defined(OS_WIN) | 410 #if defined(OS_WIN) |
| 411 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { |
| 412 HANDLE client_pipe = mojo::embedder::ChildProcessLaunched(process.Handle()); |
| 413 Send(new ChildProcessMsg_SetMojoParentPipeHandle( |
| 414 IPC::GetFileHandleForProcess(client_pipe, process.Handle(), true))); |
| 415 } |
| 416 |
| 409 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the | 417 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the |
| 410 // child process exits. This watcher is stopped once the IPC channel is | 418 // child process exits. This watcher is stopped once the IPC channel is |
| 411 // connected and the exit of the child process is detecter by an error on the | 419 // connected and the exit of the child process is detecter by an error on the |
| 412 // IPC channel thereafter. | 420 // IPC channel thereafter. |
| 413 DCHECK(!early_exit_watcher_.GetWatchedObject()); | 421 DCHECK(!early_exit_watcher_.GetWatchedObject()); |
| 414 early_exit_watcher_.StartWatchingOnce(process.Handle(), this); | 422 early_exit_watcher_.StartWatchingOnce(process.Handle(), this); |
| 415 #endif | 423 #endif |
| 416 | 424 |
| 417 // TODO(rvargas) crbug.com/417532: Don't store a handle. | 425 // TODO(rvargas) crbug.com/417532: Don't store a handle. |
| 418 data_.handle = process.Handle(); | 426 data_.handle = process.Handle(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 433 | 441 |
| 434 #if defined(OS_WIN) | 442 #if defined(OS_WIN) |
| 435 | 443 |
| 436 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 444 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
| 437 OnChildDisconnected(); | 445 OnChildDisconnected(); |
| 438 } | 446 } |
| 439 | 447 |
| 440 #endif | 448 #endif |
| 441 | 449 |
| 442 } // namespace content | 450 } // namespace content |
| OLD | NEW |