| 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 <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/allocator/allocator_extension.h" | 12 #include "base/allocator/allocator_extension.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/weak_ptr.h" |
| 17 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
| 18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 19 #include "base/metrics/stats_table.h" | 20 #include "base/metrics/stats_table.h" |
| 20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 21 #include "base/shared_memory.h" | 22 #include "base/shared_memory.h" |
| 22 #include "base/string16.h" | 23 #include "base/string16.h" |
| 23 #include "base/string_number_conversions.h" // Temporary | 24 #include "base/string_number_conversions.h" // Temporary |
| 24 #include "base/threading/thread_local.h" | 25 #include "base/threading/thread_local.h" |
| 25 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 26 #include "base/values.h" | 27 #include "base/values.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" | 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" |
| 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" | 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" |
| 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
| 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorkerReposi
tory.h" | 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorkerReposi
tory.h" |
| 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 97 #include "ui/base/layout.h" | 98 #include "ui/base/layout.h" |
| 98 #include "ui/base/ui_base_switches.h" | 99 #include "ui/base/ui_base_switches.h" |
| 99 #include "v8/include/v8.h" | 100 #include "v8/include/v8.h" |
| 100 #include "webkit/glue/webkit_glue.h" | 101 #include "webkit/glue/webkit_glue.h" |
| 102 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
| 101 | 103 |
| 102 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
| 103 #include <windows.h> | 105 #include <windows.h> |
| 104 #include <objbase.h> | 106 #include <objbase.h> |
| 105 #include "base/win/scoped_com_initializer.h" | 107 #include "base/win/scoped_com_initializer.h" |
| 106 #else | 108 #else |
| 107 // TODO(port) | 109 // TODO(port) |
| 108 #include "base/memory/scoped_handle.h" | 110 #include "base/memory/scoped_handle.h" |
| 109 #include "content/common/np_channel_base.h" | 111 #include "content/common/np_channel_base.h" |
| 110 #endif | 112 #endif |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 v8::V8::SetCreateHistogramFunction(CreateHistogram); | 276 v8::V8::SetCreateHistogramFunction(CreateHistogram); |
| 275 } | 277 } |
| 276 } | 278 } |
| 277 | 279 |
| 278 RenderThreadImpl* RenderThreadImpl::current() { | 280 RenderThreadImpl* RenderThreadImpl::current() { |
| 279 return lazy_tls.Pointer()->Get(); | 281 return lazy_tls.Pointer()->Get(); |
| 280 } | 282 } |
| 281 | 283 |
| 282 // When we run plugins in process, we actually run them on the render thread, | 284 // When we run plugins in process, we actually run them on the render thread, |
| 283 // which means that we need to make the render thread pump UI events. | 285 // which means that we need to make the render thread pump UI events. |
| 284 RenderThreadImpl::RenderThreadImpl() { | 286 RenderThreadImpl::RenderThreadImpl() |
| 287 : ALLOW_THIS_IN_INITIALIZER_LIST(shared_context_main_thread_(this)), |
| 288 ALLOW_THIS_IN_INITIALIZER_LIST(shared_context_compositor_thread_(this)) { |
| 285 Init(); | 289 Init(); |
| 286 } | 290 } |
| 287 | 291 |
| 288 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) | 292 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) |
| 289 : ChildThread(channel_name) { | 293 : ChildThread(channel_name), |
| 294 shared_context_main_thread_(this), |
| 295 shared_context_compositor_thread_(this) { |
| 290 Init(); | 296 Init(); |
| 291 } | 297 } |
| 292 | 298 |
| 293 void RenderThreadImpl::Init() { | 299 void RenderThreadImpl::Init() { |
| 294 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); | 300 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); |
| 295 | 301 |
| 296 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); | 302 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); |
| 297 v8::V8::SetCreateHistogramFunction(CreateHistogram); | 303 v8::V8::SetCreateHistogramFunction(CreateHistogram); |
| 298 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample); | 304 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample); |
| 299 | 305 |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 gpu_channel_ = new GpuChannelHost(this, 0, client_id); | 1123 gpu_channel_ = new GpuChannelHost(this, 0, client_id); |
| 1118 gpu_channel_->set_gpu_info(gpu_info); | 1124 gpu_channel_->set_gpu_info(gpu_info); |
| 1119 GetContentClient()->SetGpuInfo(gpu_info); | 1125 GetContentClient()->SetGpuInfo(gpu_info); |
| 1120 | 1126 |
| 1121 // Connect to the GPU process if a channel name was received. | 1127 // Connect to the GPU process if a channel name was received. |
| 1122 gpu_channel_->Connect(channel_handle); | 1128 gpu_channel_->Connect(channel_handle); |
| 1123 | 1129 |
| 1124 return GetGpuChannel(); | 1130 return GetGpuChannel(); |
| 1125 } | 1131 } |
| 1126 | 1132 |
| 1133 WebKit::WebGraphicsContext3D* RenderThreadImpl:: |
| 1134 OffscreenContext3dForMainThread() { |
| 1135 DCHECK(IsMainThread()); |
| 1136 return shared_context_main_thread_.Context3d(); |
| 1137 } |
| 1138 WebKit::WebGraphicsContext3D* RenderThreadImpl:: |
| 1139 OffscreenContext3dForCompositorThread() { |
| 1140 DCHECK(IsMainThread()); |
| 1141 return shared_context_compositor_thread_.Context3d(); |
| 1142 } |
| 1143 |
| 1144 GrContext* RenderThreadImpl::OffscreenGrContextForMainThread() { |
| 1145 DCHECK(IsMainThread()); |
| 1146 return shared_context_main_thread_.GrContext(); |
| 1147 } |
| 1148 |
| 1149 GrContext* RenderThreadImpl::OffscreenGrContextForCompositorThread() { |
| 1150 DCHECK(IsMainThread()); |
| 1151 return shared_context_compositor_thread_.GrContext(); |
| 1152 } |
| 1153 |
| 1154 WebKit::WebGraphicsContext3D* RenderThreadImpl::CreateOffscreenContext() { |
| 1155 WebKit::WebGraphicsContext3D::Attributes attributes; |
| 1156 attributes.shareResources = true; |
| 1157 attributes.depth = false; |
| 1158 attributes.stencil = false; |
| 1159 attributes.antialias = false; |
| 1160 attributes.noAutomaticFlushes = true; |
| 1161 |
| 1162 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { |
| 1163 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( |
| 1164 attributes, false); |
| 1165 } |
| 1166 |
| 1167 GURL url("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"); |
| 1168 return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 1169 this, attributes, url); |
| 1170 } |
| 1171 |
| 1127 WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( | 1172 WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( |
| 1128 WebKit::WebMediaStreamCenterClient* client) { | 1173 WebKit::WebMediaStreamCenterClient* client) { |
| 1129 #if defined(OS_ANDROID) | 1174 #if defined(OS_ANDROID) |
| 1130 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1175 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 1131 switches::kEnableWebRTC)) | 1176 switches::kEnableWebRTC)) |
| 1132 return NULL; | 1177 return NULL; |
| 1133 #endif | 1178 #endif |
| 1134 | 1179 |
| 1135 #if defined(ENABLE_WEBRTC) | 1180 #if defined(ENABLE_WEBRTC) |
| 1136 if (!media_stream_center_) | 1181 if (!media_stream_center_) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 | 1241 |
| 1197 void RenderThreadImpl::SetFlingCurveParameters( | 1242 void RenderThreadImpl::SetFlingCurveParameters( |
| 1198 const std::vector<float>& new_touchpad, | 1243 const std::vector<float>& new_touchpad, |
| 1199 const std::vector<float>& new_touchscreen) { | 1244 const std::vector<float>& new_touchscreen) { |
| 1200 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1245 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
| 1201 new_touchscreen); | 1246 new_touchscreen); |
| 1202 | 1247 |
| 1203 } | 1248 } |
| 1204 | 1249 |
| 1205 } // namespace content | 1250 } // namespace content |
| OLD | NEW |