| 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..a56b12342178253286749adb63ecd03427d728eb 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 || 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));
|
| m_hasPendingAnimationFrameTask = true;
|
| }
|
|
|
| @@ -36,6 +47,7 @@ void SensorReadingUpdater::onAnimationFrame() {
|
| }
|
|
|
| DEFINE_TRACE(SensorReadingUpdater) {
|
| + visitor->trace(m_document);
|
| visitor->trace(m_sensorProxy);
|
| }
|
|
|
|
|