| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "content/public/browser/browser_child_process_host_delegate.h" | 28 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 29 #include "content/public/browser/browser_child_process_observer.h" | 29 #include "content/public/browser/browser_child_process_observer.h" |
| 30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/child_process_data.h" | 31 #include "content/public/browser/child_process_data.h" |
| 32 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
| 33 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| 34 #include "content/public/common/process_type.h" | 34 #include "content/public/common/process_type.h" |
| 35 #include "content/public/common/result_codes.h" | 35 #include "content/public/common/result_codes.h" |
| 36 #include "ipc/attachment_broker.h" | 36 #include "ipc/attachment_broker.h" |
| 37 #include "ipc/attachment_broker_privileged.h" | 37 #include "ipc/attachment_broker_privileged.h" |
| 38 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 38 #include "mojo/edk/embedder/embedder.h" |
| 39 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 39 | 40 |
| 40 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
| 41 #include "content/browser/mach_broker_mac.h" | 42 #include "content/browser/mach_broker_mac.h" |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 | 45 |
| 45 #if defined(MOJO_SHELL_CLIENT) | 46 #if defined(MOJO_SHELL_CLIENT) |
| 46 #include "content/browser/mojo/mojo_shell_client_host.h" | 47 #include "content/browser/mojo/mojo_shell_client_host.h" |
| 47 #include "content/common/mojo/mojo_shell_connection_impl.h" | 48 #include "content/common/mojo/mojo_shell_connection_impl.h" |
| 48 #endif | 49 #endif |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 const base::CommandLine& browser_command_line = | 189 const base::CommandLine& browser_command_line = |
| 189 *base::CommandLine::ForCurrentProcess(); | 190 *base::CommandLine::ForCurrentProcess(); |
| 190 static const char* kForwardSwitches[] = { | 191 static const char* kForwardSwitches[] = { |
| 191 switches::kDisableLogging, | 192 switches::kDisableLogging, |
| 192 switches::kEnableLogging, | 193 switches::kEnableLogging, |
| 193 switches::kIPCConnectionTimeout, | 194 switches::kIPCConnectionTimeout, |
| 194 switches::kLoggingLevel, | 195 switches::kLoggingLevel, |
| 195 switches::kTraceToConsole, | 196 switches::kTraceToConsole, |
| 196 switches::kV, | 197 switches::kV, |
| 197 switches::kVModule, | 198 switches::kVModule, |
| 198 "use-new-edk", // TODO(use_chrome_edk): temporary. | |
| 199 }; | 199 }; |
| 200 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, | 200 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, |
| 201 arraysize(kForwardSwitches)); | 201 arraysize(kForwardSwitches)); |
| 202 | 202 |
| 203 child_process_.reset(new ChildProcessLauncher( | 203 child_process_.reset(new ChildProcessLauncher( |
| 204 delegate, | 204 delegate, |
| 205 cmd_line, | 205 cmd_line, |
| 206 data_.id, | 206 data_.id, |
| 207 this, | 207 this, |
| 208 terminate_on_shutdown)); | 208 terminate_on_shutdown)); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 delegate_->OnProcessLaunchFailed(); | 407 delegate_->OnProcessLaunchFailed(); |
| 408 delete delegate_; // Will delete us | 408 delete delegate_; // Will delete us |
| 409 } | 409 } |
| 410 | 410 |
| 411 void BrowserChildProcessHostImpl::OnProcessLaunched() { | 411 void BrowserChildProcessHostImpl::OnProcessLaunched() { |
| 412 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 412 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 413 | 413 |
| 414 const base::Process& process = child_process_->GetProcess(); | 414 const base::Process& process = child_process_->GetProcess(); |
| 415 DCHECK(process.IsValid()); | 415 DCHECK(process.IsValid()); |
| 416 | 416 |
| 417 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { | 417 mojo::edk::ScopedPlatformHandle client_pipe; |
| 418 mojo::embedder::ScopedPlatformHandle client_pipe; | |
| 419 #if defined(MOJO_SHELL_CLIENT) | 418 #if defined(MOJO_SHELL_CLIENT) |
| 420 if (IsRunningInMojoShell()) { | 419 if (IsRunningInMojoShell()) { |
| 421 client_pipe = RegisterProcessWithBroker(process.Pid()); | 420 client_pipe = RegisterProcessWithBroker(process.Pid()); |
| 422 } else | 421 } else |
| 423 #endif | 422 #endif |
| 424 { | 423 { |
| 425 client_pipe = mojo::embedder::ChildProcessLaunched(process.Handle()); | 424 client_pipe = mojo::edk::ChildProcessLaunched(process.Handle()); |
| 426 } | |
| 427 Send(new ChildProcessMsg_SetMojoParentPipeHandle( | |
| 428 IPC::GetFileHandleForProcess( | |
| 429 #if defined(OS_WIN) | |
| 430 client_pipe.release().handle, | |
| 431 #else | |
| 432 client_pipe.release().fd, | |
| 433 #endif | |
| 434 process.Handle(), true))); | |
| 435 } | 425 } |
| 426 Send(new ChildProcessMsg_SetMojoParentPipeHandle( |
| 427 IPC::GetFileHandleForProcess(client_pipe.release().handle, |
| 428 process.Handle(), true))); |
| 436 | 429 |
| 437 #if defined(OS_WIN) | 430 #if defined(OS_WIN) |
| 438 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the | 431 // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the |
| 439 // child process exits. This watcher is stopped once the IPC channel is | 432 // child process exits. This watcher is stopped once the IPC channel is |
| 440 // connected and the exit of the child process is detecter by an error on the | 433 // connected and the exit of the child process is detecter by an error on the |
| 441 // IPC channel thereafter. | 434 // IPC channel thereafter. |
| 442 DCHECK(!early_exit_watcher_.GetWatchedObject()); | 435 DCHECK(!early_exit_watcher_.GetWatchedObject()); |
| 443 early_exit_watcher_.StartWatchingOnce(process.Handle(), this); | 436 early_exit_watcher_.StartWatchingOnce(process.Handle(), this); |
| 444 #endif | 437 #endif |
| 445 | 438 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 462 | 455 |
| 463 #if defined(OS_WIN) | 456 #if defined(OS_WIN) |
| 464 | 457 |
| 465 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 458 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
| 466 OnChildDisconnected(); | 459 OnChildDisconnected(); |
| 467 } | 460 } |
| 468 | 461 |
| 469 #endif | 462 #endif |
| 470 | 463 |
| 471 } // namespace content | 464 } // namespace content |
| OLD | NEW |