| 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 edd7fed5274826d8088224a73e41b7068631ca1b..3c31c8bd4f4b4e9a619b67b6d7f889aef4f07664 100644
|
| --- a/content/browser/download/download_file_impl.cc
|
| +++ b/content/browser/download/download_file_impl.cc
|
| @@ -18,6 +18,7 @@
|
| #include "content/browser/download/download_stats.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/download_destination_observer.h"
|
| +#include "content/public/browser/download_interrupt_reasons.h"
|
| #include "content/public/browser/power_save_blocker.h"
|
| #include "net/base/io_buffer.h"
|
|
|
| @@ -34,7 +35,7 @@ DownloadFileImpl::DownloadFileImpl(
|
| const GURL& url,
|
| const GURL& referrer_url,
|
| bool calculate_hash,
|
| - scoped_ptr<ByteStreamReader> stream,
|
| + scoped_ptr<ByteStreamReader<DownloadInterruptReason> > stream,
|
| const net::BoundNetLog& bound_net_log,
|
| scoped_ptr<PowerSaveBlocker> power_save_blocker,
|
| base::WeakPtr<DownloadDestinationObserver> observer)
|
| @@ -207,7 +208,8 @@ void DownloadFileImpl::StreamActive() {
|
| size_t incoming_data_size = 0;
|
| size_t total_incoming_data_size = 0;
|
| size_t num_buffers = 0;
|
| - ByteStreamReader::StreamState state(ByteStreamReader::STREAM_EMPTY);
|
| + ByteStreamReader<DownloadInterruptReason>::StreamState state(
|
| + ByteStreamReader<DownloadInterruptReason>::STREAM_EMPTY);
|
| DownloadInterruptReason reason = DOWNLOAD_INTERRUPT_REASON_NONE;
|
| base::TimeDelta delta(
|
| base::TimeDelta::FromMilliseconds(kMaxTimeBlockingFileThreadMs));
|
| @@ -217,9 +219,9 @@ void DownloadFileImpl::StreamActive() {
|
| state = stream_reader_->Read(&incoming_data, &incoming_data_size);
|
|
|
| switch (state) {
|
| - case ByteStreamReader::STREAM_EMPTY:
|
| + case ByteStreamReader<DownloadInterruptReason>::STREAM_EMPTY:
|
| break;
|
| - case ByteStreamReader::STREAM_HAS_DATA:
|
| + case ByteStreamReader<DownloadInterruptReason>::STREAM_HAS_DATA:
|
| {
|
| ++num_buffers;
|
| base::TimeTicks write_start(base::TimeTicks::Now());
|
| @@ -230,9 +232,10 @@ void DownloadFileImpl::StreamActive() {
|
| total_incoming_data_size += incoming_data_size;
|
| }
|
| break;
|
| - case ByteStreamReader::STREAM_COMPLETE:
|
| + case ByteStreamReader<DownloadInterruptReason>::STREAM_COMPLETE:
|
| {
|
| - reason = stream_reader_->GetStatus();
|
| + reason = static_cast<DownloadInterruptReason>(
|
| + stream_reader_->GetStatus());
|
| SendUpdate();
|
| base::TimeTicks close_start(base::TimeTicks::Now());
|
| file_.Finish();
|
| @@ -248,12 +251,13 @@ void DownloadFileImpl::StreamActive() {
|
| break;
|
| }
|
| now = base::TimeTicks::Now();
|
| - } while (state == ByteStreamReader::STREAM_HAS_DATA &&
|
| + } while (state ==
|
| + ByteStreamReader<DownloadInterruptReason>::STREAM_HAS_DATA &&
|
| reason == DOWNLOAD_INTERRUPT_REASON_NONE &&
|
| now - start <= delta);
|
|
|
| // If we're stopping to yield the thread, post a task so we come back.
|
| - if (state == ByteStreamReader::STREAM_HAS_DATA &&
|
| + if (state == ByteStreamReader<DownloadInterruptReason>::STREAM_HAS_DATA &&
|
| now - start > delta) {
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| @@ -278,7 +282,8 @@ void DownloadFileImpl::StreamActive() {
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadDestinationObserver::DestinationError,
|
| observer_, reason));
|
| - } else if (state == ByteStreamReader::STREAM_COMPLETE) {
|
| + } else if (state ==
|
| + ByteStreamReader<DownloadInterruptReason>::STREAM_COMPLETE) {
|
| // Signal successful completion and shut down processing.
|
| stream_reader_->RegisterCallback(base::Closure());
|
| weak_factory_.InvalidateWeakPtrs();
|
|
|