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

Side by Side Diff: content/renderer/device_sensors/device_sensor_event_pump.h

Issue 1091093006: Update {virtual,override} to follow C++11 style in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back out some webrtc files. Created 5 years, 8 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
OLDNEW
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 CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ 5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_
6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_
7 7
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
11 #include "content/public/renderer/platform_event_observer.h" 11 #include "content/public/renderer/platform_event_observer.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 template <typename ListenerType> 15 template <typename ListenerType>
16 class CONTENT_EXPORT DeviceSensorEventPump 16 class CONTENT_EXPORT DeviceSensorEventPump
17 : NON_EXPORTED_BASE(public PlatformEventObserver<ListenerType>) { 17 : NON_EXPORTED_BASE(public PlatformEventObserver<ListenerType>) {
18 public: 18 public:
19 // Default rate for firing events. 19 // Default rate for firing events.
20 static const int kDefaultPumpFrequencyHz = 60; 20 static const int kDefaultPumpFrequencyHz = 60;
21 static const int kDefaultPumpDelayMicroseconds = 21 static const int kDefaultPumpDelayMicroseconds =
22 base::Time::kMicrosecondsPerSecond / kDefaultPumpFrequencyHz; 22 base::Time::kMicrosecondsPerSecond / kDefaultPumpFrequencyHz;
23 23
24 // PlatformEventObserver 24 // PlatformEventObserver
25 virtual void Start(blink::WebPlatformEventListener* listener) override { 25 void Start(blink::WebPlatformEventListener* listener) override {
26 DVLOG(2) << "requested start"; 26 DVLOG(2) << "requested start";
27 27
28 if (state_ != STOPPED) 28 if (state_ != STOPPED)
29 return; 29 return;
30 30
31 DCHECK(!timer_.IsRunning()); 31 DCHECK(!timer_.IsRunning());
32 32
33 PlatformEventObserver<ListenerType>::Start(listener); 33 PlatformEventObserver<ListenerType>::Start(listener);
34 state_ = PENDING_START; 34 state_ = PENDING_START;
35 } 35 }
36 36
37 virtual void Stop() override { 37 void Stop() override {
38 DVLOG(2) << "stop"; 38 DVLOG(2) << "stop";
39 39
40 if (state_ == STOPPED) 40 if (state_ == STOPPED)
41 return; 41 return;
42 42
43 DCHECK((state_ == PENDING_START && !timer_.IsRunning()) || 43 DCHECK((state_ == PENDING_START && !timer_.IsRunning()) ||
44 (state_ == RUNNING && timer_.IsRunning())); 44 (state_ == RUNNING && timer_.IsRunning()));
45 45
46 if (timer_.IsRunning()) 46 if (timer_.IsRunning())
47 timer_.Stop(); 47 timer_.Stop();
48 PlatformEventObserver<ListenerType>::Stop(); 48 PlatformEventObserver<ListenerType>::Stop();
49 state_ = STOPPED; 49 state_ = STOPPED;
50 } 50 }
51 51
52 protected: 52 protected:
53 explicit DeviceSensorEventPump(RenderThread* thread) 53 explicit DeviceSensorEventPump(RenderThread* thread)
54 : PlatformEventObserver<ListenerType>(thread), 54 : PlatformEventObserver<ListenerType>(thread),
55 pump_delay_microseconds_(kDefaultPumpDelayMicroseconds), 55 pump_delay_microseconds_(kDefaultPumpDelayMicroseconds),
56 state_(STOPPED) {} 56 state_(STOPPED) {}
57 57
58 virtual ~DeviceSensorEventPump() { 58 ~DeviceSensorEventPump() override {
59 PlatformEventObserver<ListenerType>::StopIfObserving(); 59 PlatformEventObserver<ListenerType>::StopIfObserving();
60 } 60 }
61 61
62 // The pump is a tri-state automaton with allowed transitions as follows: 62 // The pump is a tri-state automaton with allowed transitions as follows:
63 // STOPPED -> PENDING_START 63 // STOPPED -> PENDING_START
64 // PENDING_START -> RUNNING 64 // PENDING_START -> RUNNING
65 // PENDING_START -> STOPPED 65 // PENDING_START -> STOPPED
66 // RUNNING -> STOPPED 66 // RUNNING -> STOPPED
67 enum PumpState { 67 enum PumpState {
68 STOPPED, 68 STOPPED,
(...skipping 24 matching lines...) Expand all
93 int pump_delay_microseconds_; 93 int pump_delay_microseconds_;
94 PumpState state_; 94 PumpState state_;
95 base::RepeatingTimer<DeviceSensorEventPump> timer_; 95 base::RepeatingTimer<DeviceSensorEventPump> timer_;
96 96
97 DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump); 97 DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump);
98 }; 98 };
99 99
100 } // namespace content 100 } // namespace content
101 101
102 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ 102 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_
OLDNEW
« no previous file with comments | « content/public/test/mock_render_thread.h ('k') | content/renderer/input/input_handler_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698