Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 // This "default:" line exists to avoid compile warnings about enum | 410 // This "default:" line exists to avoid compile warnings about enum |
| 411 // coverage when we add a new symbol to WebLocalizedString.h in WebKit. | 411 // coverage when we add a new symbol to WebLocalizedString.h in WebKit. |
| 412 // After a planned WebKit patch is landed, we need to add a case statement | 412 // After a planned WebKit patch is landed, we need to add a case statement |
| 413 // for the added symbol here. | 413 // for the added symbol here. |
| 414 default: | 414 default: |
| 415 break; | 415 break; |
| 416 } | 416 } |
| 417 return -1; | 417 return -1; |
| 418 } | 418 } |
| 419 | 419 |
| 420 BlinkPlatformImpl::BlinkPlatformImpl() | 420 BlinkPlatformImpl::BlinkPlatformImpl() |
|
Sami
2014/11/04 01:59:01
Could we make main_thread_task_runner a parameter
alex clarke (OOO till 29th)
2014/11/04 18:40:20
I've added a new constructor rather than altering
| |
| 421 : main_loop_(base::MessageLoop::current()), | 421 : main_thread_task_runner_(base::MessageLoopProxy::current()), |
| 422 shared_timer_func_(NULL), | 422 shared_timer_func_(NULL), |
| 423 shared_timer_fire_time_(0.0), | 423 shared_timer_fire_time_(0.0), |
| 424 shared_timer_fire_time_was_set_while_suspended_(false), | 424 shared_timer_fire_time_was_set_while_suspended_(false), |
| 425 shared_timer_suspended_(0), | 425 shared_timer_suspended_(0), |
| 426 current_thread_slot_(&DestroyCurrentThread) { | 426 current_thread_slot_(&DestroyCurrentThread) { |
| 427 // ChildThread may not exist in some tests. | 427 // ChildThread may not exist in some tests. |
| 428 if (ChildThread::current()) { | 428 if (ChildThread::current()) { |
| 429 geofencing_provider_.reset(new WebGeofencingProviderImpl( | 429 geofencing_provider_.reset(new WebGeofencingProviderImpl( |
| 430 ChildThread::current()->thread_safe_sender())); | 430 ChildThread::current()->thread_safe_sender())); |
| 431 thread_safe_sender_ = ChildThread::current()->thread_safe_sender(); | 431 thread_safe_sender_ = ChildThread::current()->thread_safe_sender(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { | 483 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { |
| 484 return new WebThreadImpl(name); | 484 return new WebThreadImpl(name); |
| 485 } | 485 } |
| 486 | 486 |
| 487 blink::WebThread* BlinkPlatformImpl::currentThread() { | 487 blink::WebThread* BlinkPlatformImpl::currentThread() { |
| 488 WebThreadImplForMessageLoop* thread = | 488 WebThreadImplForMessageLoop* thread = |
| 489 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); | 489 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); |
| 490 if (thread) | 490 if (thread) |
| 491 return (thread); | 491 return (thread); |
| 492 | 492 |
| 493 scoped_refptr<base::MessageLoopProxy> message_loop = | 493 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 494 base::MessageLoopProxy::current(); | 494 base::MessageLoopProxy::current(); |
| 495 if (!message_loop.get()) | 495 if (main_thread_task_runner_.get() && |
|
Sami
2014/11/04 01:59:01
|main_thread_task_runner_| should always be non-nu
alex clarke (OOO till 29th)
2014/11/04 18:40:20
That's not always true and in fact the browser wil
| |
| 496 main_thread_task_runner_->BelongsToCurrentThread()) { | |
| 497 task_runner = main_thread_task_runner_; | |
| 498 } | |
| 499 | |
| 500 if (!task_runner.get()) | |
| 496 return NULL; | 501 return NULL; |
| 497 | 502 |
| 498 thread = new WebThreadImplForMessageLoop(message_loop.get()); | 503 thread = new WebThreadImplForMessageLoop(task_runner); |
| 499 current_thread_slot_.Set(thread); | 504 current_thread_slot_.Set(thread); |
| 500 return thread; | 505 return thread; |
| 501 } | 506 } |
| 502 | 507 |
| 503 void BlinkPlatformImpl::yieldCurrentThread() { | 508 void BlinkPlatformImpl::yieldCurrentThread() { |
| 504 base::PlatformThread::YieldCurrentThread(); | 509 base::PlatformThread::YieldCurrentThread(); |
| 505 } | 510 } |
| 506 | 511 |
| 507 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { | 512 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { |
| 508 return new WebWaitableEventImpl(); | 513 return new WebWaitableEventImpl(); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 this, &BlinkPlatformImpl::DoTimeout); | 990 this, &BlinkPlatformImpl::DoTimeout); |
| 986 OnStartSharedTimer(base::TimeDelta::FromMicroseconds(interval)); | 991 OnStartSharedTimer(base::TimeDelta::FromMicroseconds(interval)); |
| 987 } | 992 } |
| 988 | 993 |
| 989 void BlinkPlatformImpl::stopSharedTimer() { | 994 void BlinkPlatformImpl::stopSharedTimer() { |
| 990 shared_timer_.Stop(); | 995 shared_timer_.Stop(); |
| 991 } | 996 } |
| 992 | 997 |
| 993 void BlinkPlatformImpl::callOnMainThread( | 998 void BlinkPlatformImpl::callOnMainThread( |
| 994 void (*func)(void*), void* context) { | 999 void (*func)(void*), void* context) { |
| 995 main_loop_->PostTask(FROM_HERE, base::Bind(func, context)); | 1000 main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(func, context)); |
| 996 } | 1001 } |
| 997 | 1002 |
| 998 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve( | 1003 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve( |
| 999 blink::WebGestureDevice device_source, | 1004 blink::WebGestureDevice device_source, |
| 1000 const blink::WebFloatPoint& velocity, | 1005 const blink::WebFloatPoint& velocity, |
| 1001 const blink::WebSize& cumulative_scroll) { | 1006 const blink::WebSize& cumulative_scroll) { |
| 1002 auto curve = WebGestureCurveImpl::CreateFromDefaultPlatformCurve( | 1007 auto curve = WebGestureCurveImpl::CreateFromDefaultPlatformCurve( |
| 1003 gfx::Vector2dF(velocity.x, velocity.y), | 1008 gfx::Vector2dF(velocity.x, velocity.y), |
| 1004 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height)); | 1009 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height)); |
| 1005 return curve.release(); | 1010 return curve.release(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1214 } | 1219 } |
| 1215 | 1220 |
| 1216 // static | 1221 // static |
| 1217 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { | 1222 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
| 1218 WebThreadImplForMessageLoop* impl = | 1223 WebThreadImplForMessageLoop* impl = |
| 1219 static_cast<WebThreadImplForMessageLoop*>(thread); | 1224 static_cast<WebThreadImplForMessageLoop*>(thread); |
| 1220 delete impl; | 1225 delete impl; |
| 1221 } | 1226 } |
| 1222 | 1227 |
| 1223 } // namespace content | 1228 } // namespace content |
| OLD | NEW |