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 |