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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "content/child/runtime_features.h" | 65 #include "content/child/runtime_features.h" |
66 #include "content/child/thread_safe_sender.h" | 66 #include "content/child/thread_safe_sender.h" |
67 #include "content/child/web_database_observer_impl.h" | 67 #include "content/child/web_database_observer_impl.h" |
68 #include "content/child/worker_thread_registry.h" | 68 #include "content/child/worker_thread_registry.h" |
69 #include "content/common/child_process_messages.h" | 69 #include "content/common/child_process_messages.h" |
70 #include "content/common/content_constants_internal.h" | 70 #include "content/common/content_constants_internal.h" |
71 #include "content/common/database_messages.h" | 71 #include "content/common/database_messages.h" |
72 #include "content/common/dom_storage/dom_storage_messages.h" | 72 #include "content/common/dom_storage/dom_storage_messages.h" |
73 #include "content/common/frame_messages.h" | 73 #include "content/common/frame_messages.h" |
74 #include "content/common/gpu/client/context_provider_command_buffer.h" | 74 #include "content/common/gpu/client/context_provider_command_buffer.h" |
75 #include "content/common/gpu/client/gpu_channel_host.h" | |
76 #include "content/common/gpu_process_launch_causes.h" | 75 #include "content/common/gpu_process_launch_causes.h" |
77 #include "content/common/render_frame_setup.mojom.h" | 76 #include "content/common/render_frame_setup.mojom.h" |
78 #include "content/common/render_process_messages.h" | 77 #include "content/common/render_process_messages.h" |
79 #include "content/common/resource_messages.h" | 78 #include "content/common/resource_messages.h" |
80 #include "content/common/service_worker/embedded_worker_setup.mojom.h" | 79 #include "content/common/service_worker/embedded_worker_setup.mojom.h" |
81 #include "content/common/view_messages.h" | 80 #include "content/common/view_messages.h" |
82 #include "content/common/worker_messages.h" | 81 #include "content/common/worker_messages.h" |
83 #include "content/public/common/content_constants.h" | 82 #include "content/public/common/content_constants.h" |
84 #include "content/public/common/content_paths.h" | 83 #include "content/public/common/content_paths.h" |
85 #include "content/public/common/content_switches.h" | 84 #include "content/public/common/content_switches.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 #include "content/renderer/render_process_impl.h" | 120 #include "content/renderer/render_process_impl.h" |
122 #include "content/renderer/render_view_impl.h" | 121 #include "content/renderer/render_view_impl.h" |
123 #include "content/renderer/renderer_blink_platform_impl.h" | 122 #include "content/renderer/renderer_blink_platform_impl.h" |
124 #include "content/renderer/scheduler/resource_dispatch_throttler.h" | 123 #include "content/renderer/scheduler/resource_dispatch_throttler.h" |
125 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 124 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
126 #include "content/renderer/service_worker/service_worker_context_client.h" | 125 #include "content/renderer/service_worker/service_worker_context_client.h" |
127 #include "content/renderer/service_worker/service_worker_context_message_filter.
h" | 126 #include "content/renderer/service_worker/service_worker_context_message_filter.
h" |
128 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 127 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
129 #include "gin/public/debug.h" | 128 #include "gin/public/debug.h" |
130 #include "gpu/GLES2/gl2extchromium.h" | 129 #include "gpu/GLES2/gl2extchromium.h" |
| 130 #include "gpu/ipc/client/gpu_channel_host.h" |
131 #include "ipc/ipc_channel_handle.h" | 131 #include "ipc/ipc_channel_handle.h" |
132 #include "ipc/ipc_platform_file.h" | 132 #include "ipc/ipc_platform_file.h" |
133 #include "ipc/mojo/ipc_channel_mojo.h" | 133 #include "ipc/mojo/ipc_channel_mojo.h" |
134 #include "media/base/audio_hardware_config.h" | 134 #include "media/base/audio_hardware_config.h" |
135 #include "media/base/media.h" | 135 #include "media/base/media.h" |
136 #include "media/renderers/gpu_video_accelerator_factories.h" | 136 #include "media/renderers/gpu_video_accelerator_factories.h" |
137 #include "mojo/common/common_type_converters.h" | 137 #include "mojo/common/common_type_converters.h" |
138 #include "mojo/public/cpp/bindings/strong_binding.h" | 138 #include "mojo/public/cpp/bindings/strong_binding.h" |
139 #include "net/base/net_errors.h" | 139 #include "net/base/net_errors.h" |
140 #include "net/base/port_util.h" | 140 #include "net/base/port_util.h" |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 } | 1485 } |
1486 } | 1486 } |
1487 } | 1487 } |
1488 | 1488 |
1489 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1489 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
1490 | 1490 |
1491 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = | 1491 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = |
1492 GetMediaThreadTaskRunner(); | 1492 GetMediaThreadTaskRunner(); |
1493 scoped_refptr<ContextProviderCommandBuffer> shared_context_provider = | 1493 scoped_refptr<ContextProviderCommandBuffer> shared_context_provider = |
1494 SharedWorkerContextProvider(); | 1494 SharedWorkerContextProvider(); |
1495 scoped_refptr<GpuChannelHost> gpu_channel_host = GetGpuChannel(); | 1495 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = GetGpuChannel(); |
1496 if (shared_context_provider && gpu_channel_host) { | 1496 if (shared_context_provider && gpu_channel_host) { |
1497 const bool enable_video_accelerator = | 1497 const bool enable_video_accelerator = |
1498 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); | 1498 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); |
1499 const bool enable_gpu_memory_buffer_video_frames = | 1499 const bool enable_gpu_memory_buffer_video_frames = |
1500 #if defined(OS_MACOSX) || defined(OS_LINUX) | 1500 #if defined(OS_MACOSX) || defined(OS_LINUX) |
1501 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames); | 1501 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames); |
1502 #else | 1502 #else |
1503 cmd_line->HasSwitch(switches::kEnableGpuMemoryBufferVideoFrames); | 1503 cmd_line->HasSwitch(switches::kEnableGpuMemoryBufferVideoFrames); |
1504 #endif | 1504 #endif |
1505 std::vector<unsigned> image_texture_targets; | 1505 std::vector<unsigned> image_texture_targets; |
(...skipping 22 matching lines...) Expand all Loading... |
1528 gpu::gles2::ContextCreationAttribHelper attributes; | 1528 gpu::gles2::ContextCreationAttribHelper attributes; |
1529 attributes.alpha_size = -1; | 1529 attributes.alpha_size = -1; |
1530 attributes.depth_size = 0; | 1530 attributes.depth_size = 0; |
1531 attributes.stencil_size = 0; | 1531 attributes.stencil_size = 0; |
1532 attributes.samples = 0; | 1532 attributes.samples = 0; |
1533 attributes.sample_buffers = 0; | 1533 attributes.sample_buffers = 0; |
1534 attributes.bind_generates_resource = false; | 1534 attributes.bind_generates_resource = false; |
1535 attributes.lose_context_when_out_of_memory = true; | 1535 attributes.lose_context_when_out_of_memory = true; |
1536 bool share_resources = true; | 1536 bool share_resources = true; |
1537 bool automatic_flushes = false; | 1537 bool automatic_flushes = false; |
1538 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1538 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
1539 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1539 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
1540 return make_scoped_ptr( | 1540 return make_scoped_ptr( |
1541 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1541 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1542 gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, | 1542 gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, |
1543 share_resources, automatic_flushes, | 1543 share_resources, automatic_flushes, |
1544 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 1544 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), |
1545 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), NULL)); | 1545 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), NULL)); |
1546 } | 1546 } |
1547 | 1547 |
1548 scoped_refptr<cc_blink::ContextProviderWebContext> | 1548 scoped_refptr<cc_blink::ContextProviderWebContext> |
(...skipping 28 matching lines...) Expand all Loading... |
1577 DCHECK(IsMainThread()); | 1577 DCHECK(IsMainThread()); |
1578 if (g_stream_texture_factory_override.Get()) { | 1578 if (g_stream_texture_factory_override.Get()) { |
1579 stream_texture_factory_ = g_stream_texture_factory_override.Get(); | 1579 stream_texture_factory_ = g_stream_texture_factory_override.Get(); |
1580 } else if (!stream_texture_factory_.get() || | 1580 } else if (!stream_texture_factory_.get() || |
1581 stream_texture_factory_->ContextGL() | 1581 stream_texture_factory_->ContextGL() |
1582 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 1582 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
1583 if (!SharedMainThreadContextProvider().get()) { | 1583 if (!SharedMainThreadContextProvider().get()) { |
1584 stream_texture_factory_ = NULL; | 1584 stream_texture_factory_ = NULL; |
1585 return NULL; | 1585 return NULL; |
1586 } | 1586 } |
1587 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1587 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
1588 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE)); | 1588 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE)); |
1589 if (!gpu_channel_host.get()) { | 1589 if (!gpu_channel_host.get()) { |
1590 LOG(ERROR) << "Failed to establish GPU channel for media player"; | 1590 LOG(ERROR) << "Failed to establish GPU channel for media player"; |
1591 stream_texture_factory_ = NULL; | 1591 stream_texture_factory_ = NULL; |
1592 } else { | 1592 } else { |
1593 stream_texture_factory_ = StreamTextureFactoryImpl::Create( | 1593 stream_texture_factory_ = StreamTextureFactoryImpl::Create( |
1594 shared_main_thread_contexts_, gpu_channel_host.get()); | 1594 shared_main_thread_contexts_, gpu_channel_host.get()); |
1595 } | 1595 } |
1596 } | 1596 } |
1597 return stream_texture_factory_; | 1597 return stream_texture_factory_; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 RenderViewZoomer zoomer(scheme, host, zoom_level); | 1844 RenderViewZoomer zoomer(scheme, host, zoom_level); |
1845 RenderView::ForEach(&zoomer); | 1845 RenderView::ForEach(&zoomer); |
1846 } | 1846 } |
1847 | 1847 |
1848 void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) { | 1848 void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) { |
1849 CompositorDependencies* compositor_deps = this; | 1849 CompositorDependencies* compositor_deps = this; |
1850 // When bringing in render_view, also bring in webkit's glue and jsbindings. | 1850 // When bringing in render_view, also bring in webkit's glue and jsbindings. |
1851 RenderViewImpl::Create(compositor_deps, params, false); | 1851 RenderViewImpl::Create(compositor_deps, params, false); |
1852 } | 1852 } |
1853 | 1853 |
1854 GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync( | 1854 gpu::GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync( |
1855 CauseForGpuLaunch cause_for_gpu_launch) { | 1855 CauseForGpuLaunch cause_for_gpu_launch) { |
1856 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); | 1856 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); |
1857 | 1857 |
1858 if (gpu_channel_.get()) { | 1858 if (gpu_channel_.get()) { |
1859 // Do nothing if we already have a GPU channel or are already | 1859 // Do nothing if we already have a GPU channel or are already |
1860 // establishing one. | 1860 // establishing one. |
1861 if (!gpu_channel_->IsLost()) | 1861 if (!gpu_channel_->IsLost()) |
1862 return gpu_channel_.get(); | 1862 return gpu_channel_.get(); |
1863 | 1863 |
1864 // Recreate the channel if it has been lost. | 1864 // Recreate the channel if it has been lost. |
(...skipping 14 matching lines...) Expand all Loading... |
1879 // Otherwise cancel the connection. | 1879 // Otherwise cancel the connection. |
1880 return NULL; | 1880 return NULL; |
1881 } | 1881 } |
1882 | 1882 |
1883 GetContentClient()->SetGpuInfo(gpu_info); | 1883 GetContentClient()->SetGpuInfo(gpu_info); |
1884 | 1884 |
1885 // Cache some variables that are needed on the compositor thread for our | 1885 // Cache some variables that are needed on the compositor thread for our |
1886 // implementation of GpuChannelHostFactory. | 1886 // implementation of GpuChannelHostFactory. |
1887 io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); | 1887 io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); |
1888 | 1888 |
1889 gpu_channel_ = | 1889 gpu_channel_ = gpu::GpuChannelHost::Create( |
1890 GpuChannelHost::Create(this, | 1890 this, client_id, gpu_info, channel_handle, |
1891 client_id, | 1891 ChildProcess::current()->GetShutDownEvent(), gpu_memory_buffer_manager()); |
1892 gpu_info, | |
1893 channel_handle, | |
1894 ChildProcess::current()->GetShutDownEvent(), | |
1895 gpu_memory_buffer_manager()); | |
1896 return gpu_channel_.get(); | 1892 return gpu_channel_.get(); |
1897 } | 1893 } |
1898 | 1894 |
1899 blink::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( | 1895 blink::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( |
1900 blink::WebMediaStreamCenterClient* client) { | 1896 blink::WebMediaStreamCenterClient* client) { |
1901 #if defined(ENABLE_WEBRTC) | 1897 #if defined(ENABLE_WEBRTC) |
1902 if (!media_stream_center_) { | 1898 if (!media_stream_center_) { |
1903 media_stream_center_ = GetContentClient()->renderer() | 1899 media_stream_center_ = GetContentClient()->renderer() |
1904 ->OverrideCreateWebMediaStreamCenter(client); | 1900 ->OverrideCreateWebMediaStreamCenter(client); |
1905 if (!media_stream_center_) { | 1901 if (!media_stream_center_) { |
1906 scoped_ptr<MediaStreamCenter> media_stream_center( | 1902 scoped_ptr<MediaStreamCenter> media_stream_center( |
1907 new MediaStreamCenter(client, GetPeerConnectionDependencyFactory())); | 1903 new MediaStreamCenter(client, GetPeerConnectionDependencyFactory())); |
1908 media_stream_center_ = media_stream_center.release(); | 1904 media_stream_center_ = media_stream_center.release(); |
1909 } | 1905 } |
1910 } | 1906 } |
1911 #endif | 1907 #endif |
1912 return media_stream_center_; | 1908 return media_stream_center_; |
1913 } | 1909 } |
1914 | 1910 |
1915 #if defined(ENABLE_WEBRTC) | 1911 #if defined(ENABLE_WEBRTC) |
1916 PeerConnectionDependencyFactory* | 1912 PeerConnectionDependencyFactory* |
1917 RenderThreadImpl::GetPeerConnectionDependencyFactory() { | 1913 RenderThreadImpl::GetPeerConnectionDependencyFactory() { |
1918 return peer_connection_factory_.get(); | 1914 return peer_connection_factory_.get(); |
1919 } | 1915 } |
1920 #endif | 1916 #endif |
1921 | 1917 |
1922 GpuChannelHost* RenderThreadImpl::GetGpuChannel() { | 1918 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { |
1923 if (!gpu_channel_.get()) | 1919 if (!gpu_channel_.get()) |
1924 return NULL; | 1920 return NULL; |
1925 | 1921 |
1926 if (gpu_channel_->IsLost()) | 1922 if (gpu_channel_->IsLost()) |
1927 return NULL; | 1923 return NULL; |
1928 | 1924 |
1929 return gpu_channel_.get(); | 1925 return gpu_channel_.get(); |
1930 } | 1926 } |
1931 | 1927 |
1932 #if defined(ENABLE_PLUGINS) | 1928 #if defined(ENABLE_PLUGINS) |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 } | 2174 } |
2179 | 2175 |
2180 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2176 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
2181 size_t erased = | 2177 size_t erased = |
2182 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2178 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
2183 routing_id_); | 2179 routing_id_); |
2184 DCHECK_EQ(1u, erased); | 2180 DCHECK_EQ(1u, erased); |
2185 } | 2181 } |
2186 | 2182 |
2187 } // namespace content | 2183 } // namespace content |
OLD | NEW |