| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 86 |
| 87 namespace content { | 87 namespace content { |
| 88 | 88 |
| 89 namespace { | 89 namespace { |
| 90 | 90 |
| 91 class WebWaitableEventImpl : public blink::WebWaitableEvent { | 91 class WebWaitableEventImpl : public blink::WebWaitableEvent { |
| 92 public: | 92 public: |
| 93 WebWaitableEventImpl(ResetPolicy policy, InitialState state) { | 93 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {} |
| 94 bool manual_reset = policy == ResetPolicy::Manual; | |
| 95 bool initially_signaled = state == InitialState::Signaled; | |
| 96 impl_.reset(new base::WaitableEvent(manual_reset, initially_signaled)); | |
| 97 } | |
| 98 virtual ~WebWaitableEventImpl() {} | 94 virtual ~WebWaitableEventImpl() {} |
| 99 | 95 |
| 100 virtual void reset() { impl_->Reset(); } | |
| 101 virtual void wait() { impl_->Wait(); } | 96 virtual void wait() { impl_->Wait(); } |
| 102 virtual void signal() { impl_->Signal(); } | 97 virtual void signal() { impl_->Signal(); } |
| 103 | 98 |
| 104 base::WaitableEvent* impl() { | 99 base::WaitableEvent* impl() { |
| 105 return impl_.get(); | 100 return impl_.get(); |
| 106 } | 101 } |
| 107 | 102 |
| 108 private: | 103 private: |
| 109 scoped_ptr<base::WaitableEvent> impl_; | 104 scoped_ptr<base::WaitableEvent> impl_; |
| 110 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); | 105 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 } | 532 } |
| 538 | 533 |
| 539 blink::WebThread* BlinkPlatformImpl::currentThread() { | 534 blink::WebThread* BlinkPlatformImpl::currentThread() { |
| 540 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); | 535 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); |
| 541 } | 536 } |
| 542 | 537 |
| 543 void BlinkPlatformImpl::yieldCurrentThread() { | 538 void BlinkPlatformImpl::yieldCurrentThread() { |
| 544 base::PlatformThread::YieldCurrentThread(); | 539 base::PlatformThread::YieldCurrentThread(); |
| 545 } | 540 } |
| 546 | 541 |
| 547 // TODO(toyoshim): Remove no arguments version after the transition. | |
| 548 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { | 542 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { |
| 549 return new WebWaitableEventImpl( | 543 return new WebWaitableEventImpl(); |
| 550 blink::WebWaitableEvent::ResetPolicy::Auto, | |
| 551 blink::WebWaitableEvent::InitialState::NonSignaled); | |
| 552 } | |
| 553 | |
| 554 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent( | |
| 555 blink::WebWaitableEvent::ResetPolicy policy, | |
| 556 blink::WebWaitableEvent::InitialState state) { | |
| 557 return new WebWaitableEventImpl(policy, state); | |
| 558 } | 544 } |
| 559 | 545 |
| 560 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( | 546 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( |
| 561 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { | 547 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { |
| 562 std::vector<base::WaitableEvent*> events; | 548 std::vector<base::WaitableEvent*> events; |
| 563 for (size_t i = 0; i < web_events.size(); ++i) | 549 for (size_t i = 0; i < web_events.size(); ++i) |
| 564 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); | 550 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); |
| 565 size_t idx = base::WaitableEvent::WaitMany( | 551 size_t idx = base::WaitableEvent::WaitMany( |
| 566 vector_as_array(&events), events.size()); | 552 vector_as_array(&events), events.size()); |
| 567 DCHECK_LT(idx, web_events.size()); | 553 DCHECK_LT(idx, web_events.size()); |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( | 1373 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
| 1388 static_cast<ui::DomCode>(dom_code))); | 1374 static_cast<ui::DomCode>(dom_code))); |
| 1389 } | 1375 } |
| 1390 | 1376 |
| 1391 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { | 1377 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
| 1392 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( | 1378 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( |
| 1393 code.utf8().data())); | 1379 code.utf8().data())); |
| 1394 } | 1380 } |
| 1395 | 1381 |
| 1396 } // namespace content | 1382 } // namespace content |
| OLD | NEW |