| 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 #ifndef SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ | 5 #ifndef SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ |
| 6 #define SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ | 6 #define SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/threading/thread_local_storage.h" | 10 #include "base/threading/thread_local_storage.h" |
| 11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
| 12 #include "sky/engine/public/platform/Platform.h" | 12 #include "sky/engine/public/platform/Platform.h" |
| 13 #include "sky/engine/testing/platform/webunittestsupport_impl.h" | 13 #include "sky/engine/testing/platform/webunittestsupport_impl.h" |
| 14 | 14 |
| 15 namespace sky { | 15 namespace sky { |
| 16 | 16 |
| 17 class PlatformImpl : public blink::Platform { | 17 class PlatformImpl : public blink::Platform { |
| 18 public: | 18 public: |
| 19 explicit PlatformImpl(); | 19 explicit PlatformImpl(); |
| 20 virtual ~PlatformImpl(); | 20 virtual ~PlatformImpl(); |
| 21 | 21 |
| 22 // blink::Platform methods: | 22 // blink::Platform methods: |
| 23 virtual blink::WebUnitTestSupport* unitTestSupport(); | 23 virtual blink::WebUnitTestSupport* unitTestSupport(); |
| 24 virtual blink::WebString defaultLocale(); | 24 virtual blink::WebString defaultLocale(); |
| 25 virtual double currentTime(); | |
| 26 virtual double monotonicallyIncreasingTime(); | |
| 27 virtual void setSharedTimerFiredFunction(void (*func)()); | |
| 28 virtual void setSharedTimerFireInterval(double interval_seconds); | |
| 29 virtual void stopSharedTimer(); | |
| 30 | 25 |
| 31 private: | 26 private: |
| 32 void SuspendSharedTimer(); | |
| 33 void ResumeSharedTimer(); | |
| 34 | |
| 35 void DoTimeout() { | |
| 36 if (shared_timer_func_ && !shared_timer_suspended_) | |
| 37 shared_timer_func_(); | |
| 38 } | |
| 39 | |
| 40 base::MessageLoop* main_loop_; | |
| 41 base::OneShotTimer<PlatformImpl> shared_timer_; | |
| 42 void (*shared_timer_func_)(); | |
| 43 double shared_timer_fire_time_; | |
| 44 bool shared_timer_fire_time_was_set_while_suspended_; | |
| 45 int shared_timer_suspended_; // counter | |
| 46 WebUnitTestSupportImpl unit_test_support_; | 27 WebUnitTestSupportImpl unit_test_support_; |
| 47 | 28 |
| 48 DISALLOW_COPY_AND_ASSIGN(PlatformImpl); | 29 DISALLOW_COPY_AND_ASSIGN(PlatformImpl); |
| 49 }; | 30 }; |
| 50 | 31 |
| 51 } // namespace sky | 32 } // namespace sky |
| 52 | 33 |
| 53 #endif // SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ | 34 #endif // SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ |
| OLD | NEW |