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

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

Issue 2317743002: [Sensors] Implementation of the Generic Sensor API (Closed)
Patch Set: Comments from Tim and haraken Created 4 years, 3 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/SensorReading.cpp
diff --git a/third_party/WebKit/Source/modules/sensor/SensorReading.cpp b/third_party/WebKit/Source/modules/sensor/SensorReading.cpp
index 9eb63d020623789918c2b59697b9332bb8155687..12c14881bc9af7be3a74f93e364ea500abd8c641 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorReading.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorReading.cpp
@@ -4,33 +4,34 @@
#include "modules/sensor/SensorReading.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/frame/LocalDOMWindow.h"
+#include "core/timing/DOMWindowPerformance.h"
+#include "core/timing/Performance.h"
+
namespace blink {
-SensorReading::SensorReading()
+SensorReading::SensorReading(SensorProxy* sensorProxy)
+ : m_sensorProxy(sensorProxy)
{
+ DCHECK(m_sensorProxy);
}
-SensorReading::SensorReading(bool providesTimeStamp, DOMHighResTimeStamp timeStamp)
- : m_canProvideTimeStamp(providesTimeStamp)
- , m_timeStamp(timeStamp)
+DEFINE_TRACE(SensorReading)
{
+ visitor->trace(m_sensorProxy);
}
-DOMHighResTimeStamp SensorReading::timeStamp(bool& isNull)
+DOMHighResTimeStamp SensorReading::timeStamp(ScriptState* scriptState) const
{
- if (m_canProvideTimeStamp)
- return m_timeStamp;
-
- isNull = true;
- return 0;
-}
+ LocalDOMWindow* window = scriptState->domWindow();
+ if (!window)
+ return 0.0;
-SensorReading::~SensorReading()
-{
-}
+ Performance* performance = DOMWindowPerformance::performance(*window);
+ DCHECK(performance);
-DEFINE_TRACE(SensorReading)
-{
+ return performance->monotonicTimeToDOMHighResTimeStamp(m_sensorProxy->reading().timestamp);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/SensorReading.h ('k') | third_party/WebKit/Source/modules/sensor/SensorReading.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698