| 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 "components/html_viewer/blink_platform_impl.h" | 5 #include "components/html_viewer/blink_platform_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" | 35 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" |
| 36 | 36 |
| 37 namespace html_viewer { | 37 namespace html_viewer { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // Allows overriding user agent scring. | 40 // Allows overriding user agent scring. |
| 41 const char kUserAgentSwitch[] = "user-agent"; | 41 const char kUserAgentSwitch[] = "user-agent"; |
| 42 | 42 |
| 43 class WebWaitableEventImpl : public blink::WebWaitableEvent { | 43 class WebWaitableEventImpl : public blink::WebWaitableEvent { |
| 44 public: | 44 public: |
| 45 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {} | 45 WebWaitableEventImpl(ResetPolicy policy, InitialState state) { |
| 46 ~WebWaitableEventImpl() override {} | 46 bool manual_reset = policy == ResetPolicy::Manual; |
| 47 bool initially_signaled = state == InitialState::Signaled; |
| 48 impl_.reset(new base::WaitableEvent(manual_reset, initially_signaled)); |
| 49 } |
| 50 virtual ~WebWaitableEventImpl() {} |
| 47 | 51 |
| 48 void wait() override { impl_->Wait(); } | 52 virtual void reset() { impl_->Reset(); } |
| 49 void signal() override { impl_->Signal(); } | 53 virtual void wait() { impl_->Wait(); } |
| 54 virtual void signal() { impl_->Signal(); } |
| 50 | 55 |
| 51 base::WaitableEvent* impl() { | 56 base::WaitableEvent* impl() { |
| 52 return impl_.get(); | 57 return impl_.get(); |
| 53 } | 58 } |
| 54 | 59 |
| 55 private: | 60 private: |
| 56 scoped_ptr<base::WaitableEvent> impl_; | 61 scoped_ptr<base::WaitableEvent> impl_; |
| 57 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); | 62 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); |
| 58 }; | 63 }; |
| 59 | 64 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 blink::WebThread* BlinkPlatformImpl::currentThread() { | 237 blink::WebThread* BlinkPlatformImpl::currentThread() { |
| 233 if (main_thread_->isCurrentThread()) | 238 if (main_thread_->isCurrentThread()) |
| 234 return main_thread_.get(); | 239 return main_thread_.get(); |
| 235 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); | 240 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); |
| 236 } | 241 } |
| 237 | 242 |
| 238 void BlinkPlatformImpl::yieldCurrentThread() { | 243 void BlinkPlatformImpl::yieldCurrentThread() { |
| 239 base::PlatformThread::YieldCurrentThread(); | 244 base::PlatformThread::YieldCurrentThread(); |
| 240 } | 245 } |
| 241 | 246 |
| 242 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { | 247 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent( |
| 243 return new WebWaitableEventImpl(); | 248 blink::WebWaitableEvent::ResetPolicy policy, |
| 249 blink::WebWaitableEvent::InitialState state) { |
| 250 return new WebWaitableEventImpl(policy, state); |
| 244 } | 251 } |
| 245 | 252 |
| 246 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( | 253 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( |
| 247 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { | 254 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { |
| 248 std::vector<base::WaitableEvent*> events; | 255 std::vector<base::WaitableEvent*> events; |
| 249 for (size_t i = 0; i < web_events.size(); ++i) | 256 for (size_t i = 0; i < web_events.size(); ++i) |
| 250 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); | 257 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); |
| 251 size_t idx = base::WaitableEvent::WaitMany( | 258 size_t idx = base::WaitableEvent::WaitMany( |
| 252 vector_as_array(&events), events.size()); | 259 vector_as_array(&events), events.size()); |
| 253 DCHECK_LT(idx, web_events.size()); | 260 DCHECK_LT(idx, web_events.size()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 273 BlinkPlatformImpl::notificationManager() { | 280 BlinkPlatformImpl::notificationManager() { |
| 274 return &web_notification_manager_; | 281 return &web_notification_manager_; |
| 275 } | 282 } |
| 276 | 283 |
| 277 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { | 284 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { |
| 278 DCHECK(!current_thread_slot_.Get()); | 285 DCHECK(!current_thread_slot_.Get()); |
| 279 current_thread_slot_.Set(thread); | 286 current_thread_slot_.Set(thread); |
| 280 } | 287 } |
| 281 | 288 |
| 282 } // namespace html_viewer | 289 } // namespace html_viewer |
| OLD | NEW |