Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Issue 1315443003: ServiceWorkerWriteToCacheJob: refactor (Closed)

Created:
5 years, 4 months ago by Elly Fong-Jones
Modified:
5 years, 3 months ago
CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, tzik, serviceworker-reviews, jam, nhiroki, darin-cc_chromium.org, horo+watch_chromium.org, kinuko+serviceworker, kinuko+watch, blink-worker-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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 Committed: https://crrev.com/d778a5a82cdccab2b3cbf4940749753c98e59dcc Cr-Commit-Position: refs/heads/master@{#349669}

Patch Set 1 #

Patch Set 2 : first draft #

Total comments: 16

Patch Set 3 : First round of fixes #

Patch Set 4 : StateMachine -> DoLoop #

Total comments: 14

Patch Set 5 : Second round #

Total comments: 52

Patch Set 6 : Next round. Fixed unit tests & ReadRawData structure. #

Total comments: 4

Patch Set 7 : Last nits for falken #

Total comments: 1

Patch Set 8 : Annotate virtual methods #

Total comments: 18

Patch Set 9 : Proper DoLoop pattern #

Total comments: 21

Patch Set 10 : Documentation fixes #

Patch Set 11 : Fix bogus DCHECK #

Patch Set 12 : CONTENT_EXPORT ServiceWorkerCacheWriter #

Patch Set 13 : Pull in CONTENT_EXPORT header #

Patch Set 14 : Fix broken include #

Patch Set 15 : Fixes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1578 lines, -504 lines) Patch
M content/browser/appcache/appcache_response.h View 1 2 3 4 5 6 7 2 chunks +7 lines, -4 lines 0 comments Download
A content/browser/service_worker/service_worker_cache_writer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +230 lines, -0 lines 0 comments Download
A content/browser/service_worker/service_worker_cache_writer.cc View 1 2 3 4 5 6 7 8 9 1 chunk +498 lines, -0 lines 0 comments Download
A content/browser/service_worker/service_worker_cache_writer_unittest.cc View 1 2 3 4 5 1 chunk +697 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_write_to_cache_job.h View 1 2 3 4 5 6 7 8 5 chunks +20 lines, -22 lines 0 comments Download
M content/browser/service_worker/service_worker_write_to_cache_job.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 18 chunks +123 lines, -478 lines 0 comments Download
M content/content_browser.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +2 lines, -0 lines 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 48 (16 generated)
Elly Fong-Jones
falken, rdsmith: PTAL? sorry for how big this is :(
5 years, 3 months ago (2015-08-27 15:58:20 UTC) #2
falken
Thanks so much for working on this refactor! I'm sorry the current code is pretty ...
5 years, 3 months ago (2015-08-28 05:45:25 UTC) #3
Elly Fong-Jones
falken: PTAL? https://codereview.chromium.org/1315443003/diff/20001/content/browser/service_worker/service_worker_cache_writer.cc File content/browser/service_worker/service_worker_cache_writer.cc (right): https://codereview.chromium.org/1315443003/diff/20001/content/browser/service_worker/service_worker_cache_writer.cc#newcode244 content/browser/service_worker/service_worker_cache_writer.cc:244: int result = state_machine_.Run(net::OK); On 2015/08/28 05:45:24, ...
5 years, 3 months ago (2015-08-31 15:03:46 UTC) #4
Elly Fong-Jones
After discussion on net-dev, I changed the StateMachine pattern back to the more conventional DoLoop ...
5 years, 3 months ago (2015-08-31 17:48:10 UTC) #5
falken
This looks good! some more comments. I assume "TODO: Update_EmptyScript and Update_SameScript fail" has to ...
5 years, 3 months ago (2015-09-01 08:06:38 UTC) #6
Elly Fong-Jones
PTAL? https://codereview.chromium.org/1315443003/diff/60001/content/browser/service_worker/service_worker_cache_writer.cc File content/browser/service_worker/service_worker_cache_writer.cc (right): https://codereview.chromium.org/1315443003/diff/60001/content/browser/service_worker/service_worker_cache_writer.cc#newcode66 content/browser/service_worker/service_worker_cache_writer.cc:66: bool done_; On 2015/09/01 08:06:37, falken wrote: > ...
5 years, 3 months ago (2015-09-01 13:17:48 UTC) #7
falken
Yep this looks good to me, I just have optional nits now. I think some ...
5 years, 3 months ago (2015-09-01 14:43:53 UTC) #8
Randy Smith (Not in Mondays)
First round of comments. I'm focussing on the high level async structure and DoLoop idiomaticity ...
5 years, 3 months ago (2015-09-01 20:35:42 UTC) #9
Elly Fong-Jones
PTAL? https://codereview.chromium.org/1315443003/diff/80001/content/browser/service_worker/service_worker_cache_writer.cc File content/browser/service_worker/service_worker_cache_writer.cc (right): https://codereview.chromium.org/1315443003/diff/80001/content/browser/service_worker/service_worker_cache_writer.cc#newcode6 content/browser/service_worker/service_worker_cache_writer.cc:6: On 2015/09/01 14:43:52, falken wrote: > need <algorithm> ...
5 years, 3 months ago (2015-09-09 13:36:09 UTC) #10
falken
lgtm https://codereview.chromium.org/1315443003/diff/100001/content/browser/service_worker/service_worker_write_to_cache_job.cc File content/browser/service_worker/service_worker_write_to_cache_job.cc (right): https://codereview.chromium.org/1315443003/diff/100001/content/browser/service_worker/service_worker_write_to_cache_job.cc#newcode163 content/browser/service_worker/service_worker_write_to_cache_job.cc:163: I liked the DCHECK_EQ(0, *bytes_read) or the comment ...
5 years, 3 months ago (2015-09-10 07:16:06 UTC) #11
Elly Fong-Jones
https://codereview.chromium.org/1315443003/diff/100001/content/browser/service_worker/service_worker_write_to_cache_job.cc File content/browser/service_worker/service_worker_write_to_cache_job.cc (right): https://codereview.chromium.org/1315443003/diff/100001/content/browser/service_worker/service_worker_write_to_cache_job.cc#newcode163 content/browser/service_worker/service_worker_write_to_cache_job.cc:163: On 2015/09/10 07:16:06, falken wrote: > I liked the ...
5 years, 3 months ago (2015-09-10 12:33:06 UTC) #12
Elly Fong-Jones
michaeln: ptal at appcache_response.h change?
5 years, 3 months ago (2015-09-10 12:33:35 UTC) #14
michaeln
lgtm (w the comments) https://codereview.chromium.org/1315443003/diff/120001/content/browser/appcache/appcache_response.h File content/browser/appcache/appcache_response.h (right): https://codereview.chromium.org/1315443003/diff/120001/content/browser/appcache/appcache_response.h#newcode211 content/browser/appcache/appcache_response.h:211: // Should only be called ...
5 years, 3 months ago (2015-09-10 20:50:27 UTC) #15
Randy Smith (Not in Mondays)
Elly: My apologies for not getting back to you more quickly on this CL; as ...
5 years, 3 months ago (2015-09-13 20:56:36 UTC) #16
Randy Smith (Not in Mondays)
Some comments on ServiceWorkerWriteToCacheJob (not doing that as thoroughly, as I don't consider myself even ...
5 years, 3 months ago (2015-09-13 21:32:08 UTC) #17
Elly Fong-Jones
This now uses the canonical form of the DoLoop pattern. rdsmith: PTAL? https://codereview.chromium.org/1315443003/diff/140001/content/browser/service_worker/service_worker_cache_writer.cc File content/browser/service_worker/service_worker_cache_writer.cc ...
5 years, 3 months ago (2015-09-15 15:08:24 UTC) #18
Randy Smith (Not in Mondays)
Mostly nits; this is fairly close. https://codereview.chromium.org/1315443003/diff/160001/content/browser/service_worker/service_worker_cache_writer.cc File content/browser/service_worker/service_worker_cache_writer.cc (right): https://codereview.chromium.org/1315443003/diff/160001/content/browser/service_worker/service_worker_cache_writer.cc#newcode107 content/browser/service_worker/service_worker_cache_writer.cc:107: default: Under what ...
5 years, 3 months ago (2015-09-16 18:57:28 UTC) #19
Elly Fong-Jones
PTAL? https://codereview.chromium.org/1315443003/diff/160001/content/browser/service_worker/service_worker_cache_writer.cc File content/browser/service_worker/service_worker_cache_writer.cc (right): https://codereview.chromium.org/1315443003/diff/160001/content/browser/service_worker/service_worker_cache_writer.cc#newcode107 content/browser/service_worker/service_worker_cache_writer.cc:107: default: On 2015/09/16 18:57:28, rdsmith wrote: > Under ...
5 years, 3 months ago (2015-09-16 19:25:57 UTC) #20
Randy Smith (Not in Mondays)
LGTM; thanks for putting up with my nits. https://codereview.chromium.org/1315443003/diff/160001/content/browser/service_worker/service_worker_cache_writer.cc File content/browser/service_worker/service_worker_cache_writer.cc (right): https://codereview.chromium.org/1315443003/diff/160001/content/browser/service_worker/service_worker_cache_writer.cc#newcode144 content/browser/service_worker/service_worker_cache_writer.cc:144: if ...
5 years, 3 months ago (2015-09-16 20:00:48 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1315443003/180001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1315443003/180001
5 years, 3 months ago (2015-09-17 13:15:53 UTC) #24
commit-bot: I haz the power
Try jobs failed on following builders: cast_shell_linux on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linux/builds/55816)
5 years, 3 months ago (2015-09-17 13:33:20 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1315443003/200001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1315443003/200001
5 years, 3 months ago (2015-09-17 15:27:35 UTC) #29
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_compile_dbg_ng on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg_ng/builds/99198)
5 years, 3 months ago (2015-09-17 15:46:13 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1315443003/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1315443003/220001
5 years, 3 months ago (2015-09-18 13:04:19 UTC) #34
commit-bot: I haz the power
Try jobs failed on following builders: android_chromium_gn_compile_dbg on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_dbg/builds/117377) cast_shell_android on tryserver.chromium.linux (JOB_FAILED, ...
5 years, 3 months ago (2015-09-18 13:17:35 UTC) #36
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1315443003/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1315443003/240001
5 years, 3 months ago (2015-09-18 13:31:18 UTC) #39
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_gn_chromeos_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_gn_chromeos_rel/builds/83624) linux_chromium_rel_ng on tryserver.chromium.linux (JOB_FAILED, ...
5 years, 3 months ago (2015-09-18 13:37:45 UTC) #41
Elly Fong-Jones
On 2015/09/18 13:37:45, commit-bot: I haz the power wrote: > Try jobs failed on following ...
5 years, 3 months ago (2015-09-18 13:47:51 UTC) #42
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1315443003/260001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1315443003/260001
5 years, 3 months ago (2015-09-18 13:55:33 UTC) #45
commit-bot: I haz the power
Committed patchset #14 (id:260001)
5 years, 3 months ago (2015-09-18 14:57:51 UTC) #46
commit-bot: I haz the power
Patchset 14 (id:??) landed as https://crrev.com/d778a5a82cdccab2b3cbf4940749753c98e59dcc Cr-Commit-Position: refs/heads/master@{#349669}
5 years, 3 months ago (2015-09-18 14:58:25 UTC) #47
Nate Chapin
5 years, 3 months ago (2015-09-18 21:57:51 UTC) #48
Message was sent while issue was closed.
A revert of this CL (patchset #14 id:260001) has been created in
https://codereview.chromium.org/1351423002/ by japhet@chromium.org.

The reason for reverting is: Caused a layout test to timeout on mac/win:
http://test-results.appspot.com/dashboards/flakiness_dashboard.html#showExpec...

Test was added as part of fixing
https://code.google.com/p/chromium/issues/detail?id=419999 and the bugfix looks
to be in highly related code..

Powered by Google App Engine
This is Rietveld 408576698