Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: Source/core/frame/DeviceEventControllerBase.h

Issue 315573002: Generalize and refactor DeviceSensorEvent* architecture to support multi-event type targets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add stopUpdating in destructor of BatteryManager. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/frame/DeviceEventControllerBase.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DeviceEventControllerBase_h
6 #define DeviceEventControllerBase_h
7
8 #include "core/page/PageLifecycleObserver.h"
9 #include "platform/Timer.h"
10
11 namespace WebCore {
12
13 // Base controller class for registering controllers with a dispatcher.
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
16 // it available.
17 class DeviceEventControllerBase : public PageLifecycleObserver {
18 public:
19 void startUpdating();
20 void stopUpdating();
21
22 // This is called when new data becomes available.
23 virtual void didUpdateData() = 0;
24
25 protected:
26 explicit DeviceEventControllerBase(Page*);
27 virtual ~DeviceEventControllerBase();
28
29 virtual void registerWithDispatcher() = 0;
30 virtual void unregisterWithDispatcher() = 0;
31
32 // When true initiates a one-shot didUpdateData() when startUpdating() is ca lled.
33 virtual bool hasLastData() = 0;
34
35 bool m_hasEventListener;
36
37 private:
38 // Inherited from PageLifecycleObserver.
39 virtual void pageVisibilityChanged() OVERRIDE FINAL;
40
41 void oneShotCallback(Timer<DeviceEventControllerBase>*);
42
43 bool m_isActive;
44 Timer<DeviceEventControllerBase> m_timer;
45 };
46
47 } // namespace WebCore
48
49 #endif // DeviceEventControllerBase_h
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/frame/DeviceEventControllerBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698