| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #include "ui/events/keycodes/dom/keycode_converter.h" | 76 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 77 | 77 |
| 78 using blink::WebData; | 78 using blink::WebData; |
| 79 using blink::WebFallbackThemeEngine; | 79 using blink::WebFallbackThemeEngine; |
| 80 using blink::WebLocalizedString; | 80 using blink::WebLocalizedString; |
| 81 using blink::WebString; | 81 using blink::WebString; |
| 82 using blink::WebThemeEngine; | 82 using blink::WebThemeEngine; |
| 83 using blink::WebURL; | 83 using blink::WebURL; |
| 84 using blink::WebURLError; | 84 using blink::WebURLError; |
| 85 using blink::WebURLLoader; | 85 using blink::WebURLLoader; |
| 86 using scheduler::WebThreadImplForWorkerScheduler; |
| 86 | 87 |
| 87 namespace content { | 88 namespace content { |
| 88 | 89 |
| 89 namespace { | 90 namespace { |
| 90 | 91 |
| 91 class WebWaitableEventImpl : public blink::WebWaitableEvent { | 92 class WebWaitableEventImpl : public blink::WebWaitableEvent { |
| 92 public: | 93 public: |
| 93 WebWaitableEventImpl(ResetPolicy policy, InitialState state) { | 94 WebWaitableEventImpl(ResetPolicy policy, InitialState state) { |
| 94 bool manual_reset = policy == ResetPolicy::Manual; | 95 bool manual_reset = policy == ResetPolicy::Manual; |
| 95 bool initially_signaled = state == InitialState::Signaled; | 96 bool initially_signaled = state == InitialState::Signaled; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 notification_dispatcher_ = | 476 notification_dispatcher_ = |
| 476 ChildThreadImpl::current()->notification_dispatcher(); | 477 ChildThreadImpl::current()->notification_dispatcher(); |
| 477 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher(); | 478 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher(); |
| 478 permission_client_.reset(new PermissionDispatcher( | 479 permission_client_.reset(new PermissionDispatcher( |
| 479 ChildThreadImpl::current()->service_registry())); | 480 ChildThreadImpl::current()->service_registry())); |
| 480 main_thread_sync_provider_.reset( | 481 main_thread_sync_provider_.reset( |
| 481 new BackgroundSyncProvider(main_thread_task_runner_.get())); | 482 new BackgroundSyncProvider(main_thread_task_runner_.get())); |
| 482 } | 483 } |
| 483 } | 484 } |
| 484 | 485 |
| 486 void BlinkPlatformImpl::WaitUntilWebThreadTLSUpdate( |
| 487 scheduler::WebThreadBase* thread) { |
| 488 base::WaitableEvent event(false, false); |
| 489 thread->TaskRunner()->PostTask( |
| 490 FROM_HERE, |
| 491 base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, base::Unretained(this), |
| 492 base::Unretained(thread), base::Unretained(&event))); |
| 493 event.Wait(); |
| 494 } |
| 495 |
| 485 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread, | 496 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread, |
| 486 base::WaitableEvent* event) { | 497 base::WaitableEvent* event) { |
| 487 DCHECK(!current_thread_slot_.Get()); | 498 DCHECK(!current_thread_slot_.Get()); |
| 488 current_thread_slot_.Set(thread); | 499 current_thread_slot_.Set(thread); |
| 489 event->Signal(); | 500 event->Signal(); |
| 490 } | 501 } |
| 491 | 502 |
| 492 BlinkPlatformImpl::~BlinkPlatformImpl() { | 503 BlinkPlatformImpl::~BlinkPlatformImpl() { |
| 493 } | 504 } |
| 494 | 505 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 bool BlinkPlatformImpl::portAllowed(const blink::WebURL& url) const { | 555 bool BlinkPlatformImpl::portAllowed(const blink::WebURL& url) const { |
| 545 GURL gurl = GURL(url); | 556 GURL gurl = GURL(url); |
| 546 // Return true for URLs without a port specified. This is needed to let | 557 // Return true for URLs without a port specified. This is needed to let |
| 547 // through non-network schemes that don't go over the network. | 558 // through non-network schemes that don't go over the network. |
| 548 if (!gurl.has_port()) | 559 if (!gurl.has_port()) |
| 549 return true; | 560 return true; |
| 550 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme()); | 561 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme()); |
| 551 } | 562 } |
| 552 | 563 |
| 553 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { | 564 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { |
| 554 return createThreadWithOptions(name, base::Thread::Options()).release(); | 565 scoped_ptr<WebThreadImplForWorkerScheduler> thread( |
| 566 new WebThreadImplForWorkerScheduler(name)); |
| 567 thread->Init(); |
| 568 WaitUntilWebThreadTLSUpdate(thread.get()); |
| 569 return thread.release(); |
| 555 } | 570 } |
| 556 | 571 |
| 557 scoped_ptr<scheduler::WebThreadBase> BlinkPlatformImpl::createThreadWithOptions( | 572 void BlinkPlatformImpl::SetCompositorThread( |
| 558 const char* name, | 573 scheduler::WebThreadBase* compositor_thread) { |
| 559 base::Thread::Options options) { | 574 compositor_thread_ = compositor_thread; |
| 560 scoped_ptr<scheduler::WebThreadBase> thread( | 575 if (compositor_thread_) |
| 561 new scheduler::WebThreadImplForWorkerScheduler(name, options)); | 576 WaitUntilWebThreadTLSUpdate(compositor_thread_); |
| 562 base::WaitableEvent event(false, false); | |
| 563 thread->TaskRunner()->PostTask( | |
| 564 FROM_HERE, | |
| 565 base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, base::Unretained(this), | |
| 566 base::Unretained(thread.get()), base::Unretained(&event))); | |
| 567 event.Wait(); | |
| 568 return thread; | |
| 569 } | 577 } |
| 570 | 578 |
| 571 blink::WebThread* BlinkPlatformImpl::currentThread() { | 579 blink::WebThread* BlinkPlatformImpl::currentThread() { |
| 572 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); | 580 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); |
| 573 } | 581 } |
| 574 | 582 |
| 575 void BlinkPlatformImpl::yieldCurrentThread() { | 583 void BlinkPlatformImpl::yieldCurrentThread() { |
| 576 base::PlatformThread::YieldCurrentThread(); | 584 base::PlatformThread::YieldCurrentThread(); |
| 577 } | 585 } |
| 578 | 586 |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( | 1305 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( |
| 1298 static_cast<ui::DomKey>(dom_key))); | 1306 static_cast<ui::DomKey>(dom_key))); |
| 1299 } | 1307 } |
| 1300 | 1308 |
| 1301 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { | 1309 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { |
| 1302 return static_cast<int>( | 1310 return static_cast<int>( |
| 1303 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); | 1311 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); |
| 1304 } | 1312 } |
| 1305 | 1313 |
| 1306 } // namespace content | 1314 } // namespace content |
| OLD | NEW |