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

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

Issue 1494483002: Revert of 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
« no previous file with comments | « content/child/blink_platform_impl.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
29 #include "base/time/time.h" 28 #include "base/time/time.h"
30 #include "base/trace_event/memory_allocator_dump_guid.h" 29 #include "base/trace_event/memory_allocator_dump_guid.h"
31 #include "base/trace_event/memory_dump_manager.h" 30 #include "base/trace_event/memory_dump_manager.h"
32 #include "base/trace_event/trace_event.h" 31 #include "base/trace_event/trace_event.h"
33 #include "blink/public/resources/grit/blink_image_resources.h" 32 #include "blink/public/resources/grit/blink_image_resources.h"
34 #include "blink/public/resources/grit/blink_resources.h" 33 #include "blink/public/resources/grit/blink_resources.h"
35 #include "components/mime_util/mime_util.h" 34 #include "components/mime_util/mime_util.h"
36 #include "components/scheduler/child/web_task_runner_impl.h" 35 #include "components/scheduler/child/web_task_runner_impl.h"
37 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" 36 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h"
38 #include "content/app/resources/grit/content_resources.h" 37 #include "content/app/resources/grit/content_resources.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // TODO(skyostil): Ensure that we always have an active task runner when 435 // TODO(skyostil): Ensure that we always have an active task runner when
437 // constructing the platform. 436 // constructing the platform.
438 BlinkPlatformImpl::BlinkPlatformImpl() 437 BlinkPlatformImpl::BlinkPlatformImpl()
439 : BlinkPlatformImpl(base::ThreadTaskRunnerHandle::IsSet() 438 : BlinkPlatformImpl(base::ThreadTaskRunnerHandle::IsSet()
440 ? base::ThreadTaskRunnerHandle::Get() 439 ? base::ThreadTaskRunnerHandle::Get()
441 : nullptr) { 440 : nullptr) {
442 } 441 }
443 442
444 BlinkPlatformImpl::BlinkPlatformImpl( 443 BlinkPlatformImpl::BlinkPlatformImpl(
445 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) 444 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner)
446 : main_thread_task_runner_(main_thread_task_runner), 445 : main_thread_task_runner_(main_thread_task_runner) {
447 compositor_thread_(nullptr) {
448 InternalInit(); 446 InternalInit();
449 } 447 }
450 448
451 void BlinkPlatformImpl::InternalInit() { 449 void BlinkPlatformImpl::InternalInit() {
452 // ChildThread may not exist in some tests. 450 // ChildThread may not exist in some tests.
453 if (ChildThreadImpl::current()) { 451 if (ChildThreadImpl::current()) {
454 geofencing_provider_.reset(new WebGeofencingProviderImpl( 452 geofencing_provider_.reset(new WebGeofencingProviderImpl(
455 ChildThreadImpl::current()->thread_safe_sender())); 453 ChildThreadImpl::current()->thread_safe_sender()));
456 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); 454 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender();
457 notification_dispatcher_ = 455 notification_dispatcher_ =
458 ChildThreadImpl::current()->notification_dispatcher(); 456 ChildThreadImpl::current()->notification_dispatcher();
459 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher(); 457 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher();
460 permission_client_.reset(new PermissionDispatcher( 458 permission_client_.reset(new PermissionDispatcher(
461 ChildThreadImpl::current()->service_registry())); 459 ChildThreadImpl::current()->service_registry()));
462 main_thread_sync_provider_.reset( 460 main_thread_sync_provider_.reset(
463 new BackgroundSyncProvider(main_thread_task_runner_.get())); 461 new BackgroundSyncProvider(main_thread_task_runner_.get()));
464 } 462 }
465 } 463 }
466 464
467 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread, 465 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) {
468 base::WaitableEvent* event) {
469 DCHECK(!current_thread_slot_.Get()); 466 DCHECK(!current_thread_slot_.Get());
470 current_thread_slot_.Set(thread); 467 current_thread_slot_.Set(thread);
471 event->Signal();
472 } 468 }
473 469
474 BlinkPlatformImpl::~BlinkPlatformImpl() { 470 BlinkPlatformImpl::~BlinkPlatformImpl() {
475 } 471 }
476 472
477 WebURLLoader* BlinkPlatformImpl::createURLLoader() { 473 WebURLLoader* BlinkPlatformImpl::createURLLoader() {
478 ChildThreadImpl* child_thread = ChildThreadImpl::current(); 474 ChildThreadImpl* child_thread = ChildThreadImpl::current();
479 // There may be no child thread in RenderViewTests. These tests can still use 475 // There may be no child thread in RenderViewTests. These tests can still use
480 // data URLs to bypass the ResourceDispatcher. 476 // data URLs to bypass the ResourceDispatcher.
481 return new WebURLLoaderImpl( 477 return new WebURLLoaderImpl(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 bool BlinkPlatformImpl::portAllowed(const blink::WebURL& url) const { 522 bool BlinkPlatformImpl::portAllowed(const blink::WebURL& url) const {
527 GURL gurl = GURL(url); 523 GURL gurl = GURL(url);
528 // Return true for URLs without a port specified. This is needed to let 524 // Return true for URLs without a port specified. This is needed to let
529 // through non-network schemes that don't go over the network. 525 // through non-network schemes that don't go over the network.
530 if (!gurl.has_port()) 526 if (!gurl.has_port())
531 return true; 527 return true;
532 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme()); 528 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme());
533 } 529 }
534 530
535 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { 531 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) {
536 return createThreadWithOptions(name, base::Thread::Options()).release(); 532 scheduler::WebThreadImplForWorkerScheduler* thread =
537 } 533 new scheduler::WebThreadImplForWorkerScheduler(name);
538
539 scoped_ptr<scheduler::WebThreadBase> BlinkPlatformImpl::createThreadWithOptions(
540 const char* name,
541 base::Thread::Options options) {
542 scoped_ptr<scheduler::WebThreadBase> thread(
543 new scheduler::WebThreadImplForWorkerScheduler(name, options));
544 base::WaitableEvent event(false, false);
545 thread->TaskRunner()->PostTask( 534 thread->TaskRunner()->PostTask(
546 FROM_HERE, 535 FROM_HERE, base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS,
547 base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, base::Unretained(this), 536 base::Unretained(this), thread));
548 base::Unretained(thread.get()), base::Unretained(&event)));
549 event.Wait();
550 return thread; 537 return thread;
551 } 538 }
552 539
553 blink::WebThread* BlinkPlatformImpl::currentThread() { 540 blink::WebThread* BlinkPlatformImpl::currentThread() {
554 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); 541 return static_cast<blink::WebThread*>(current_thread_slot_.Get());
555 } 542 }
556 543
557 void BlinkPlatformImpl::yieldCurrentThread() { 544 void BlinkPlatformImpl::yieldCurrentThread() {
558 base::PlatformThread::YieldCurrentThread(); 545 base::PlatformThread::YieldCurrentThread();
559 } 546 }
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1076
1090 double BlinkPlatformImpl::systemTraceTime() { 1077 double BlinkPlatformImpl::systemTraceTime() {
1091 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 1078 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
1092 } 1079 }
1093 1080
1094 void BlinkPlatformImpl::cryptographicallyRandomValues( 1081 void BlinkPlatformImpl::cryptographicallyRandomValues(
1095 unsigned char* buffer, size_t length) { 1082 unsigned char* buffer, size_t length) {
1096 base::RandBytes(buffer, length); 1083 base::RandBytes(buffer, length);
1097 } 1084 }
1098 1085
1099 blink::WebThread* BlinkPlatformImpl::compositorThread() const {
1100 return compositor_thread_;
1101 }
1102
1103 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve( 1086 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve(
1104 blink::WebGestureDevice device_source, 1087 blink::WebGestureDevice device_source,
1105 const blink::WebFloatPoint& velocity, 1088 const blink::WebFloatPoint& velocity,
1106 const blink::WebSize& cumulative_scroll) { 1089 const blink::WebSize& cumulative_scroll) {
1107 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve( 1090 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve(
1108 gfx::Vector2dF(velocity.x, velocity.y), 1091 gfx::Vector2dF(velocity.x, velocity.y),
1109 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height), 1092 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height),
1110 IsMainThread()).release(); 1093 IsMainThread()).release();
1111 } 1094 }
1112 1095
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( 1292 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
1310 static_cast<ui::DomKey>(dom_key))); 1293 static_cast<ui::DomKey>(dom_key)));
1311 } 1294 }
1312 1295
1313 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { 1296 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) {
1314 return static_cast<int>( 1297 return static_cast<int>(
1315 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); 1298 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8()));
1316 } 1299 }
1317 1300
1318 } // namespace content 1301 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blink_platform_impl.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698