| 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/webthemeengine_impl.h" | |
| 14 #include "sky/engine/testing/platform/webunittestsupport_impl.h" | 13 #include "sky/engine/testing/platform/webunittestsupport_impl.h" |
| 15 | 14 |
| 16 namespace sky { | 15 namespace sky { |
| 17 | 16 |
| 18 class PlatformImpl : public blink::Platform { | 17 class PlatformImpl : public blink::Platform { |
| 19 public: | 18 public: |
| 20 explicit PlatformImpl(); | 19 explicit PlatformImpl(); |
| 21 virtual ~PlatformImpl(); | 20 virtual ~PlatformImpl(); |
| 22 | 21 |
| 23 // blink::Platform methods: | 22 // blink::Platform methods: |
| 24 virtual blink::WebUnitTestSupport* unitTestSupport(); | 23 virtual blink::WebUnitTestSupport* unitTestSupport(); |
| 25 virtual blink::WebThemeEngine* themeEngine(); | |
| 26 virtual blink::WebString defaultLocale(); | 24 virtual blink::WebString defaultLocale(); |
| 27 virtual double currentTime(); | 25 virtual double currentTime(); |
| 28 virtual double monotonicallyIncreasingTime(); | 26 virtual double monotonicallyIncreasingTime(); |
| 29 virtual void setSharedTimerFiredFunction(void (*func)()); | 27 virtual void setSharedTimerFiredFunction(void (*func)()); |
| 30 virtual void setSharedTimerFireInterval(double interval_seconds); | 28 virtual void setSharedTimerFireInterval(double interval_seconds); |
| 31 virtual void stopSharedTimer(); | 29 virtual void stopSharedTimer(); |
| 32 virtual const unsigned char* getTraceCategoryEnabledFlag( | 30 virtual const unsigned char* getTraceCategoryEnabledFlag( |
| 33 const char* category_name); | 31 const char* category_name); |
| 34 | 32 |
| 35 private: | 33 private: |
| 36 void SuspendSharedTimer(); | 34 void SuspendSharedTimer(); |
| 37 void ResumeSharedTimer(); | 35 void ResumeSharedTimer(); |
| 38 | 36 |
| 39 void DoTimeout() { | 37 void DoTimeout() { |
| 40 if (shared_timer_func_ && !shared_timer_suspended_) | 38 if (shared_timer_func_ && !shared_timer_suspended_) |
| 41 shared_timer_func_(); | 39 shared_timer_func_(); |
| 42 } | 40 } |
| 43 | 41 |
| 44 base::MessageLoop* main_loop_; | 42 base::MessageLoop* main_loop_; |
| 45 base::OneShotTimer<PlatformImpl> shared_timer_; | 43 base::OneShotTimer<PlatformImpl> shared_timer_; |
| 46 void (*shared_timer_func_)(); | 44 void (*shared_timer_func_)(); |
| 47 double shared_timer_fire_time_; | 45 double shared_timer_fire_time_; |
| 48 bool shared_timer_fire_time_was_set_while_suspended_; | 46 bool shared_timer_fire_time_was_set_while_suspended_; |
| 49 int shared_timer_suspended_; // counter | 47 int shared_timer_suspended_; // counter |
| 50 WebThemeEngineImpl theme_engine_; | |
| 51 WebUnitTestSupportImpl unit_test_support_; | 48 WebUnitTestSupportImpl unit_test_support_; |
| 52 | 49 |
| 53 DISALLOW_COPY_AND_ASSIGN(PlatformImpl); | 50 DISALLOW_COPY_AND_ASSIGN(PlatformImpl); |
| 54 }; | 51 }; |
| 55 | 52 |
| 56 } // namespace sky | 53 } // namespace sky |
| 57 | 54 |
| 58 #endif // SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ | 55 #endif // SKY_ENGINE_TESTING_PLATFORM_PLATFORM_IMPL_H_ |
| OLD | NEW |