| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 #include "gpu/command_buffer/client/gpu_switches.h" | 157 #include "gpu/command_buffer/client/gpu_switches.h" |
| 158 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 158 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 159 #include "gpu/command_buffer/service/gpu_switches.h" | 159 #include "gpu/command_buffer/service/gpu_switches.h" |
| 160 #include "ipc/attachment_broker.h" | 160 #include "ipc/attachment_broker.h" |
| 161 #include "ipc/attachment_broker_privileged.h" | 161 #include "ipc/attachment_broker_privileged.h" |
| 162 #include "ipc/ipc_channel.h" | 162 #include "ipc/ipc_channel.h" |
| 163 #include "ipc/ipc_logging.h" | 163 #include "ipc/ipc_logging.h" |
| 164 #include "ipc/ipc_switches.h" | 164 #include "ipc/ipc_switches.h" |
| 165 #include "ipc/mojo/ipc_channel_mojo.h" | 165 #include "ipc/mojo/ipc_channel_mojo.h" |
| 166 #include "media/base/media_switches.h" | 166 #include "media/base/media_switches.h" |
| 167 #include "mojo/edk/embedder/embedder.h" |
| 167 #include "net/url_request/url_request_context_getter.h" | 168 #include "net/url_request/url_request_context_getter.h" |
| 168 #include "ppapi/shared_impl/ppapi_switches.h" | 169 #include "ppapi/shared_impl/ppapi_switches.h" |
| 169 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 170 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
| 170 #include "third_party/icu/source/common/unicode/unistr.h" | 171 #include "third_party/icu/source/common/unicode/unistr.h" |
| 171 #include "third_party/icu/source/i18n/unicode/timezone.h" | 172 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 172 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | |
| 173 #include "third_party/skia/include/core/SkBitmap.h" | 173 #include "third_party/skia/include/core/SkBitmap.h" |
| 174 #include "ui/base/ui_base_switches.h" | 174 #include "ui/base/ui_base_switches.h" |
| 175 #include "ui/events/event_switches.h" | 175 #include "ui/events/event_switches.h" |
| 176 #include "ui/gfx/switches.h" | 176 #include "ui/gfx/switches.h" |
| 177 #include "ui/gl/gl_switches.h" | 177 #include "ui/gl/gl_switches.h" |
| 178 #include "ui/gl/gpu_switching_manager.h" | 178 #include "ui/gl/gpu_switching_manager.h" |
| 179 #include "ui/native_theme/native_theme_switches.h" | 179 #include "ui/native_theme/native_theme_switches.h" |
| 180 | 180 |
| 181 #if defined(OS_ANDROID) | 181 #if defined(OS_ANDROID) |
| 182 #include "content/browser/android/child_process_launcher_android.h" | 182 #include "content/browser/android/child_process_launcher_android.h" |
| (...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 switches::kDisableDirectWrite, | 1562 switches::kDisableDirectWrite, |
| 1563 switches::kDisableWin32kRendererLockDown, | 1563 switches::kDisableWin32kRendererLockDown, |
| 1564 switches::kTraceExportEventsToETW, | 1564 switches::kTraceExportEventsToETW, |
| 1565 #endif | 1565 #endif |
| 1566 #if defined(USE_OZONE) | 1566 #if defined(USE_OZONE) |
| 1567 switches::kOzonePlatform, | 1567 switches::kOzonePlatform, |
| 1568 #endif | 1568 #endif |
| 1569 #if defined(OS_CHROMEOS) | 1569 #if defined(OS_CHROMEOS) |
| 1570 switches::kDisableVaapiAcceleratedVideoEncode, | 1570 switches::kDisableVaapiAcceleratedVideoEncode, |
| 1571 #endif | 1571 #endif |
| 1572 "use-new-edk", // TODO(use_chrome_edk): temporary. | |
| 1573 }; | 1572 }; |
| 1574 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, | 1573 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, |
| 1575 arraysize(kSwitchNames)); | 1574 arraysize(kSwitchNames)); |
| 1576 | 1575 |
| 1577 CopyEnableDisableFeatureFlagsToRenderer(renderer_cmd); | 1576 CopyEnableDisableFeatureFlagsToRenderer(renderer_cmd); |
| 1578 | 1577 |
| 1579 if (browser_cmd.HasSwitch(switches::kTraceStartup) && | 1578 if (browser_cmd.HasSwitch(switches::kTraceStartup) && |
| 1580 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { | 1579 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { |
| 1581 // Pass kTraceStartup switch to renderer only if startup tracing has not | 1580 // Pass kTraceStartup switch to renderer only if startup tracing has not |
| 1582 // finished. | 1581 // finished. |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 // to exit. Child process will be killed in any case during | 2369 // to exit. Child process will be killed in any case during |
| 2371 // child_process_launcher_.reset(). Make sure we will not broadcast | 2370 // child_process_launcher_.reset(). Make sure we will not broadcast |
| 2372 // FrameHostMsg_RenderProcessGone with status | 2371 // FrameHostMsg_RenderProcessGone with status |
| 2373 // TERMINATION_STATUS_STILL_RUNNING, since this will break WebContentsImpl | 2372 // TERMINATION_STATUS_STILL_RUNNING, since this will break WebContentsImpl |
| 2374 // logic. | 2373 // logic. |
| 2375 status = base::TERMINATION_STATUS_PROCESS_CRASHED; | 2374 status = base::TERMINATION_STATUS_PROCESS_CRASHED; |
| 2376 } | 2375 } |
| 2377 } | 2376 } |
| 2378 | 2377 |
| 2379 RendererClosedDetails details(status, exit_code); | 2378 RendererClosedDetails details(status, exit_code); |
| 2380 mojo_application_host_->WillDestroySoon(); | |
| 2381 | 2379 |
| 2382 child_process_launcher_.reset(); | 2380 child_process_launcher_.reset(); |
| 2383 #if USE_ATTACHMENT_BROKER | 2381 #if USE_ATTACHMENT_BROKER |
| 2384 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( | 2382 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
| 2385 channel_.get()); | 2383 channel_.get()); |
| 2386 #endif | 2384 #endif |
| 2387 channel_.reset(); | 2385 channel_.reset(); |
| 2388 while (!queued_messages_.empty()) { | 2386 while (!queued_messages_.empty()) { |
| 2389 delete queued_messages_.front(); | 2387 delete queued_messages_.front(); |
| 2390 queued_messages_.pop(); | 2388 queued_messages_.pop(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 // RenderViews being swapped back in. | 2456 // RenderViews being swapped back in. |
| 2459 // In single process mode, we never shutdown the renderer. | 2457 // In single process mode, we never shutdown the renderer. |
| 2460 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) | 2458 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) |
| 2461 return; | 2459 return; |
| 2462 | 2460 |
| 2463 // Notify any contents that might have swapped out renderers from this | 2461 // Notify any contents that might have swapped out renderers from this |
| 2464 // process. They should not attempt to swap them back in. | 2462 // process. They should not attempt to swap them back in. |
| 2465 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2463 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, |
| 2466 RenderProcessWillExit(this)); | 2464 RenderProcessWillExit(this)); |
| 2467 | 2465 |
| 2468 mojo_application_host_->WillDestroySoon(); | |
| 2469 | |
| 2470 Send(new ChildProcessMsg_Shutdown()); | 2466 Send(new ChildProcessMsg_Shutdown()); |
| 2471 } | 2467 } |
| 2472 | 2468 |
| 2473 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { | 2469 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { |
| 2474 SetSuddenTerminationAllowed(enabled); | 2470 SetSuddenTerminationAllowed(enabled); |
| 2475 } | 2471 } |
| 2476 | 2472 |
| 2477 void RenderProcessHostImpl::UpdateProcessPriority() { | 2473 void RenderProcessHostImpl::UpdateProcessPriority() { |
| 2478 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { | 2474 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { |
| 2479 is_process_backgrounded_ = false; | 2475 is_process_backgrounded_ = false; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2555 // ExtensionService uses this notification to initialize the renderer process | 2551 // ExtensionService uses this notification to initialize the renderer process |
| 2556 // with state that must be there before any JavaScript executes. | 2552 // with state that must be there before any JavaScript executes. |
| 2557 // | 2553 // |
| 2558 // The queued messages contain such things as "navigate". If this notification | 2554 // The queued messages contain such things as "navigate". If this notification |
| 2559 // was after, we can end up executing JavaScript before the initialization | 2555 // was after, we can end up executing JavaScript before the initialization |
| 2560 // happens. | 2556 // happens. |
| 2561 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, | 2557 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 2562 Source<RenderProcessHost>(this), | 2558 Source<RenderProcessHost>(this), |
| 2563 NotificationService::NoDetails()); | 2559 NotificationService::NoDetails()); |
| 2564 | 2560 |
| 2565 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk") && | 2561 if (child_process_launcher_.get()) { |
| 2566 child_process_launcher_.get()) { | |
| 2567 base::ProcessHandle process_handle = | 2562 base::ProcessHandle process_handle = |
| 2568 child_process_launcher_->GetProcess().Handle(); | 2563 child_process_launcher_->GetProcess().Handle(); |
| 2569 mojo::embedder::ScopedPlatformHandle client_pipe = | 2564 mojo::edk::ScopedPlatformHandle client_pipe = |
| 2570 mojo::embedder::ChildProcessLaunched(process_handle); | 2565 mojo::edk::ChildProcessLaunched(process_handle); |
| 2571 Send(new ChildProcessMsg_SetMojoParentPipeHandle( | 2566 Send(new ChildProcessMsg_SetMojoParentPipeHandle( |
| 2572 IPC::GetFileHandleForProcess( | 2567 IPC::GetFileHandleForProcess(client_pipe.release().handle, |
| 2573 #if defined(OS_WIN) | |
| 2574 client_pipe.release().handle, | |
| 2575 #else | |
| 2576 client_pipe.release().fd, | |
| 2577 #endif | |
| 2578 process_handle, true))); | 2568 process_handle, true))); |
| 2579 } | 2569 } |
| 2580 | 2570 |
| 2581 #if defined(MOJO_SHELL_CLIENT) | 2571 #if defined(MOJO_SHELL_CLIENT) |
| 2582 // Send the mojo shell handle to the renderer. | 2572 // Send the mojo shell handle to the renderer. |
| 2583 SendExternalMojoShellHandleToChild(GetHandle(), this); | 2573 SendExternalMojoShellHandleToChild(GetHandle(), this); |
| 2584 #endif | 2574 #endif |
| 2585 | 2575 |
| 2586 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2576 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
| 2587 // This way, Mojo can be safely used from the renderer in response to any | 2577 // This way, Mojo can be safely used from the renderer in response to any |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2792 void RenderProcessHostImpl::GetAudioOutputControllers( | 2782 void RenderProcessHostImpl::GetAudioOutputControllers( |
| 2793 const GetAudioOutputControllersCallback& callback) const { | 2783 const GetAudioOutputControllersCallback& callback) const { |
| 2794 audio_renderer_host()->GetOutputControllers(callback); | 2784 audio_renderer_host()->GetOutputControllers(callback); |
| 2795 } | 2785 } |
| 2796 | 2786 |
| 2797 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { | 2787 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { |
| 2798 return bluetooth_dispatcher_host_.get(); | 2788 return bluetooth_dispatcher_host_.get(); |
| 2799 } | 2789 } |
| 2800 | 2790 |
| 2801 } // namespace content | 2791 } // namespace content |
| OLD | NEW |