Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: content/child/blink_platform_impl.cc

Issue 1449953002: compositor-worker: Refactor CompositorWorkerManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/child/blink_platform_impl.h" 5 #include "content/child/blink_platform_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/metrics/sparse_histogram.h" 17 #include "base/metrics/sparse_histogram.h"
18 #include "base/rand_util.h" 18 #include "base/rand_util.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
24 #include "base/synchronization/waitable_event.h" 24 #include "base/synchronization/waitable_event.h"
25 #include "base/sys_info.h" 25 #include "base/sys_info.h"
26 #include "base/thread_task_runner_handle.h" 26 #include "base/thread_task_runner_handle.h"
27 #include "base/threading/platform_thread.h" 27 #include "base/threading/platform_thread.h"
28 #include "base/threading/thread.h"
28 #include "base/time/time.h" 29 #include "base/time/time.h"
29 #include "base/trace_event/memory_allocator_dump_guid.h" 30 #include "base/trace_event/memory_allocator_dump_guid.h"
30 #include "base/trace_event/memory_dump_manager.h" 31 #include "base/trace_event/memory_dump_manager.h"
31 #include "base/trace_event/trace_event.h" 32 #include "base/trace_event/trace_event.h"
32 #include "blink/public/resources/grit/blink_image_resources.h" 33 #include "blink/public/resources/grit/blink_image_resources.h"
33 #include "blink/public/resources/grit/blink_resources.h" 34 #include "blink/public/resources/grit/blink_resources.h"
34 #include "components/mime_util/mime_util.h" 35 #include "components/mime_util/mime_util.h"
35 #include "components/scheduler/child/web_task_runner_impl.h" 36 #include "components/scheduler/child/web_task_runner_impl.h"
36 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" 37 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h"
37 #include "content/app/resources/grit/content_resources.h" 38 #include "content/app/resources/grit/content_resources.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // TODO(skyostil): Ensure that we always have an active task runner when 436 // TODO(skyostil): Ensure that we always have an active task runner when
436 // constructing the platform. 437 // constructing the platform.
437 BlinkPlatformImpl::BlinkPlatformImpl() 438 BlinkPlatformImpl::BlinkPlatformImpl()
438 : BlinkPlatformImpl(base::ThreadTaskRunnerHandle::IsSet() 439 : BlinkPlatformImpl(base::ThreadTaskRunnerHandle::IsSet()
439 ? base::ThreadTaskRunnerHandle::Get() 440 ? base::ThreadTaskRunnerHandle::Get()
440 : nullptr) { 441 : nullptr) {
441 } 442 }
442 443
443 BlinkPlatformImpl::BlinkPlatformImpl( 444 BlinkPlatformImpl::BlinkPlatformImpl(
444 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) 445 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner)
445 : main_thread_task_runner_(main_thread_task_runner) { 446 : main_thread_task_runner_(main_thread_task_runner),
447 compositor_thread_(nullptr) {
446 InternalInit(); 448 InternalInit();
447 } 449 }
448 450
449 void BlinkPlatformImpl::InternalInit() { 451 void BlinkPlatformImpl::InternalInit() {
450 // ChildThread may not exist in some tests. 452 // ChildThread may not exist in some tests.
451 if (ChildThreadImpl::current()) { 453 if (ChildThreadImpl::current()) {
452 geofencing_provider_.reset(new WebGeofencingProviderImpl( 454 geofencing_provider_.reset(new WebGeofencingProviderImpl(
453 ChildThreadImpl::current()->thread_safe_sender())); 455 ChildThreadImpl::current()->thread_safe_sender()));
454 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); 456 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender();
455 notification_dispatcher_ = 457 notification_dispatcher_ =
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 bool BlinkPlatformImpl::portAllowed(const blink::WebURL& url) const { 524 bool BlinkPlatformImpl::portAllowed(const blink::WebURL& url) const {
523 GURL gurl = GURL(url); 525 GURL gurl = GURL(url);
524 // Return true for URLs without a port specified. This is needed to let 526 // Return true for URLs without a port specified. This is needed to let
525 // through non-network schemes that don't go over the network. 527 // through non-network schemes that don't go over the network.
526 if (!gurl.has_port()) 528 if (!gurl.has_port())
527 return true; 529 return true;
528 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme()); 530 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme());
529 } 531 }
530 532
531 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { 533 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) {
534 base::Thread::Options options;
532 scheduler::WebThreadImplForWorkerScheduler* thread = 535 scheduler::WebThreadImplForWorkerScheduler* thread =
533 new scheduler::WebThreadImplForWorkerScheduler(name); 536 new scheduler::WebThreadImplForWorkerScheduler(name, options);
534 thread->TaskRunner()->PostTask( 537 thread->TaskRunner()->PostTask(
535 FROM_HERE, base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, 538 FROM_HERE, base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS,
536 base::Unretained(this), thread)); 539 base::Unretained(this), thread));
537 return thread; 540 return thread;
538 } 541 }
539 542
543 blink::WebThread* BlinkPlatformImpl::createThreadForCompositor(
544 const char* name) {
545 base::Thread::Options options;
sadrul 2015/11/27 19:03:07 DCHECK(!compositor_thread_)?
Ian Vollick 2015/11/27 19:56:11 Done.
546 #if defined(OS_ANDROID)
547 options.priority = base::ThreadPriority::DISPLAY;
548 #endif
549 compositor_thread_ =
550 new scheduler::WebThreadImplForWorkerScheduler(name, options);
551 compositor_thread_->TaskRunner()->PostTask(
552 FROM_HERE, base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS,
553 base::Unretained(this), compositor_thread_));
554 return compositor_thread_;
555 }
556
540 blink::WebThread* BlinkPlatformImpl::currentThread() { 557 blink::WebThread* BlinkPlatformImpl::currentThread() {
541 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); 558 return static_cast<blink::WebThread*>(current_thread_slot_.Get());
542 } 559 }
543 560
544 void BlinkPlatformImpl::yieldCurrentThread() { 561 void BlinkPlatformImpl::yieldCurrentThread() {
545 base::PlatformThread::YieldCurrentThread(); 562 base::PlatformThread::YieldCurrentThread();
546 } 563 }
547 564
548 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent( 565 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent(
549 blink::WebWaitableEvent::ResetPolicy policy, 566 blink::WebWaitableEvent::ResetPolicy policy,
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1099
1083 double BlinkPlatformImpl::systemTraceTime() { 1100 double BlinkPlatformImpl::systemTraceTime() {
1084 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 1101 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
1085 } 1102 }
1086 1103
1087 void BlinkPlatformImpl::cryptographicallyRandomValues( 1104 void BlinkPlatformImpl::cryptographicallyRandomValues(
1088 unsigned char* buffer, size_t length) { 1105 unsigned char* buffer, size_t length) {
1089 base::RandBytes(buffer, length); 1106 base::RandBytes(buffer, length);
1090 } 1107 }
1091 1108
1109 blink::WebThread* BlinkPlatformImpl::compositorThread() const {
1110 return compositor_thread_;
1111 }
1112
1092 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve( 1113 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve(
1093 blink::WebGestureDevice device_source, 1114 blink::WebGestureDevice device_source,
1094 const blink::WebFloatPoint& velocity, 1115 const blink::WebFloatPoint& velocity,
1095 const blink::WebSize& cumulative_scroll) { 1116 const blink::WebSize& cumulative_scroll) {
1096 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve( 1117 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve(
1097 gfx::Vector2dF(velocity.x, velocity.y), 1118 gfx::Vector2dF(velocity.x, velocity.y),
1098 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height), 1119 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height),
1099 IsMainThread()).release(); 1120 IsMainThread()).release();
1100 } 1121 }
1101 1122
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( 1319 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
1299 static_cast<ui::DomKey>(dom_key))); 1320 static_cast<ui::DomKey>(dom_key)));
1300 } 1321 }
1301 1322
1302 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { 1323 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) {
1303 return static_cast<int>( 1324 return static_cast<int>(
1304 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); 1325 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8()));
1305 } 1326 }
1306 1327
1307 } // namespace content 1328 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698