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..0c938d16ce544fa9694dba4f7719ebe81db9e0de 100644 |
| --- a/third_party/WebKit/Source/modules/sensor/SensorReadingUpdater.cpp |
| +++ b/third_party/WebKit/Source/modules/sensor/SensorReadingUpdater.cpp |
| @@ -17,12 +17,21 @@ SensorReadingUpdater::SensorReadingUpdater(SensorProxy* sensorProxy) |
| : m_sensorProxy(sensorProxy), m_hasPendingAnimationFrameTask(false) {} |
| void SensorReadingUpdater::enqueueAnimationFrameTask() { |
| + if (!m_document || m_document->isDetached()) { |
|
haraken
2017/01/25 18:20:06
Will the following work?
- Make SensorReadingUpda
Mikhail
2017/01/26 06:19:59
As far as I see, ContextClient contains ExecutionC
|
| + // If the document has detached the scheduled callbacks |
| + // will never be called. |
| + m_hasPendingAnimationFrameTask = false; |
| + m_document = m_sensorProxy->document(); |
|
haraken
2017/01/25 18:20:06
Can we set m_document in SensorReadingUpdater's co
Mikhail
2017/01/26 06:19:59
Done.
|
| + if (!m_document) |
| + 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 +45,7 @@ void SensorReadingUpdater::onAnimationFrame() { |
| } |
| DEFINE_TRACE(SensorReadingUpdater) { |
| + visitor->trace(m_document); |
| visitor->trace(m_sensorProxy); |
| } |