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

Unified Diff: third_party/WebKit/Source/modules/sensor/PressureSensorReading.cpp

Issue 2051083002: WIP : Generic Sensor API implementation Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/sensor/PressureSensorReading.cpp
diff --git a/third_party/WebKit/Source/modules/sensor/PressureSensorReading.cpp b/third_party/WebKit/Source/modules/sensor/PressureSensorReading.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f200e34ec972ce065b7cb5b5eb6319491f058d07
--- /dev/null
+++ b/third_party/WebKit/Source/modules/sensor/PressureSensorReading.cpp
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/sensor/PressureSensorReading.h"
+
+namespace blink {
+
+PressureSensorReading::PressureSensorReading(SensorController* controller)
+ : SensorReading(controller)
+{
+}
+
+DEFINE_TRACE(PressureSensorReading)
+{
+ SensorReading::trace(visitor);
+}
+
+DOMHighResTimeStamp PressureSensorReading::timeStamp() const
+{
+ refreshData();
+ return m_data.timestamp;
+}
+
+double PressureSensorReading::pressure() const
+{
+ refreshData();
+ return m_data.pressure;
+}
+
+auto PressureSensorReading::updateInternalData() -> UpdateStatus
+{
+ if (!m_controller || !m_controller->isInitialized())
+ return Error;
+
+ double previous = m_data.pressure;
+
+ refreshData();
+
+// WTFLogAlways("PressureSensorReading::updateInternalData: %f, time: %f", m_data.pressure, m_data.timestamp);
+
+ return (previous != m_data.pressure) ? Updated : Same;
+}
+
+void PressureSensorReading::refreshData() const
+{
+ if (!m_controller || !m_controller->isInitialized())
+ return;
+ m_data = *m_controller->reading<Data>();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698