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

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: clarify compositor thread ownership. guarantee initialization correctness. 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) {
532 scheduler::WebThreadImplForWorkerScheduler* thread = 534 return createThreadWithOptions(name, base::Thread::Options());
533 new scheduler::WebThreadImplForWorkerScheduler(name); 535 }
536
537 blink::WebThread* BlinkPlatformImpl::createThreadWithOptions(
538 const char* name,
539 base::Thread::Options options) {
540 scheduler::WebThreadBase* thread =
541 new scheduler::WebThreadImplForWorkerScheduler(name, options);
534 thread->TaskRunner()->PostTask( 542 thread->TaskRunner()->PostTask(
535 FROM_HERE, base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, 543 FROM_HERE, base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS,
536 base::Unretained(this), thread)); 544 base::Unretained(this), thread));
537 return thread; 545 return thread;
538 } 546 }
539 547
540 blink::WebThread* BlinkPlatformImpl::currentThread() { 548 blink::WebThread* BlinkPlatformImpl::currentThread() {
541 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); 549 return static_cast<blink::WebThread*>(current_thread_slot_.Get());
542 } 550 }
543 551
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1084
1077 double BlinkPlatformImpl::systemTraceTime() { 1085 double BlinkPlatformImpl::systemTraceTime() {
1078 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 1086 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
1079 } 1087 }
1080 1088
1081 void BlinkPlatformImpl::cryptographicallyRandomValues( 1089 void BlinkPlatformImpl::cryptographicallyRandomValues(
1082 unsigned char* buffer, size_t length) { 1090 unsigned char* buffer, size_t length) {
1083 base::RandBytes(buffer, length); 1091 base::RandBytes(buffer, length);
1084 } 1092 }
1085 1093
1094 blink::WebThread* BlinkPlatformImpl::compositorThread() const {
1095 return compositor_thread_;
1096 }
1097
1086 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve( 1098 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve(
1087 blink::WebGestureDevice device_source, 1099 blink::WebGestureDevice device_source,
1088 const blink::WebFloatPoint& velocity, 1100 const blink::WebFloatPoint& velocity,
1089 const blink::WebSize& cumulative_scroll) { 1101 const blink::WebSize& cumulative_scroll) {
1090 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve( 1102 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve(
1091 gfx::Vector2dF(velocity.x, velocity.y), 1103 gfx::Vector2dF(velocity.x, velocity.y),
1092 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height), 1104 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height),
1093 IsMainThread()).release(); 1105 IsMainThread()).release();
1094 } 1106 }
1095 1107
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( 1304 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
1293 static_cast<ui::DomKey>(dom_key))); 1305 static_cast<ui::DomKey>(dom_key)));
1294 } 1306 }
1295 1307
1296 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { 1308 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) {
1297 return static_cast<int>( 1309 return static_cast<int>(
1298 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); 1310 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8()));
1299 } 1311 }
1300 1312
1301 } // namespace content 1313 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698