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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 #include "gpu/command_buffer/client/gpu_switches.h" | 158 #include "gpu/command_buffer/client/gpu_switches.h" |
159 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 159 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
160 #include "gpu/command_buffer/service/gpu_switches.h" | 160 #include "gpu/command_buffer/service/gpu_switches.h" |
161 #include "ipc/attachment_broker.h" | 161 #include "ipc/attachment_broker.h" |
162 #include "ipc/attachment_broker_privileged.h" | 162 #include "ipc/attachment_broker_privileged.h" |
163 #include "ipc/ipc_channel.h" | 163 #include "ipc/ipc_channel.h" |
164 #include "ipc/ipc_logging.h" | 164 #include "ipc/ipc_logging.h" |
165 #include "ipc/ipc_switches.h" | 165 #include "ipc/ipc_switches.h" |
166 #include "ipc/mojo/ipc_channel_mojo.h" | 166 #include "ipc/mojo/ipc_channel_mojo.h" |
167 #include "media/base/media_switches.h" | 167 #include "media/base/media_switches.h" |
| 168 #include "mojo/edk/embedder/embedder.h" |
168 #include "net/url_request/url_request_context_getter.h" | 169 #include "net/url_request/url_request_context_getter.h" |
169 #include "ppapi/shared_impl/ppapi_switches.h" | 170 #include "ppapi/shared_impl/ppapi_switches.h" |
170 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 171 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
171 #include "third_party/icu/source/common/unicode/unistr.h" | 172 #include "third_party/icu/source/common/unicode/unistr.h" |
172 #include "third_party/icu/source/i18n/unicode/timezone.h" | 173 #include "third_party/icu/source/i18n/unicode/timezone.h" |
173 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | |
174 #include "third_party/skia/include/core/SkBitmap.h" | 174 #include "third_party/skia/include/core/SkBitmap.h" |
175 #include "ui/base/ui_base_switches.h" | 175 #include "ui/base/ui_base_switches.h" |
176 #include "ui/events/event_switches.h" | 176 #include "ui/events/event_switches.h" |
177 #include "ui/gfx/switches.h" | 177 #include "ui/gfx/switches.h" |
178 #include "ui/gl/gl_switches.h" | 178 #include "ui/gl/gl_switches.h" |
179 #include "ui/gl/gpu_switching_manager.h" | 179 #include "ui/gl/gpu_switching_manager.h" |
180 #include "ui/native_theme/native_theme_switches.h" | 180 #include "ui/native_theme/native_theme_switches.h" |
181 | 181 |
182 #if defined(OS_ANDROID) | 182 #if defined(OS_ANDROID) |
183 #include "content/browser/android/child_process_launcher_android.h" | 183 #include "content/browser/android/child_process_launcher_android.h" |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 switches::kDisableDirectWrite, | 1521 switches::kDisableDirectWrite, |
1522 switches::kDisableWin32kRendererLockDown, | 1522 switches::kDisableWin32kRendererLockDown, |
1523 switches::kTraceExportEventsToETW, | 1523 switches::kTraceExportEventsToETW, |
1524 #endif | 1524 #endif |
1525 #if defined(USE_OZONE) | 1525 #if defined(USE_OZONE) |
1526 switches::kOzonePlatform, | 1526 switches::kOzonePlatform, |
1527 #endif | 1527 #endif |
1528 #if defined(OS_CHROMEOS) | 1528 #if defined(OS_CHROMEOS) |
1529 switches::kDisableVaapiAcceleratedVideoEncode, | 1529 switches::kDisableVaapiAcceleratedVideoEncode, |
1530 #endif | 1530 #endif |
1531 "use-new-edk", // TODO(use_chrome_edk): temporary. | |
1532 }; | 1531 }; |
1533 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, | 1532 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, |
1534 arraysize(kSwitchNames)); | 1533 arraysize(kSwitchNames)); |
1535 | 1534 |
1536 CopyEnableDisableFeatureFlagsToRenderer(renderer_cmd); | 1535 CopyEnableDisableFeatureFlagsToRenderer(renderer_cmd); |
1537 | 1536 |
1538 if (browser_cmd.HasSwitch(switches::kTraceStartup) && | 1537 if (browser_cmd.HasSwitch(switches::kTraceStartup) && |
1539 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { | 1538 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { |
1540 // Pass kTraceStartup switch to renderer only if startup tracing has not | 1539 // Pass kTraceStartup switch to renderer only if startup tracing has not |
1541 // finished. | 1540 // finished. |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 // to exit. Child process will be killed in any case during | 2332 // to exit. Child process will be killed in any case during |
2334 // child_process_launcher_.reset(). Make sure we will not broadcast | 2333 // child_process_launcher_.reset(). Make sure we will not broadcast |
2335 // FrameHostMsg_RenderProcessGone with status | 2334 // FrameHostMsg_RenderProcessGone with status |
2336 // TERMINATION_STATUS_STILL_RUNNING, since this will break WebContentsImpl | 2335 // TERMINATION_STATUS_STILL_RUNNING, since this will break WebContentsImpl |
2337 // logic. | 2336 // logic. |
2338 status = base::TERMINATION_STATUS_PROCESS_CRASHED; | 2337 status = base::TERMINATION_STATUS_PROCESS_CRASHED; |
2339 } | 2338 } |
2340 } | 2339 } |
2341 | 2340 |
2342 RendererClosedDetails details(status, exit_code); | 2341 RendererClosedDetails details(status, exit_code); |
2343 mojo_application_host_->WillDestroySoon(); | |
2344 | 2342 |
2345 child_process_launcher_.reset(); | 2343 child_process_launcher_.reset(); |
2346 #if USE_ATTACHMENT_BROKER | 2344 #if USE_ATTACHMENT_BROKER |
2347 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( | 2345 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
2348 channel_.get()); | 2346 channel_.get()); |
2349 #endif | 2347 #endif |
2350 channel_.reset(); | 2348 channel_.reset(); |
2351 while (!queued_messages_.empty()) { | 2349 while (!queued_messages_.empty()) { |
2352 delete queued_messages_.front(); | 2350 delete queued_messages_.front(); |
2353 queued_messages_.pop(); | 2351 queued_messages_.pop(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2421 // RenderViews being swapped back in. | 2419 // RenderViews being swapped back in. |
2422 // In single process mode, we never shutdown the renderer. | 2420 // In single process mode, we never shutdown the renderer. |
2423 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) | 2421 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) |
2424 return; | 2422 return; |
2425 | 2423 |
2426 // Notify any contents that might have swapped out renderers from this | 2424 // Notify any contents that might have swapped out renderers from this |
2427 // process. They should not attempt to swap them back in. | 2425 // process. They should not attempt to swap them back in. |
2428 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2426 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, |
2429 RenderProcessWillExit(this)); | 2427 RenderProcessWillExit(this)); |
2430 | 2428 |
2431 mojo_application_host_->WillDestroySoon(); | |
2432 | |
2433 Send(new ChildProcessMsg_Shutdown()); | 2429 Send(new ChildProcessMsg_Shutdown()); |
2434 } | 2430 } |
2435 | 2431 |
2436 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { | 2432 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { |
2437 SetSuddenTerminationAllowed(enabled); | 2433 SetSuddenTerminationAllowed(enabled); |
2438 } | 2434 } |
2439 | 2435 |
2440 void RenderProcessHostImpl::UpdateProcessPriority() { | 2436 void RenderProcessHostImpl::UpdateProcessPriority() { |
2441 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { | 2437 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { |
2442 is_process_backgrounded_ = false; | 2438 is_process_backgrounded_ = false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 // ExtensionService uses this notification to initialize the renderer process | 2514 // ExtensionService uses this notification to initialize the renderer process |
2519 // with state that must be there before any JavaScript executes. | 2515 // with state that must be there before any JavaScript executes. |
2520 // | 2516 // |
2521 // The queued messages contain such things as "navigate". If this notification | 2517 // The queued messages contain such things as "navigate". If this notification |
2522 // was after, we can end up executing JavaScript before the initialization | 2518 // was after, we can end up executing JavaScript before the initialization |
2523 // happens. | 2519 // happens. |
2524 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, | 2520 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, |
2525 Source<RenderProcessHost>(this), | 2521 Source<RenderProcessHost>(this), |
2526 NotificationService::NoDetails()); | 2522 NotificationService::NoDetails()); |
2527 | 2523 |
2528 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk") && | 2524 if (child_process_launcher_.get()) { |
2529 child_process_launcher_.get()) { | |
2530 base::ProcessHandle process_handle = | 2525 base::ProcessHandle process_handle = |
2531 child_process_launcher_->GetProcess().Handle(); | 2526 child_process_launcher_->GetProcess().Handle(); |
2532 mojo::embedder::ScopedPlatformHandle client_pipe; | 2527 mojo::edk::ScopedPlatformHandle client_pipe; |
2533 #if defined(MOJO_SHELL_CLIENT) | 2528 #if defined(MOJO_SHELL_CLIENT) |
2534 if (IsRunningInMojoShell()) { | 2529 if (IsRunningInMojoShell()) { |
2535 client_pipe = RegisterProcessWithBroker( | 2530 client_pipe = RegisterProcessWithBroker( |
2536 child_process_launcher_->GetProcess().Pid()); | 2531 child_process_launcher_->GetProcess().Pid()); |
2537 } else | 2532 } else |
2538 #endif | 2533 #endif |
2539 { | 2534 { |
2540 client_pipe = mojo::embedder::ChildProcessLaunched(process_handle); | 2535 client_pipe = mojo::edk::ChildProcessLaunched(process_handle); |
2541 } | 2536 } |
2542 Send(new ChildProcessMsg_SetMojoParentPipeHandle( | 2537 Send(new ChildProcessMsg_SetMojoParentPipeHandle( |
2543 IPC::GetFileHandleForProcess( | 2538 IPC::GetFileHandleForProcess(client_pipe.release().handle, |
2544 #if defined(OS_WIN) | |
2545 client_pipe.release().handle, | |
2546 #else | |
2547 client_pipe.release().fd, | |
2548 #endif | |
2549 process_handle, true))); | 2539 process_handle, true))); |
2550 } | 2540 } |
2551 | 2541 |
2552 #if defined(MOJO_SHELL_CLIENT) | 2542 #if defined(MOJO_SHELL_CLIENT) |
2553 // Send the mojo shell handle to the renderer. | 2543 // Send the mojo shell handle to the renderer. |
2554 SendExternalMojoShellHandleToChild(GetHandle(), this); | 2544 SendExternalMojoShellHandleToChild(GetHandle(), this); |
2555 #endif | 2545 #endif |
2556 | 2546 |
2557 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2547 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
2558 // This way, Mojo can be safely used from the renderer in response to any | 2548 // 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... |
2763 void RenderProcessHostImpl::GetAudioOutputControllers( | 2753 void RenderProcessHostImpl::GetAudioOutputControllers( |
2764 const GetAudioOutputControllersCallback& callback) const { | 2754 const GetAudioOutputControllersCallback& callback) const { |
2765 audio_renderer_host()->GetOutputControllers(callback); | 2755 audio_renderer_host()->GetOutputControllers(callback); |
2766 } | 2756 } |
2767 | 2757 |
2768 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { | 2758 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { |
2769 return bluetooth_dispatcher_host_.get(); | 2759 return bluetooth_dispatcher_host_.get(); |
2770 } | 2760 } |
2771 | 2761 |
2772 } // namespace content | 2762 } // namespace content |
OLD | NEW |