Chromium Code Reviews| 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) |
| + return 0.0; |
| + |
| + LocalDOMWindow* window = m_context->executingWindow(); |
|
haraken
2016/09/06 05:04:29
This is retrieving a wrong window.
Alternately yo
|
| + if (!window) |
| + return 0.0; |
| + |
| + Performance* performance = DOMWindowPerformance::performance(*window); |
| + if (!performance) |
|
haraken
2016/09/06 05:04:29
This shouldn't be nullptr.
|
| + return 0.0; |
| + |
| + return performance->monotonicTimeToDOMHighResTimeStamp(m_sensorProxy->reading().timestamp); |
| } |
| } // namespace blink |