ServiceWorker: Check the existence of the disk cache before access

This CL wraps AppCacheDiskCacheInterface with base::WeakPtr and makes
AppCacheResponseIO check it before access to avoid a crash.

<Before this CL>

Derivatives of AppCacheResponseIO (ServiceWorkerResponseWriter etc) has a raw
pointer to AppCacheDiskCacheInterface implementation and the implementation is
owned by storage implementation, namely, AppCacheStorageImpl or
ServiceWorkerStorage.

When ServiceWorkerStorage is destroyed because of storage recovery while
ServiceWorkerCacheWriter is asynchronously running, the cache writer asks the
response writer to store data in the disk cache and it crashes because of the
dangling pointer.

<After this CL>

ServiceWorkerResponseWriter checks the existence of the disk cache by
base::WeakPtr before access and simply fails the request if it is already gone.

BUG=600542

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

Cr-Commit-Position: refs/heads/master@{#385638}
9 files changed