Chromium Code Reviews| Index: third_party/WebKit/Source/modules/sensor/SensorReadingUpdater.cpp |
| diff --git a/third_party/WebKit/Source/modules/sensor/SensorReadingUpdater.cpp b/third_party/WebKit/Source/modules/sensor/SensorReadingUpdater.cpp |
| index 3d35f7da1f8c0a31755ddbe5f2056c1113818b68..73c966f4c574db19c1a33d66b89f798dd873d27a 100644 |
| --- a/third_party/WebKit/Source/modules/sensor/SensorReadingUpdater.cpp |
| +++ b/third_party/WebKit/Source/modules/sensor/SensorReadingUpdater.cpp |
| @@ -14,15 +14,26 @@ using device::mojom::blink::ReportingMode; |
| namespace blink { |
| SensorReadingUpdater::SensorReadingUpdater(SensorProxy* sensorProxy) |
| - : m_sensorProxy(sensorProxy), m_hasPendingAnimationFrameTask(false) {} |
| + : m_sensorProxy(sensorProxy), |
| + m_document(m_sensorProxy->document()), |
| + m_hasPendingAnimationFrameTask(false) {} |
| void SensorReadingUpdater::enqueueAnimationFrameTask() { |
| + if (!m_document || m_document->isDetached()) { |
| + // If the document has detached the scheduled callbacks |
| + // will never be called. |
| + m_hasPendingAnimationFrameTask = false; |
| + m_document = m_sensorProxy->document(); |
| + if (!m_document) |
|
haraken
2017/01/27 11:30:33
Don't you need to add '|| m_document->isDetached()
|
| + return; |
| + } |
| + |
| if (m_hasPendingAnimationFrameTask) |
| return; |
| auto callback = WTF::bind(&SensorReadingUpdater::onAnimationFrame, |
| wrapWeakPersistent(this)); |
| - m_sensorProxy->document()->enqueueAnimationFrameTask(std::move(callback)); |
| + m_document->enqueueAnimationFrameTask(std::move(callback)); |
|
haraken
2017/01/26 22:24:14
A final question: Why do you need m_document in th
|
| m_hasPendingAnimationFrameTask = true; |
| } |
| @@ -36,6 +47,7 @@ void SensorReadingUpdater::onAnimationFrame() { |
| } |
| DEFINE_TRACE(SensorReadingUpdater) { |
| + visitor->trace(m_document); |
| visitor->trace(m_sensorProxy); |
| } |