• Yury Semikhatsky's avatar
    [DevTools] Properly notify devtools agent host when service worker is destroyed · 1537d629
    Yury Semikhatsky authored
    ServiceWorkerDevToolsAgentHost now stores thread-safe reference to
    ServiceWorkerContextWrapper instead of ServiceWorkerContextCore that
    could be deleted asynchronously on the service worker core thread.
    
    WorkerDestroyed notification is now sent to the observers of
    ServiceWorkerDevToolsManager iff the worker version is both stopped
    and doomed. Each worker can be terminated (and restarted) multiple times
    and will result in a sequence of targetCrashed/targetReloadedAfterCrash
    events in the protocol but the instance of its
    ServiceWorkerDevToolsAgentHost will survive restarts and all connected
    sessions will be preserved.
    
    It fixes the events generated in the protocol for service workers from
    targetCreated, (detachedFromTarget, attachedToTarget, targetReloadedAfterCrash)* to
    targetCreated, (targetCrashed/targetReloadedAfterCrash)*, targetDestroyed
    and avoids inadvertent session terminations when workers are stopped and
    also spurious targetReloadedAfterCrash events.
    
    Bug: none
    Change-Id: I1125604d08b7842f7f8d74751091193b9af2cb59
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099590
    Commit-Queue: Yury Semikhatsky <yurys@chromium.org>
    Reviewed-by: default avatarTsuyoshi Horo <horo@chromium.org>
    Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#750975}
    1537d629
service_worker_devtools_manager.h 5.36 KB