| Index: content/browser/download/download_file_impl.cc
|
| diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc
|
| index e4ec806f7718c8b4de357eb9977f329a852834a7..71379a60061209e7c34341f835d7bd3c558864de 100644
|
| --- a/content/browser/download/download_file_impl.cc
|
| +++ b/content/browser/download/download_file_impl.cc
|
| @@ -71,6 +71,9 @@ DownloadFileImpl::DownloadFileImpl(
|
| default_download_directory_(default_download_directory),
|
| is_sparse_file_(is_sparse_file),
|
| bytes_seen_(0),
|
| + num_active_streams_(0),
|
| + bytes_seen_with_parallel_streams_(0),
|
| + bytes_seen_without_parallel_streams_(0),
|
| received_slices_(received_slices),
|
| observer_(observer),
|
| weak_factory_(this) {
|
| @@ -317,8 +320,18 @@ void DownloadFileImpl::StreamActive(SourceStream* source_stream) {
|
| reason = WriteDataToFile(
|
| source_stream->offset() + source_stream->bytes_written(),
|
| incoming_data.get()->data(), incoming_data_size);
|
| - disk_writes_time_ += (base::TimeTicks::Now() - write_start);
|
| + base::TimeDelta write_time = (base::TimeTicks::Now() - write_start);
|
| + disk_writes_time_ += write_time;
|
| bytes_seen_ += incoming_data_size;
|
| + if (is_sparse_file_) {
|
| + if (num_active_streams_ > 1) {
|
| + disk_writes_time_with_parallel_streams_ += write_time;
|
| + bytes_seen_with_parallel_streams_ += incoming_data_size;
|
| + } else {
|
| + disk_writes_time_without_parallel_streams_ += write_time;
|
| + bytes_seen_without_parallel_streams_ += incoming_data_size;
|
| + }
|
| + }
|
| total_incoming_data_size += incoming_data_size;
|
| if (reason == DOWNLOAD_INTERRUPT_REASON_NONE)
|
| source_stream->OnWriteBytesToDisk(incoming_data_size);
|
| @@ -367,10 +380,12 @@ void DownloadFileImpl::StreamActive(SourceStream* source_stream) {
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadDestinationObserver::DestinationError, observer_,
|
| reason, TotalBytesReceived(), base::Passed(&hash_state)));
|
| + num_active_streams_--;
|
| } else if (state == ByteStreamReader::STREAM_COMPLETE || should_terminate) {
|
| // Signal successful completion or termination of the current stream.
|
| source_stream->stream_reader()->RegisterCallback(base::Closure());
|
| source_stream->set_finished(true);
|
| + num_active_streams_--;
|
|
|
| // Inform observers.
|
| SendUpdate();
|
| @@ -389,6 +404,12 @@ void DownloadFileImpl::StreamActive(SourceStream* source_stream) {
|
| if (all_stream_complete) {
|
| RecordFileBandwidth(bytes_seen_, disk_writes_time_,
|
| base::TimeTicks::Now() - download_start_);
|
| + if (is_sparse_file_) {
|
| + RecordParallelDownloadStats(bytes_seen_with_parallel_streams_,
|
| + disk_writes_time_with_parallel_streams_,
|
| + bytes_seen_without_parallel_streams_,
|
| + disk_writes_time_without_parallel_streams_);
|
| + }
|
| weak_factory_.InvalidateWeakPtrs();
|
| std::unique_ptr<crypto::SecureHash> hash_state = file_.Finish();
|
| update_timer_.reset();
|
| @@ -414,6 +435,7 @@ void DownloadFileImpl::RegisterAndActivateStream(SourceStream* source_stream) {
|
| weak_factory_.GetWeakPtr(),
|
| source_stream));
|
| StreamActive(source_stream);
|
| + num_active_streams_++;
|
| }
|
| }
|
|
|
|
|