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

Issue 82273002: Fix various issues in RedirectToFileResourceHandler. (Closed)

Created:
7 years, 1 month ago by davidben
Modified:
6 years, 9 months ago
CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, jam
Visibility:
Public.

Description

Fix various issues in RedirectToFileResourceHandler. - Handle errors in creating temporary files. - Cancel on write failure instead of resuming. This used to work, but got lost in some refactoring in r142108. - Fix the OnResponseCompleted resume logic to account for partial writes. - Don't lose write errors which occur after OnResponseCompleted is received. - WeakPtrFactory goes after other members. - OnWillStart was never forwarded to downstream handlers. - Make sure the file is closed before deleting it. Also add a lot of machinery so we can better unit test this stack. BUG=316634, 347663 TEST=ResourceDispatcherHostTest.DownloadToFile ResourceDispatcherHostTest.RegisterDownloadedTempFile ResourceLoaderTest.RedirectToFile* TemporaryFileStreamTest.Basic Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256688

Patch Set 1 #

Patch Set 2 : Check for errors in creating the temporary file. #

Patch Set 3 : Add a RDH-level test. Also fix two more nuisances. #

Total comments: 1

Patch Set 4 : UUUUNIT TESTS #

Total comments: 1

Patch Set 5 : Appease clang #

Patch Set 6 : Further appease clang #

Patch Set 7 : Fix content_browsertests. #

Patch Set 8 : Close the file before deleting it. #

Patch Set 9 : Fix ResourceDispatcherHostTest.DownloadToFile #

Patch Set 10 : Comments #

Total comments: 41

Patch Set 11 : Various #

Total comments: 45

Patch Set 12 : Various comments #

Total comments: 2

Patch Set 13 : Comment #

Total comments: 10

Patch Set 14 : Rebase, move a lot of code around. #

Patch Set 15 : Fix test on Windows. #

Patch Set 16 : Rebase #

Total comments: 17

Patch Set 17 : Rebase, address mmenke comments. #

Total comments: 16

Patch Set 18 : Rebase #

Patch Set 19 : mmenke comments #

Total comments: 45

Patch Set 20 : mmenke comments #

Total comments: 2

Patch Set 21 : Revise comment #

Patch Set 22 : Rebase #

Patch Set 23 : Code duplication from rebase. #

Total comments: 6

Patch Set 24 : Re-use ResourceLoaderTest machinery. #

Total comments: 2

Patch Set 25 : Rename test fixture #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1204 lines, -128 lines) Patch
M content/browser/loader/async_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +9 lines, -0 lines 0 comments Download
M content/browser/loader/redirect_to_file_resource_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 6 chunks +45 lines, -22 lines 0 comments Download
M content/browser/loader/redirect_to_file_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 9 chunks +157 lines, -52 lines 0 comments Download
M content/browser/loader/resource_dispatcher_host_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -1 line 0 comments Download
M content/browser/loader/resource_dispatcher_host_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +14 lines, -8 lines 0 comments Download
M content/browser/loader/resource_dispatcher_host_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 12 chunks +213 lines, -19 lines 0 comments Download
M content/browser/loader/resource_loader_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 10 chunks +346 lines, -9 lines 0 comments Download
M content/browser/loader/sync_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +12 lines, -0 lines 0 comments Download
A content/browser/loader/temporary_file_stream.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +46 lines, -0 lines 0 comments Download
A content/browser/loader/temporary_file_stream.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +61 lines, -0 lines 0 comments Download
A content/browser/loader/temporary_file_stream_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +120 lines, -0 lines 0 comments Download
M content/content_browser.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 15 16 17 18 19 20 21 1 chunk +1 line, -0 lines 0 comments Download
M net/base/mock_file_stream.h View 1 2 3 4 5 6 7 8 9 10 4 chunks +40 lines, -7 lines 0 comments Download
M net/base/mock_file_stream.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +122 lines, -4 lines 0 comments Download
M net/url_request/url_request_test_job.h View 1 2 3 2 chunks +3 lines, -2 lines 0 comments Download
M net/url_request/url_request_test_job.cc View 1 2 3 2 chunks +12 lines, -4 lines 0 comments Download

Messages

Total messages: 51 (0 generated)
davidben
This is to fix some of the local issues in RedirectToFileResourceHandler. The more general cancel/resume ...
7 years, 1 month ago (2013-11-22 00:24:52 UTC) #1
mmenke
On 2013/11/22 00:24:52, David Benjamin wrote: > This is to fix some of the local ...
7 years, 1 month ago (2013-11-22 16:34:47 UTC) #2
davidben
Added another bit of missing error-handling. Yeah, I wouldn't mind some tests here. (And on ...
7 years, 1 month ago (2013-11-22 17:28:37 UTC) #3
mmenke
On 2013/11/22 17:28:37, David Benjamin wrote: > Added another bit of missing error-handling. > > ...
7 years ago (2013-11-25 19:08:51 UTC) #4
davidben
On 2013/11/25 19:08:51, mmenke wrote: > On 2013/11/22 17:28:37, David Benjamin wrote: > > Added ...
7 years ago (2013-11-25 20:23:24 UTC) #5
mmenke
On 2013/11/25 20:23:24, David Benjamin wrote: > On 2013/11/25 19:08:51, mmenke wrote: > > On ...
7 years ago (2013-11-25 20:26:20 UTC) #6
davidben
On 2013/11/25 20:26:20, mmenke wrote: > On 2013/11/25 20:23:24, David Benjamin wrote: > > On ...
7 years ago (2013-11-26 00:13:59 UTC) #7
davidben
Alright, here is a LOT of machinery for unit tests. I split out the RDH ...
7 years ago (2013-11-26 22:59:53 UTC) #8
mmenke
This will take me a while to work through. May not get back to you ...
7 years ago (2013-11-27 15:39:16 UTC) #9
davidben
On 2013/11/27 15:39:16, mmenke wrote: > This will take me a while to work through. ...
7 years ago (2013-11-27 23:15:05 UTC) #10
davidben
Bah, this CL just keeps getting bigger. Hopefully this resolves the close + delete issue ...
7 years ago (2013-12-02 19:39:25 UTC) #11
mmenke
On 2013/12/02 19:39:25, David Benjamin wrote: > Bah, this CL just keeps getting bigger. Hopefully ...
7 years ago (2013-12-03 16:49:04 UTC) #12
mmenke
On 2013/12/03 16:49:04, mmenke wrote: > On 2013/12/02 19:39:25, David Benjamin wrote: > > Bah, ...
7 years ago (2013-12-03 18:45:40 UTC) #13
davidben
Added some block comments at the top of each class. Is this clearer?
7 years ago (2013-12-03 21:44:27 UTC) #14
mmenke
Still reviewing (Yes, I'm slow). https://codereview.chromium.org/82273002/diff/340001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/340001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode56 content/browser/loader/redirect_to_file_resource_handler.cc:56: // |file_stream_->Write()| completes. Could ...
7 years ago (2013-12-04 20:55:48 UTC) #15
davidben
Also got rid of pending_temp_files_ in TemporaryFileManager. Made the interface more explicitly a Delegate that ...
7 years ago (2013-12-04 22:44:03 UTC) #16
mmenke
On 2013/12/04 22:44:03, David Benjamin wrote: > Also got rid of pending_temp_files_ in TemporaryFileManager. Made ...
7 years ago (2013-12-05 17:05:30 UTC) #17
davidben
On 2013/12/05 17:05:30, mmenke wrote: > On 2013/12/04 22:44:03, David Benjamin wrote: > > Also ...
7 years ago (2013-12-05 17:34:31 UTC) #18
mmenke
On 2013/12/05 17:34:31, David Benjamin wrote: > On 2013/12/05 17:05:30, mmenke wrote: > > On ...
7 years ago (2013-12-05 17:38:57 UTC) #19
mmenke
Not quite finished, just want to look through the unit tests. https://codereview.chromium.org/82273002/diff/340001/content/browser/loader/temporary_file_manager.h File content/browser/loader/temporary_file_manager.h (right): ...
7 years ago (2013-12-05 21:34:02 UTC) #20
davidben
https://codereview.chromium.org/82273002/diff/360001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/360001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode56 content/browser/loader/redirect_to_file_resource_handler.cc:56: // |file_stream_->Write()| completes. On 2013/12/05 21:34:03, mmenke wrote: > ...
7 years ago (2013-12-05 22:43:19 UTC) #21
mmenke
https://codereview.chromium.org/82273002/diff/360001/content/browser/loader/resource_loader_unittest.cc File content/browser/loader/resource_loader_unittest.cc (right): https://codereview.chromium.org/82273002/diff/360001/content/browser/loader/resource_loader_unittest.cc#newcode500 content/browser/loader/resource_loader_unittest.cc:500: EXPECT_FALSE(base::PathExists(temp_path)); On 2013/12/05 22:43:20, David Benjamin wrote: > On ...
7 years ago (2013-12-05 23:00:13 UTC) #22
davidben
https://codereview.chromium.org/82273002/diff/360001/content/browser/loader/resource_loader_unittest.cc File content/browser/loader/resource_loader_unittest.cc (right): https://codereview.chromium.org/82273002/diff/360001/content/browser/loader/resource_loader_unittest.cc#newcode500 content/browser/loader/resource_loader_unittest.cc:500: EXPECT_FALSE(base::PathExists(temp_path)); On 2013/12/05 23:00:13, mmenke wrote: > On 2013/12/05 ...
7 years ago (2013-12-05 23:21:00 UTC) #23
mmenke
LGTM, though perhaps I should just another 5 tests, just because this CL hasn't gone ...
7 years ago (2013-12-06 16:15:38 UTC) #24
davidben
+darin for content/ OWNERS and for content/browser/loader code. mmenke's already done the bulk of the ...
7 years ago (2013-12-06 16:57:03 UTC) #25
darin (slow to review)
https://codereview.chromium.org/82273002/diff/400001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/400001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode243 content/browser/loader/redirect_to_file_resource_handler.cc:243: writer_.reset(new Writer(this, file_stream.Pass(), deletable_file)); It makes me a bit ...
7 years ago (2013-12-06 17:56:01 UTC) #26
davidben
Sorry, I sat on this for a bit. Rebased the CL and shuffled some of ...
7 years ago (2013-12-19 22:21:01 UTC) #27
davidben
Friendly ping for revised patchset.
6 years, 11 months ago (2014-01-10 21:31:37 UTC) #28
mmenke
On 2014/01/10 21:31:37, David Benjamin wrote: > Friendly ping for revised patchset. I'll get back ...
6 years, 11 months ago (2014-01-13 15:16:35 UTC) #29
mmenke
Still need to get to the unit tests. https://codereview.chromium.org/82273002/diff/550001/content/browser/loader/async_resource_handler.cc File content/browser/loader/async_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/550001/content/browser/loader/async_resource_handler.cc#newcode206 content/browser/loader/async_resource_handler.cc:206: } ...
6 years, 11 months ago (2014-01-16 16:43:25 UTC) #30
davidben
https://codereview.chromium.org/82273002/diff/550001/content/browser/loader/async_resource_handler.cc File content/browser/loader/async_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/550001/content/browser/loader/async_resource_handler.cc#newcode206 content/browser/loader/async_resource_handler.cc:206: } On 2014/01/16 16:43:26, mmenke wrote: > Sure you ...
6 years, 10 months ago (2014-01-29 21:41:49 UTC) #31
mmenke
Still need to carefully go over the tests. https://codereview.chromium.org/82273002/diff/720001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/720001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode164 content/browser/loader/redirect_to_file_resource_handler.cc:164: DCHECK(!writer_->path().empty()); ...
6 years, 10 months ago (2014-02-14 21:52:49 UTC) #32
davidben
https://codereview.chromium.org/82273002/diff/720001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/720001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode164 content/browser/loader/redirect_to_file_resource_handler.cc:164: DCHECK(!writer_->path().empty()); On 2014/02/14 21:52:49, mmenke wrote: > Random comment: ...
6 years, 10 months ago (2014-02-25 20:03:06 UTC) #33
mmenke
LGTM https://codereview.chromium.org/82273002/diff/1270001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/1270001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode58 content/browser/loader/redirect_to_file_resource_handler.cc:58: // temporary is not deleted before it is ...
6 years, 9 months ago (2014-03-03 21:10:11 UTC) #34
davidben
https://codereview.chromium.org/82273002/diff/1270001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/1270001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode58 content/browser/loader/redirect_to_file_resource_handler.cc:58: // temporary is not deleted before it is closed. ...
6 years, 9 months ago (2014-03-03 23:20:18 UTC) #35
mmenke
Still LGTM. https://codereview.chromium.org/82273002/diff/1270001/content/browser/loader/redirect_to_file_resource_handler.cc File content/browser/loader/redirect_to_file_resource_handler.cc (right): https://codereview.chromium.org/82273002/diff/1270001/content/browser/loader/redirect_to_file_resource_handler.cc#newcode258 content/browser/loader/redirect_to_file_resource_handler.cc:258: controller()->CancelWithError(net::FileErrorToNetError(error_code)); On 2014/03/03 23:20:18, David Benjamin wrote: ...
6 years, 9 months ago (2014-03-04 18:06:51 UTC) #36
mmenke
Any plans on landing this? There's a p-1 bug about one of the issues: https://code.google.com/p/chromium/issues/detail?id=347663 ...
6 years, 9 months ago (2014-03-06 21:01:55 UTC) #37
davidben
Did a not entirely trivial rebase. The ResourceLoaderTest logic now has a little bit of ...
6 years, 9 months ago (2014-03-06 21:52:20 UTC) #38
tyoshino (SeeGerritForStatus)
It seems the other bugs this change fixes may also affect XHR. So, the best ...
6 years, 9 months ago (2014-03-09 03:12:24 UTC) #39
darin (slow to review)
https://codereview.chromium.org/82273002/diff/1330002/content/browser/loader/redirect_to_file_resource_handler.h File content/browser/loader/redirect_to_file_resource_handler.h (right): https://codereview.chromium.org/82273002/diff/1330002/content/browser/loader/redirect_to_file_resource_handler.h#newcode41 content/browser/loader/redirect_to_file_resource_handler.h:41: // The temporary is vended through a delegate interface. ...
6 years, 9 months ago (2014-03-11 05:15:57 UTC) #40
davidben
https://codereview.chromium.org/82273002/diff/1330002/content/browser/loader/redirect_to_file_resource_handler.h File content/browser/loader/redirect_to_file_resource_handler.h (right): https://codereview.chromium.org/82273002/diff/1330002/content/browser/loader/redirect_to_file_resource_handler.h#newcode41 content/browser/loader/redirect_to_file_resource_handler.h:41: // The temporary is vended through a delegate interface. ...
6 years, 9 months ago (2014-03-11 19:50:03 UTC) #41
darin (slow to review)
LGTM https://codereview.chromium.org/82273002/diff/1360001/content/browser/loader/resource_loader_unittest.cc File content/browser/loader/resource_loader_unittest.cc (right): https://codereview.chromium.org/82273002/diff/1360001/content/browser/loader/resource_loader_unittest.cc#newcode407 content/browser/loader/resource_loader_unittest.cc:407: class RedirectToFileTest : public ResourceLoaderTest { OK, nit: ...
6 years, 9 months ago (2014-03-11 20:17:32 UTC) #42
davidben
https://codereview.chromium.org/82273002/diff/1360001/content/browser/loader/resource_loader_unittest.cc File content/browser/loader/resource_loader_unittest.cc (right): https://codereview.chromium.org/82273002/diff/1360001/content/browser/loader/resource_loader_unittest.cc#newcode407 content/browser/loader/resource_loader_unittest.cc:407: class RedirectToFileTest : public ResourceLoaderTest { On 2014/03/11 20:17:33, ...
6 years, 9 months ago (2014-03-11 21:07:04 UTC) #43
davidben
The CQ bit was checked by davidben@chromium.org
6 years, 9 months ago (2014-03-11 21:07:16 UTC) #44
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/davidben@chromium.org/82273002/1380001
6 years, 9 months ago (2014-03-11 22:04:36 UTC) #45
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 9 months ago (2014-03-12 01:48:18 UTC) #46
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_clang_dbg
6 years, 9 months ago (2014-03-12 01:48:19 UTC) #47
davidben
The CQ bit was checked by davidben@chromium.org
6 years, 9 months ago (2014-03-12 17:38:58 UTC) #48
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/davidben@chromium.org/82273002/1380001
6 years, 9 months ago (2014-03-12 17:40:46 UTC) #49
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/davidben@chromium.org/82273002/1380001
6 years, 9 months ago (2014-03-12 19:27:35 UTC) #50
commit-bot: I haz the power
6 years, 9 months ago (2014-03-12 23:05:23 UTC) #51
Message was sent while issue was closed.
Change committed as 256688

Powered by Google App Engine
This is Rietveld 408576698