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

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

Issue 2746573002: [Sensors] Implement bindings for AbsoluteOrientationSensor (Closed)
Patch Set: webexpose Created 3 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 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"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 ExceptionState&, 66 ExceptionState&,
67 device::mojom::blink::SensorType); 67 device::mojom::blink::SensorType);
68 68
69 using SensorConfigurationPtr = device::mojom::blink::SensorConfigurationPtr; 69 using SensorConfigurationPtr = device::mojom::blink::SensorConfigurationPtr;
70 using SensorConfiguration = device::mojom::blink::SensorConfiguration; 70 using SensorConfiguration = device::mojom::blink::SensorConfiguration;
71 71
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 double readingValue(int index, bool& isNull) const; 77 double readingValue(int index, bool& isNull) const;
78 double readingValueUnchecked(int index) const;
79 bool canReturnReadings() const;
80 bool isActivated() const { return m_state == SensorState::Activated; }
77 81
78 private: 82 private:
79 void initSensorProxyIfNeeded(); 83 void initSensorProxyIfNeeded();
80 84
81 // ContextLifecycleObserver overrides. 85 // ContextLifecycleObserver overrides.
82 void contextDestroyed(ExecutionContext*) override; 86 void contextDestroyed(ExecutionContext*) override;
83 87
84 // SensorController::Observer overrides. 88 // SensorProxy::Observer overrides.
85 void onSensorInitialized() override; 89 void onSensorInitialized() override;
86 void onSensorReadingChanged(double timestamp) override; 90 void notifySensorChanged(double timestamp) override;
87 void onSensorError(ExceptionCode, 91 void onSensorError(ExceptionCode,
88 const String& sanitizedMessage, 92 const String& sanitizedMessage,
89 const String& unsanitizedMessage) override; 93 const String& unsanitizedMessage) override;
90 94
91 void onStartRequestCompleted(bool); 95 void onStartRequestCompleted(bool);
92 void onStopRequestCompleted(bool); 96 void onStopRequestCompleted(bool);
93 97
94 void startListening(); 98 void startListening();
95 void stopListening(); 99 void stopListening();
96 100
97 void updateState(SensorState newState); 101 void updateState(SensorState newState);
98 void reportError(ExceptionCode = UnknownError, 102 void reportError(ExceptionCode = UnknownError,
99 const String& sanitizedMessage = String(), 103 const String& sanitizedMessage = String(),
100 const String& unsanitizedMessage = String()); 104 const String& unsanitizedMessage = String());
101 105
102 void notifySensorReadingChanged(); 106 void notifySensorReadingChanged();
103 void notifyOnActivate(); 107 void notifyOnActivate();
104 void notifyError(DOMException* error); 108 void notifyError(DOMException* error);
105 109
106 bool canReturnReadings() const;
107
108 private: 110 private:
109 SensorOptions m_sensorOptions; 111 SensorOptions m_sensorOptions;
110 device::mojom::blink::SensorType m_type; 112 device::mojom::blink::SensorType m_type;
111 SensorState m_state; 113 SensorState m_state;
112 Member<SensorProxy> m_sensorProxy; 114 Member<SensorProxy> m_sensorProxy;
113 device::SensorReading m_storedData; 115 device::SensorReading m_storedData;
114 SensorConfigurationPtr m_configuration; 116 SensorConfigurationPtr m_configuration;
115 double m_lastUpdateTimestamp; 117 double m_lastUpdateTimestamp;
116 }; 118 };
117 119
118 } // namespace blink 120 } // namespace blink
119 121
120 #endif // Sensor_h 122 #endif // Sensor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/OrientationSensor.idl ('k') | third_party/WebKit/Source/modules/sensor/Sensor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698