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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/Sensor.h

Issue 2590513002: Revert of [Sensors] Align sensor reading updates and 'onchange' notification with rAF. (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Sensor_h 5 #ifndef Sensor_h
6 #define Sensor_h 6 #define Sensor_h
7 7
8 #include "bindings/core/v8/ActiveScriptWrappable.h" 8 #include "bindings/core/v8/ActiveScriptWrappable.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/dom/ContextLifecycleObserver.h" 10 #include "core/dom/ContextLifecycleObserver.h"
11 #include "core/dom/SuspendableObject.h" 11 #include "core/dom/SuspendableObject.h"
12 #include "core/frame/PlatformEventController.h" 12 #include "core/frame/PlatformEventController.h"
13 #include "modules/EventTargetModules.h" 13 #include "modules/EventTargetModules.h"
14 #include "modules/sensor/SensorOptions.h" 14 #include "modules/sensor/SensorOptions.h"
15 #include "modules/sensor/SensorProxy.h" 15 #include "modules/sensor/SensorProxy.h"
16 #include "platform/heap/Handle.h" 16 #include "platform/heap/Handle.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class ExceptionState; 20 class ExceptionState;
21 class ExecutionContext; 21 class ExecutionContext;
22 class SensorReading; 22 class SensorReading;
23 class SensorUpdateNotificationStrategy;
23 24
24 class Sensor : public EventTargetWithInlineData, 25 class Sensor : public EventTargetWithInlineData,
25 public ActiveScriptWrappable<Sensor>, 26 public ActiveScriptWrappable<Sensor>,
26 public ContextLifecycleObserver, 27 public ContextLifecycleObserver,
27 public SensorProxy::Observer { 28 public SensorProxy::Observer {
28 USING_GARBAGE_COLLECTED_MIXIN(Sensor); 29 USING_GARBAGE_COLLECTED_MIXIN(Sensor);
29 DEFINE_WRAPPERTYPEINFO(); 30 DEFINE_WRAPPERTYPEINFO();
30 31
31 public: 32 public:
32 enum class SensorState { Idle, Activating, Activated, Errored }; 33 enum class SensorState { Idle, Activating, Activated, Errored };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 virtual SensorConfigurationPtr createSensorConfig(); 76 virtual SensorConfigurationPtr createSensorConfig();
76 77
77 private: 78 private:
78 void initSensorProxyIfNeeded(); 79 void initSensorProxyIfNeeded();
79 80
80 // ContextLifecycleObserver overrides. 81 // ContextLifecycleObserver overrides.
81 void contextDestroyed() override; 82 void contextDestroyed() override;
82 83
83 // SensorController::Observer overrides. 84 // SensorController::Observer overrides.
84 void onSensorInitialized() override; 85 void onSensorInitialized() override;
85 void onSensorReadingChanged(double timestamp) override; 86 void onSensorReadingChanged() override;
86 void onSensorError(ExceptionCode, 87 void onSensorError(ExceptionCode,
87 const String& sanitizedMessage, 88 const String& sanitizedMessage,
88 const String& unsanitizedMessage) override; 89 const String& unsanitizedMessage) override;
90 void onSuspended() override;
89 91
90 void onStartRequestCompleted(bool); 92 void onStartRequestCompleted(bool);
91 void onStopRequestCompleted(bool); 93 void onStopRequestCompleted(bool);
92 94
93 void startListening(); 95 void startListening();
94 void stopListening(); 96 void stopListening();
95 97
98 void onSensorUpdateNotification();
99
96 void updateState(SensorState newState); 100 void updateState(SensorState newState);
97 void reportError(ExceptionCode = UnknownError, 101 void reportError(ExceptionCode = UnknownError,
98 const String& sanitizedMessage = String(), 102 const String& sanitizedMessage = String(),
99 const String& unsanitizedMessage = String()); 103 const String& unsanitizedMessage = String());
100 104
101 void notifySensorReadingChanged(); 105 void notifySensorReadingChanged();
102 void notifyOnActivate(); 106 void notifyOnActivate();
103 void notifyError(DOMException* error); 107 void notifyError(DOMException* error);
104 108
105 private: 109 private:
106 SensorOptions m_sensorOptions; 110 SensorOptions m_sensorOptions;
107 device::mojom::blink::SensorType m_type; 111 device::mojom::blink::SensorType m_type;
108 SensorState m_state; 112 SensorState m_state;
109 Member<SensorProxy> m_sensorProxy; 113 Member<SensorProxy> m_sensorProxy;
114 std::unique_ptr<SensorUpdateNotificationStrategy> m_sensorUpdateNotifier;
110 device::SensorReading m_storedData; 115 device::SensorReading m_storedData;
111 SensorConfigurationPtr m_configuration; 116 SensorConfigurationPtr m_configuration;
112 double m_lastUpdateTimestamp;
113 }; 117 };
114 118
115 } // namespace blink 119 } // namespace blink
116 120
117 #endif // Sensor_h 121 #endif // Sensor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/BUILD.gn ('k') | third_party/WebKit/Source/modules/sensor/Sensor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698