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/renderer_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/numerics/safe_conversions.h" | 17 #include "base/numerics/safe_conversions.h" |
17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "cc/blink/context_provider_web_context.h" | 23 #include "cc/blink/context_provider_web_context.h" |
23 #include "components/scheduler/child/web_scheduler_impl.h" | 24 #include "components/scheduler/child/web_scheduler_impl.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 294 } |
294 | 295 |
295 //------------------------------------------------------------------------------ | 296 //------------------------------------------------------------------------------ |
296 | 297 |
297 blink::WebURLLoader* RendererBlinkPlatformImpl::createURLLoader() { | 298 blink::WebURLLoader* RendererBlinkPlatformImpl::createURLLoader() { |
298 ChildThreadImpl* child_thread = ChildThreadImpl::current(); | 299 ChildThreadImpl* child_thread = ChildThreadImpl::current(); |
299 // There may be no child thread in RenderViewTests. These tests can still use | 300 // There may be no child thread in RenderViewTests. These tests can still use |
300 // data URLs to bypass the ResourceDispatcher. | 301 // data URLs to bypass the ResourceDispatcher. |
301 return new content::WebURLLoaderImpl( | 302 return new content::WebURLLoaderImpl( |
302 child_thread ? child_thread->resource_dispatcher() : NULL, | 303 child_thread ? child_thread->resource_dispatcher() : NULL, |
303 make_scoped_ptr(currentThread()->getWebTaskRunner()->clone())); | 304 base::WrapUnique(currentThread()->getWebTaskRunner()->clone())); |
304 } | 305 } |
305 | 306 |
306 blink::WebThread* RendererBlinkPlatformImpl::currentThread() { | 307 blink::WebThread* RendererBlinkPlatformImpl::currentThread() { |
307 if (main_thread_->isCurrentThread()) | 308 if (main_thread_->isCurrentThread()) |
308 return main_thread_.get(); | 309 return main_thread_.get(); |
309 return BlinkPlatformImpl::currentThread(); | 310 return BlinkPlatformImpl::currentThread(); |
310 } | 311 } |
311 | 312 |
312 blink::BlameContext* RendererBlinkPlatformImpl::topLevelBlameContext() { | 313 blink::BlameContext* RendererBlinkPlatformImpl::topLevelBlameContext() { |
313 return &top_level_blame_context_; | 314 return &top_level_blame_context_; |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL1; | 1047 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL1; |
1047 else if (web_attributes.webGLVersion == 2) | 1048 else if (web_attributes.webGLVersion == 2) |
1048 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL2; | 1049 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL2; |
1049 | 1050 |
1050 bool share_resources = false; | 1051 bool share_resources = false; |
1051 bool automatic_flushes = true; | 1052 bool automatic_flushes = true; |
1052 // Prefer discrete GPU for WebGL. | 1053 // Prefer discrete GPU for WebGL. |
1053 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 1054 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
1054 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 1055 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
1055 | 1056 |
1056 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 1057 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
1057 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1058 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1058 gpu_channel_host.get(), attributes, gpu_preference, share_resources, | 1059 gpu_channel_host.get(), attributes, gpu_preference, share_resources, |
1059 automatic_flushes, GURL(top_document_web_url), limits, | 1060 automatic_flushes, GURL(top_document_web_url), limits, |
1060 share_context)); | 1061 share_context)); |
1061 scoped_refptr<ContextProviderCommandBuffer> provider = | 1062 scoped_refptr<ContextProviderCommandBuffer> provider = |
1062 ContextProviderCommandBuffer::Create(std::move(context), | 1063 ContextProviderCommandBuffer::Create(std::move(context), |
1063 RENDERER_MAINTHREAD_CONTEXT); | 1064 RENDERER_MAINTHREAD_CONTEXT); |
1064 if (!provider || !provider->BindToCurrentThread()) { | 1065 if (!provider || !provider->BindToCurrentThread()) { |
1065 // Collect Graphicsinfo if there is a context failure or it is failed | 1066 // Collect Graphicsinfo if there is a context failure or it is failed |
1066 // purposefully in case of layout tests. | 1067 // purposefully in case of layout tests. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 // Blink adds a new type. | 1184 // Blink adds a new type. |
1184 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " | 1185 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " |
1185 "unknown type."; | 1186 "unknown type."; |
1186 } | 1187 } |
1187 | 1188 |
1188 return NULL; | 1189 return NULL; |
1189 } | 1190 } |
1190 | 1191 |
1191 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( | 1192 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( |
1192 blink::WebPlatformEventType type, | 1193 blink::WebPlatformEventType type, |
1193 scoped_ptr<PlatformEventObserverBase> observer) { | 1194 std::unique_ptr<PlatformEventObserverBase> observer) { |
1194 if (platform_event_observers_.Lookup(type)) | 1195 if (platform_event_observers_.Lookup(type)) |
1195 platform_event_observers_.Remove(type); | 1196 platform_event_observers_.Remove(type); |
1196 platform_event_observers_.AddWithID(observer.release(), type); | 1197 platform_event_observers_.AddWithID(observer.release(), type); |
1197 } | 1198 } |
1198 | 1199 |
1199 blink::ServiceRegistry* RendererBlinkPlatformImpl::serviceRegistry() { | 1200 blink::ServiceRegistry* RendererBlinkPlatformImpl::serviceRegistry() { |
1200 return blink_service_registry_.get(); | 1201 return blink_service_registry_.get(); |
1201 } | 1202 } |
1202 | 1203 |
1203 void RendererBlinkPlatformImpl::startListening( | 1204 void RendererBlinkPlatformImpl::startListening( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 } | 1286 } |
1286 | 1287 |
1287 //------------------------------------------------------------------------------ | 1288 //------------------------------------------------------------------------------ |
1288 | 1289 |
1289 blink::WebTrialTokenValidator* | 1290 blink::WebTrialTokenValidator* |
1290 RendererBlinkPlatformImpl::trialTokenValidator() { | 1291 RendererBlinkPlatformImpl::trialTokenValidator() { |
1291 return &trial_token_validator_; | 1292 return &trial_token_validator_; |
1292 } | 1293 } |
1293 | 1294 |
1294 } // namespace content | 1295 } // namespace content |
OLD | NEW |