Skip to content

Commit

Permalink
Revert of ServiceWorkerWriteToCacheJob: refactor (patchset chromium#3
Browse files Browse the repository at this point in the history
…id:40001 of https://codereview.chromium.org/1356153002/ )

Reason for revert:
This change has broken the Service Worker update logic.
See crbug.com/537098

Original issue's description:
> ServiceWorkerWriteToCacheJob: refactor
>
> This CL is a re-land of a previously reviewed and approved CL that was reverted: https://codereview.chromium.org/1315443003
>
> ServiceWorkerWriteToCacheJob is a subclass of URLRequestJob that is responsible for filling and updating a write-through cache for ServiceWorker data. Specifically, ServiceWorkerWriteToCacheJob creates an underlying URLRequestJob which it uses to do the actual network request for the script, then returns the script body to the creator of the ServiceWorkerWriteToCacheJob while also storing it in the ServiceWorker cache if it has been updated.
>
> In order to avoid spurious cache rewrites, ServiceWorkerWriteToCacheJob defers writing an entry for as long as possible: if there is an existing entry, it compares incoming network data to the cache entry's data, and only starts writing once there is a mismatch. Since the mismatch may occur after much data has already been handled, once this happens ServiceWorkerWriteToCacheJob must transparently copy all the existing data up to that point from the cache, then resume streaming network data into the cache and back to its consumer. This is the "compare-and-copy" process. If there is no existing entry, network data is streamed directly to the cache; this is the "passthrough" process.
>
> This CL removes the code implementing the compare-and-copy and passthrough processes from ServiceWorkerWriteToCacheJob and moves it into a separate class, ServiceWorkerCacheWriter. ServiceWorkerCacheWriter exposes an asynchronous API for overwriting a single cache entry that is now used by ServiceWorkerWriteToCacheJob.
>
> BUG=474859
> TBR=jochen,falken
>
> Committed: https://crrev.com/d778a5a82cdccab2b3cbf4940749753c98e59dcc
> Cr-Commit-Position: refs/heads/master@{#349669}
>
> patch from issue 1315443003 at patchset 260001 (http://crrev.com/1315443003#ps260001)
>
> Committed: https://crrev.com/015f4a69ad39e4625648e160dde9b75f8aaad522
> Cr-Commit-Position: refs/heads/master@{#350824}

TBR=mmenke@chromium.org,falken@chromium.org,ellyjones@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=474859

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

Cr-Commit-Position: refs/heads/master@{#351264}
  • Loading branch information
horo-t authored and Commit bot committed Sep 29, 2015
1 parent 1ba2e7b commit 2ec1d6f
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 1,578 deletions.
11 changes: 4 additions & 7 deletions content/browser/appcache/appcache_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,8 @@ class CONTENT_EXPORT AppCacheResponseWriter
// negative error code or the number of bytes written. The 'callback' is a
// required parameter. The contents of 'info_buf' are not modified.
// Should only be called where there is no Write operation in progress.
// (virtual for testing)
virtual void WriteInfo(HttpResponseInfoIOBuffer* info_buf,
const net::CompletionCallback& callback);
void WriteInfo(HttpResponseInfoIOBuffer* info_buf,
const net::CompletionCallback& callback);

// Writes data to storage. Always returns the result of the write
// asynchronously through the 'callback'. Returns the number of bytes written
Expand All @@ -221,10 +220,8 @@ class CONTENT_EXPORT AppCacheResponseWriter
// the number of bytes written. The 'callback' is a required parameter.
// The contents of 'buf' are not modified.
// Should only be called where there is no Write operation in progress.
// (virtual for testing)
virtual void WriteData(net::IOBuffer* buf,
int buf_len,
const net::CompletionCallback& callback);
void WriteData(net::IOBuffer* buf, int buf_len,
const net::CompletionCallback& callback);

// Returns true if there is a write pending.
bool IsWritePending() { return IsIOPending(); }
Expand Down
Loading

0 comments on commit 2ec1d6f

Please sign in to comment.