| 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..cfb4280e2da02112f7fcb4bbf3f28c46cc5fbee8 100644
|
| --- a/third_party/WebKit/Source/modules/sensor/SensorReading.cpp
|
| +++ b/third_party/WebKit/Source/modules/sensor/SensorReading.cpp
|
| @@ -4,33 +4,50 @@
|
|
|
| #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"
|
| +#include "modules/sensor/SensorProxy.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_context)
|
| + 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(platformTimeStamp());
|
| }
|
|
|
| } // namespace blink
|
|
|