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

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

Issue 2121313002: [sensors] Generic Sensors Framework blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sensors_mojo_interfaces
Patch Set: Comments from Tim 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..d7dcdbf42d2e2bac106ca7e60fcf982fc3a679c2 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorReading.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorReading.cpp
@@ -4,33 +4,49 @@
#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(ExecutionContext* context)
+ : m_context(context)
{
}
-SensorReading::SensorReading(bool providesTimeStamp, DOMHighResTimeStamp timeStamp)
- : m_canProvideTimeStamp(providesTimeStamp)
- , m_timeStamp(timeStamp)
+DEFINE_TRACE(SensorReading)
{
+ visitor->trace(m_sensorProxy);
+ visitor->trace(m_context);
}
-DOMHighResTimeStamp SensorReading::timeStamp(bool& isNull)
+void SensorReading::attach(SensorProxy* sensorProxy)
{
- if (m_canProvideTimeStamp)
- return m_timeStamp;
-
- isNull = true;
- return 0;
+ DCHECK(sensorProxy);
+ m_sensorProxy = sensorProxy;
}
-SensorReading::~SensorReading()
+void SensorReading::detach()
{
+ m_sensorProxy = nullptr;
}
-DEFINE_TRACE(SensorReading)
+DOMHighResTimeStamp SensorReading::timeStamp() const
{
+ if (!m_sensorProxy || !m_context)
timvolodine 2016/09/02 19:41:29 I actually meant this (shorter and more readable):
Mikhail 2016/09/05 10:26:27 Unfortunately two new variables are created here (
timvolodine 2016/09/05 23:22:40 yeah sorry my bad (technically I think you could
+ return 0.0;
+
+ LocalDOMWindow* window = m_context->executingWindow();
+ if (!window)
+ return 0.0;
+
+ Performance* performance = DOMWindowPerformance::performance(*window);
+ if (!performance)
+ return 0.0;
+
+ return performance->monotonicTimeToDOMHighResTimeStamp(m_sensorProxy->reading().timestamp);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698