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

Issue 10074001: Initial implementation of the ByteStream refactor. (Closed)

Created:
8 years, 8 months ago by Randy Smith (Not in Mondays)
Modified:
8 years, 6 months ago
Reviewers:
ahendrickson
CC:
chromium-reviews, cbentzel+watch_chromium.org, jam, joi+watch-content_chromium.org, rginda+watch_chromium.org, darin-cc_chromium.org, rdsmith+dwatch_chromium.org
Visibility:
Public.

Description

Initial implementation of the ByteStream refactor. This puts an abstraction barrier between DownloadResourceHandler and DownloadFile; instead of targeting each other directly, they interact through a ByteStream class that transfers (zero-copy) bytes, potentially between threads. This refactor enables substitution of different download sources and download destinations, and potentially adding in filters between source and destination as well. BUG=123192

Patch Set 1 #

Total comments: 26

Patch Set 2 : Incorporated Andy's comments. #

Patch Set 3 : Checkpoint and merge to LKGR. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1451 lines, -690 lines) Patch
M content/browser/download/base_file.cc View 1 2 1 chunk +0 lines, -7 lines 0 comments Download
A content/browser/download/byte_stream.h View 1 1 chunk +213 lines, -0 lines 0 comments Download
A content/browser/download/byte_stream.cc View 1 2 1 chunk +206 lines, -0 lines 0 comments Download
A content/browser/download/byte_stream_unittest.cc View 1 2 1 chunk +477 lines, -0 lines 0 comments Download
D content/browser/download/download_buffer.h View 1 chunk +0 lines, -71 lines 0 comments Download
D content/browser/download/download_buffer.cc View 1 chunk +0 lines, -71 lines 0 comments Download
D content/browser/download/download_buffer_unittest.cc View 1 chunk +0 lines, -123 lines 0 comments Download
M content/browser/download/download_create_info.h View 2 chunks +7 lines, -0 lines 0 comments Download
M content/browser/download/download_create_info.cc View 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/download/download_file.h View 1 2 2 chunks +0 lines, -8 lines 0 comments Download
M content/browser/download/download_file_impl.h View 1 2 4 chunks +20 lines, -3 lines 0 comments Download
M content/browser/download/download_file_impl.cc View 1 2 4 chunks +121 lines, -6 lines 0 comments Download
M content/browser/download/download_file_manager.h View 1 2 2 chunks +0 lines, -15 lines 0 comments Download
M content/browser/download/download_file_manager.cc View 1 2 3 chunks +0 lines, -103 lines 0 comments Download
M content/browser/download/download_file_manager_unittest.cc View 17 chunks +1 line, -132 lines 0 comments Download
M content/browser/download/download_file_unittest.cc View 1 2 12 chunks +241 lines, -33 lines 0 comments Download
M content/browser/download/download_manager_impl_unittest.cc View 1 2 16 chunks +21 lines, -37 lines 0 comments Download
M content/browser/download/download_net_log_parameters.h View 1 2 1 chunk +14 lines, -0 lines 0 comments Download
M content/browser/download/download_net_log_parameters.cc View 1 2 1 chunk +14 lines, -0 lines 0 comments Download
M content/browser/download/download_resource_handler.h View 7 chunks +12 lines, -9 lines 0 comments Download
M content/browser/download/download_resource_handler.cc View 1 2 7 chunks +58 lines, -59 lines 0 comments Download
M content/browser/download/download_stats.h View 1 2 chunks +4 lines, -0 lines 0 comments Download
M content/browser/download/download_stats.cc View 1 2 chunks +5 lines, -2 lines 0 comments Download
M content/browser/renderer_host/x509_user_cert_resource_handler.h View 3 chunks +6 lines, -2 lines 0 comments Download
M content/browser/renderer_host/x509_user_cert_resource_handler.cc View 1 chunk +20 lines, -3 lines 0 comments Download
M content/content_browser.gypi View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M content/content_tests.gypi View 1 2 1 chunk +1 line, -1 line 0 comments Download
M content/test/net/url_request_slow_download_job.cc View 1 chunk +2 lines, -0 lines 0 comments Download
M net/base/net_log_event_type_list.h View 1 2 1 chunk +5 lines, -3 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Randy Smith (Not in Mondays)
Andy: This is a first pass at the ByteStream refactor. I'm interested in your thoughts ...
8 years, 8 months ago (2012-04-12 18:29:46 UTC) #1
ahendrickson
This basically looks fine to me, with some nits. Per the Chrome style guide: "Omit ...
8 years, 8 months ago (2012-04-16 15:14:26 UTC) #2
Randy Smith (Not in Mondays)
8 years, 8 months ago (2012-04-18 19:10:38 UTC) #3
Wow, this was a much more detailed review than I expected.  Thanks!

I didn't get a lot of comments in the area where I thought you have the most
expertise (which was the movement and transformation of code from
DownloadFileManager to DownloadFile) so I wanted to confirm that you thought
that was ok.  I think I found a bug scanning over it just now (I don't think I'm
finalizing the hash before final shipment, but I want to write a test to confirm
that that's broken and *then* fix it) but I could be wrong, and that's the area
where I think you're mostly likely to find big things.  Does that look ok to
you?

I'd welcome further comments from you if you want, but I'm going to assume you
won't be doing further review.  But if you any thoughts on the above question
(or anything else you'd like to comment on) please let me know.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
File content/browser/download/byte_stream.cc (right):

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.cc:26: if (data_size_ == 0 && byte_count >
0 && sink_task_runner_.get() != NULL)
On 2012/04/16 15:14:27, ahendrickson wrote:
> Nit: Add braces for multi-line 'if' bodies.

Ooops.  But already done in a later PS.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.cc:27: // Nothing actually touches the data
on this object can be
On 2012/04/16 15:14:27, ahendrickson wrote:
> *Nothing that

Done.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.cc:46: if (contents_.empty() &&
sink_task_runner_.get() != NULL)
On 2012/04/16 15:14:27, ahendrickson wrote:
> Nit:  Add braces.

Done.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.cc:79: source_task_runner_.get() != NULL)
On 2012/04/16 15:14:27, ahendrickson wrote:
> Nit:  Add braces.

Done.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.cc:80: // Nothing actually touches the data
on this object can be
On 2012/04/16 15:14:27, ahendrickson wrote:
> *Nothing that

Done.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
File content/browser/download/byte_stream.h (right):

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.h:58: typedef enum { STREAM_EMPTY,
STREAM_NON_EMPTY, STREAM_COMPLETE } StreamState;
On 2012/04/16 15:14:27, ahendrickson wrote:
> STREAM_NON_EMPTY -> STREAM_HAS_DATA ?

Done.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.h:81: // and provide a status.
On 2012/04/16 15:14:27, ahendrickson wrote:
> Indicate what status should be provided in the normal completion case?

Done.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.h:95: void RegisterSourceCallback(
On 2012/04/16 15:14:27, ahendrickson wrote:
> I think this needs a better name.  RegisterSourceCanAddCallback?

I'd prefer not, mostly because there isn't really anything else that the source
can be notified about and it's a longer name.  How strongly do you feel?

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.h:109: // Only valid to call if GetData()
has returned STREAM_COMPLETE.
On 2012/04/16 15:14:27, ahendrickson wrote:
> What will this return if called too early?

Undefined.  I don't want to promise to assert, but assertion is what I generally
think of as happening when you violate an interface contract.  

(I've added a DCHECK in the code.)

http://codereview.chromium.org/10074001/diff/1/content/browser/download/byte_...
content/browser/download/byte_stream.h:119: void
RegisterSinkCallback(scoped_refptr<base::TaskRunner> sink_task_runner,
On 2012/04/16 15:14:27, ahendrickson wrote:
> RegisterDataAvailableCallback?

But this is also called when there's just a result code.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/downl...
File content/browser/download/download_file_impl.h (right):

http://codereview.chromium.org/10074001/diff/1/content/browser/download/downl...
content/browser/download/download_file_impl.h:55: void PipeActive();
On 2012/04/16 15:14:27, ahendrickson wrote:
> I was not clear as to what this function does.  Needs a descriptive comment,
and
> perhaps a better name?

Added comment; let me know if you still think I need to change the name.  It's
not part of the interface, so I'm not too too worried about it :-}.

http://codereview.chromium.org/10074001/diff/1/content/browser/download/downl...
File content/browser/download/download_resource_handler.cc (left):

http://codereview.chromium.org/10074001/diff/1/content/browser/download/downl...
content/browser/download/download_resource_handler.cc:173: // We can't start
saving the data before we create the file on disk and have a
On 2012/04/16 15:14:27, ahendrickson wrote:
> Nice!

:-).

http://codereview.chromium.org/10074001/diff/1/content/test/net/url_request_s...
File content/test/net/url_request_slow_download_job.cc (right):

http://codereview.chromium.org/10074001/diff/1/content/test/net/url_request_s...
content/test/net/url_request_slow_download_job.cc:188: // Release reference
On 2012/04/16 15:14:27, ahendrickson wrote:
> Is this related to this CL?

Sorta-not-really.  It's an already existing problem I found while running tests
for the CL that I fixed in another CL.  So this should disappear in a future
merge.

Powered by Google App Engine
This is Rietveld 408576698