[ServiceWorker] Avoid using stale pointer of EmbeddedWorkerInstance
We're saving the raw pointer of an EmbeddedWorkerInstance in a base::ScopedObserver member of ServiceWorkerRegisterJob, but, the EmbeddedWorkerInstance is not guaranteed to outlive the ServiceWorkerRegisterJob, it may get destroyed and lead to a situation that ServiceWorkerRegisterJob holds a stale pointer, which could lead to crash. This CL lets ServiceWorkerRegisterJob listen OnDetached() from the EmbeddedWorkerInstance so it can be aware that the EmbeddedWorkerInstanc pointer is going to be stale and should be removed from the source list of base::ScopedObserver. This fix should be safe enough now, but in longer term we'll try to remove EmbeddedWorkerInstance::Listener interface and let EmbeddedWorkerInstance talk directly to its owner ServiceWorkerVersion, then let ServiceWorkerRegisterJob observe the ServiceWorkerVersion it's manipulating to get OnScriptLoaded() notification. BUG=854063,855394 Change-Id: I9c5a46beda1aafff32a86b9055be2b53d50fda97 Reviewed-on: https://chromium-review.googlesource.com/1112904 Commit-Queue: Han Leon <leon.han@intel.com> Reviewed-by:Matt Falkenhagen <falken@chromium.org> Cr-Commit-Position: refs/heads/master@{#569906}
Showing
Please register or sign in to comment