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

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

Issue 2503853002: [Sensors] Improvements in fetching reading for sensors with continuous reporting mode (Closed)
Patch Set: Fixed assertion hit Created 4 years, 1 month 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/ActiveDOMObject.h" 10 #include "core/dom/ActiveDOMObject.h"
11 #include "core/dom/ContextLifecycleObserver.h" 11 #include "core/dom/ContextLifecycleObserver.h"
12 #include "core/frame/PlatformEventController.h" 12 #include "core/frame/PlatformEventController.h"
13 #include "core/page/PageVisibilityObserver.h"
14 #include "modules/EventTargetModules.h" 13 #include "modules/EventTargetModules.h"
15 #include "modules/sensor/SensorOptions.h" 14 #include "modules/sensor/SensorOptions.h"
16 #include "modules/sensor/SensorProxy.h" 15 #include "modules/sensor/SensorProxy.h"
17 #include "platform/heap/Handle.h" 16 #include "platform/heap/Handle.h"
18 17
19 namespace blink { 18 namespace blink {
20 19
21 class ExceptionState; 20 class ExceptionState;
22 class ScriptState; 21 class ScriptState;
23 class SensorReading; 22 class SensorReading;
24 class SensorPollingStrategy; 23 class SensorUpdateNotificationStrategy;
25 24
26 class Sensor : public EventTargetWithInlineData, 25 class Sensor : public EventTargetWithInlineData,
27 public ActiveScriptWrappable, 26 public ActiveScriptWrappable,
28 public ContextLifecycleObserver, 27 public ContextLifecycleObserver,
29 public PageVisibilityObserver,
30 public SensorProxy::Observer { 28 public SensorProxy::Observer {
31 USING_GARBAGE_COLLECTED_MIXIN(Sensor); 29 USING_GARBAGE_COLLECTED_MIXIN(Sensor);
32 DEFINE_WRAPPERTYPEINFO(); 30 DEFINE_WRAPPERTYPEINFO();
33 31
34 public: 32 public:
35 enum class SensorState { Idle, Activating, Active, Errored }; 33 enum class SensorState { Idle, Activating, Active, Errored };
36 34
37 ~Sensor() override; 35 ~Sensor() override;
38 36
39 void start(ScriptState*, ExceptionState&); 37 void start(ScriptState*, ExceptionState&);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 80
83 // ContextLifecycleObserver overrides. 81 // ContextLifecycleObserver overrides.
84 void contextDestroyed() override; 82 void contextDestroyed() override;
85 83
86 // SensorController::Observer overrides. 84 // SensorController::Observer overrides.
87 void onSensorInitialized() override; 85 void onSensorInitialized() override;
88 void onSensorReadingChanged() override; 86 void onSensorReadingChanged() override;
89 void onSensorError(ExceptionCode, 87 void onSensorError(ExceptionCode,
90 const String& sanitizedMessage, 88 const String& sanitizedMessage,
91 const String& unsanitizedMessage) override; 89 const String& unsanitizedMessage) override;
90 void onSuspended() override;
92 91
93 void onStartRequestCompleted(bool); 92 void onStartRequestCompleted(bool);
94 void onStopRequestCompleted(bool); 93 void onStopRequestCompleted(bool);
95 94
96 // PageVisibilityObserver overrides.
97 void pageVisibilityChanged() override;
98
99 void startListening(); 95 void startListening();
100 void stopListening(); 96 void stopListening();
101 97
102 // Makes sensor reading refresh its values from the shared buffer. 98 void onSensorUpdateNotification();
103 void pollForData();
104 99
105 void updateState(SensorState newState); 100 void updateState(SensorState newState);
106 void reportError(ExceptionCode = UnknownError, 101 void reportError(ExceptionCode = UnknownError,
107 const String& sanitizedMessage = String(), 102 const String& sanitizedMessage = String(),
108 const String& unsanitizedMessage = String()); 103 const String& unsanitizedMessage = String());
109 104
110 void updatePollingStatus();
111
112 void notifySensorReadingChanged(); 105 void notifySensorReadingChanged();
113 void notifyOnActivate(); 106 void notifyOnActivate();
114 void notifyError(DOMException* error); 107 void notifyError(DOMException* error);
115 108
116 private: 109 private:
117 SensorOptions m_sensorOptions; 110 SensorOptions m_sensorOptions;
118 device::mojom::blink::SensorType m_type; 111 device::mojom::blink::SensorType m_type;
119 SensorState m_state; 112 SensorState m_state;
120 Member<SensorProxy> m_sensorProxy; 113 Member<SensorProxy> m_sensorProxy;
121 std::unique_ptr<SensorPollingStrategy> m_polling; 114 std::unique_ptr<SensorUpdateNotificationStrategy> m_sensorUpdateNotifier;
122 device::SensorReading m_storedData; 115 device::SensorReading m_storedData;
123 SensorConfigurationPtr m_configuration; 116 SensorConfigurationPtr m_configuration;
124 }; 117 };
125 118
126 } // namespace blink 119 } // namespace blink
127 120
128 #endif // Sensor_h 121 #endif // Sensor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698