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