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