[ServiceWorkerCache] Fix a race in the scheduler.
commit9f1cb7cdbfae306b800095b5e3ab322796728092
authorjkarlin <jkarlin@chromium.org>
Fri, 6 Mar 2015 00:55:26 +0000 (5 16:55 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 6 Mar 2015 00:56:40 +0000 (6 00:56 +0000)
tree11499ee6d74942113b52beb462325d43581dc76a
parent879199cfc3fd23829d6bf4d0f7a0202ee3805bbd
[ServiceWorkerCache] Fix a race in the scheduler.

If the scheduler's closure is synchronous it can wind up popping its
callback from the queue (causing the closure to be deleted if it's the
last reference) while the callback is running. If the closure holds a
refptr that owns the scheduler, bad things happen.

The fix is to hold a reference to the closure while it's running.

To make the scheduler a bit easier to read, rather than pop the queue
after the operation completes, it now pops it before running the
operation.

BUG=463782

Review URL: https://codereview.chromium.org/978383003

Cr-Commit-Position: refs/heads/master@{#319381}
content/browser/service_worker/service_worker_cache.cc
content/browser/service_worker/service_worker_cache_scheduler.cc
content/browser/service_worker/service_worker_cache_scheduler.h
content/browser/service_worker/service_worker_cache_storage.cc