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

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

Issue 2870073002: [Sensors] Decouple sensor readings update from rAF (Closed)
Patch Set: [Sensors] Decouple sensor readings update from rAF Created 3 years, 7 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 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 "core/dom/ContextLifecycleObserver.h" 8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "core/dom/DOMHighResTimeStamp.h" 9 #include "core/dom/DOMHighResTimeStamp.h"
10 #include "core/dom/DOMTimeStamp.h" 10 #include "core/dom/DOMTimeStamp.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // The default implementation will init frequency configuration parameter, 72 // The default implementation will init frequency configuration parameter,
73 // concrete sensor implementations can override this method to handle other 73 // concrete sensor implementations can override this method to handle other
74 // parameters if needed. 74 // parameters if needed.
75 virtual SensorConfigurationPtr CreateSensorConfig(); 75 virtual SensorConfigurationPtr CreateSensorConfig();
76 76
77 double ReadingValue(int index, bool& is_null) const; 77 double ReadingValue(int index, bool& is_null) const;
78 double ReadingValueUnchecked(int index) const; 78 double ReadingValueUnchecked(int index) const;
79 bool CanReturnReadings() const; 79 bool CanReturnReadings() const;
80 bool IsActivated() const { return state_ == SensorState::kActivated; } 80 bool IsActivated() const { return state_ == SensorState::kActivated; }
81 81
82 // SensorProxy::Observer overrides.
83 void OnSensorInitialized() override;
84 void OnSensorReadingChanged(double timestamp) override;
85 void OnSensorError(ExceptionCode,
86 const String& sanitized_message,
87 const String& unsanitized_message) override;
88
82 private: 89 private:
83 void InitSensorProxyIfNeeded(); 90 void InitSensorProxyIfNeeded();
84 91
85 // ContextLifecycleObserver overrides. 92 // ContextLifecycleObserver overrides.
86 void ContextDestroyed(ExecutionContext*) override; 93 void ContextDestroyed(ExecutionContext*) override;
87 94
88 // SensorProxy::Observer overrides.
89 void OnSensorInitialized() override;
90 void NotifySensorChanged(double timestamp) override;
91 void OnSensorError(ExceptionCode,
92 const String& sanitized_message,
93 const String& unsanitized_message) override;
94
95 void OnAddConfigurationRequestCompleted(bool); 95 void OnAddConfigurationRequestCompleted(bool);
96 96
97 void StartListening(); 97 void StartListening();
98 void StopListening(); 98 void StopListening();
99 99
100 void RequestAddConfiguration(); 100 void RequestAddConfiguration();
101 101
102 void UpdateState(SensorState new_state); 102 void UpdateState(SensorState new_state);
103 void HandleError(ExceptionCode = kUnknownError, 103 void HandleError(ExceptionCode = kUnknownError,
104 const String& sanitized_message = String(), 104 const String& sanitized_message = String(),
105 const String& unsanitized_message = String()); 105 const String& unsanitized_message = String());
106 106
107 void NotifySensorReadingChanged(); 107 void UpdateReading();
108 void NotifyOnActivate(); 108 void NotifyOnActivate();
109 void NotifyError(DOMException* error); 109 void NotifyError(DOMException* error);
110 110
111 private: 111 private:
112 SensorOptions sensor_options_; 112 SensorOptions sensor_options_;
113 device::mojom::blink::SensorType type_; 113 device::mojom::blink::SensorType type_;
114 SensorState state_; 114 SensorState state_;
115 Member<SensorProxy> sensor_proxy_; 115 Member<SensorProxy> sensor_proxy_;
116 device::SensorReading stored_data_; 116 device::SensorReading reading_;
117 SensorConfigurationPtr configuration_; 117 SensorConfigurationPtr configuration_;
118 double last_update_timestamp_; 118 double last_update_timestamp_;
119 bool pending_reading_update_;
119 }; 120 };
120 121
121 } // namespace blink 122 } // namespace blink
122 123
123 #endif // Sensor_h 124 #endif // Sensor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/OrientationSensor.cpp ('k') | third_party/WebKit/Source/modules/sensor/Sensor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698