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