| 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 DeviceEventControllerBase_h | 5 #ifndef PlatformEventController_h |
| 6 #define DeviceEventControllerBase_h | 6 #define PlatformEventController_h |
| 7 | 7 |
| 8 #include "core/page/PageLifecycleObserver.h" | 8 #include "core/page/PageLifecycleObserver.h" |
| 9 #include "platform/Timer.h" | 9 #include "platform/Timer.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 // Base controller class for registering controllers with a dispatcher. | 13 // Base controller class for registering controllers with a dispatcher. |
| 14 // It watches page visibility and calls stopUpdating when page is not visible. | 14 // It watches page visibility and calls stopUpdating when page is not visible. |
| 15 // It provides a didUpdateData() callback method which is called when new data | 15 // It provides a didUpdateData() callback method which is called when new data |
| 16 // it available. | 16 // it available. |
| 17 class DeviceEventControllerBase : public PageLifecycleObserver { | 17 class PlatformEventController : public PageLifecycleObserver { |
| 18 public: | 18 public: |
| 19 void startUpdating(); | 19 void startUpdating(); |
| 20 void stopUpdating(); | 20 void stopUpdating(); |
| 21 | 21 |
| 22 // This is called when new data becomes available. | 22 // This is called when new data becomes available. |
| 23 virtual void didUpdateData() = 0; | 23 virtual void didUpdateData() = 0; |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 explicit DeviceEventControllerBase(Page*); | 26 explicit PlatformEventController(Page*); |
| 27 virtual ~DeviceEventControllerBase(); | 27 virtual ~PlatformEventController(); |
| 28 | 28 |
| 29 virtual void registerWithDispatcher() = 0; | 29 virtual void registerWithDispatcher() = 0; |
| 30 virtual void unregisterWithDispatcher() = 0; | 30 virtual void unregisterWithDispatcher() = 0; |
| 31 | 31 |
| 32 // When true initiates a one-shot didUpdateData() when startUpdating() is ca
lled. | 32 // When true initiates a one-shot didUpdateData() when startUpdating() is ca
lled. |
| 33 virtual bool hasLastData() = 0; | 33 virtual bool hasLastData() = 0; |
| 34 | 34 |
| 35 bool m_hasEventListener; | 35 bool m_hasEventListener; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 // Inherited from PageLifecycleObserver. | 38 // Inherited from PageLifecycleObserver. |
| 39 virtual void pageVisibilityChanged() OVERRIDE; | 39 virtual void pageVisibilityChanged() OVERRIDE; |
| 40 | 40 |
| 41 void oneShotCallback(Timer<DeviceEventControllerBase>*); | 41 void oneShotCallback(Timer<PlatformEventController>*); |
| 42 | 42 |
| 43 bool m_isActive; | 43 bool m_isActive; |
| 44 Timer<DeviceEventControllerBase> m_timer; | 44 Timer<PlatformEventController> m_timer; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 } // namespace blink | 47 } // namespace blink |
| 48 | 48 |
| 49 #endif // DeviceEventControllerBase_h | 49 #endif // PlatformEventController_h |
| OLD | NEW |