diff options
author | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-22 19:22:41 +0000 |
---|---|---|
committer | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-22 19:22:41 +0000 |
commit | 443853c674eeabd922bfcda2caf0411f47c9a93c (patch) | |
tree | 425513cd9998b67aa183aa6f7c9a700761de533f /chrome | |
parent | b6dbdce9b4c536b4d0208ab2a0bf39bd219824bf (diff) | |
download | chromium_src-443853c674eeabd922bfcda2caf0411f47c9a93c.zip chromium_src-443853c674eeabd922bfcda2caf0411f47c9a93c.tar.gz chromium_src-443853c674eeabd922bfcda2caf0411f47c9a93c.tar.bz2 |
In order to resume a download some more information needs to be gathered.
This CL adds member data to classes to support this. It is the first of several CLs to implement download resumption.
In addition hash information is propagated from DownloadFile to DownloadItem, because a new DownloadFile will be created when the download is resumed. It will also need to be persisted in order to resume across chrome runs.
The plan is that data will be collected in DownloadResourceHandler::OnResponseStarted() and passed down to DownloadItem.
On resume, it will pass the information from the resuming DownloadItem to ResourceDispatcherHost::BeginDownload(), which will set any required headers.
BUG= 7648
TEST=None
Review URL: http://codereview.chromium.org/8404049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/download/download_item_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/download/download_manager_unittest.cc | 45 |
2 files changed, 30 insertions, 19 deletions
diff --git a/chrome/browser/download/download_item_unittest.cc b/chrome/browser/download/download_item_unittest.cc index c4d7a31..bb8ee214 100644 --- a/chrome/browser/download/download_item_unittest.cc +++ b/chrome/browser/download/download_item_unittest.cc @@ -159,7 +159,7 @@ TEST_F(DownloadItemTest, NotificationAfterUpdate) { DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); MockObserver observer(item); - item->UpdateProgress(kDownloadChunkSize, kDownloadSpeed); + item->UpdateProgress(kDownloadChunkSize, kDownloadSpeed, ""); ASSERT_TRUE(observer.CheckUpdated()); EXPECT_EQ(kDownloadSpeed, item->CurrentSpeed()); } @@ -202,7 +202,7 @@ TEST_F(DownloadItemTest, NotificationAfterInterrupted) { DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); MockObserver observer(item); - item->Interrupted(kDownloadChunkSize, DOWNLOAD_INTERRUPT_REASON_NONE); + item->Interrupted(kDownloadChunkSize, "", DOWNLOAD_INTERRUPT_REASON_NONE); ASSERT_TRUE(observer.CheckUpdated()); } diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc index ca98843..965924f 100644 --- a/chrome/browser/download/download_manager_unittest.cc +++ b/chrome/browser/download/download_manager_unittest.cc @@ -70,13 +70,15 @@ class MockDownloadFileFactory virtual DownloadFile* CreateFile(DownloadCreateInfo* info, const DownloadRequestHandle& request_handle, - DownloadManager* download_manager) OVERRIDE; + DownloadManager* download_manager, + bool calculate_hash) OVERRIDE; }; DownloadFile* MockDownloadFileFactory::CreateFile( DownloadCreateInfo* info, const DownloadRequestHandle& request_handle, - DownloadManager* download_manager) { + DownloadManager* download_manager, + bool calculate_hash) { NOTREACHED(); return NULL; } @@ -221,8 +223,10 @@ class DownloadManagerTest : public testing::Test { } void OnDownloadInterrupted(int32 download_id, int64 size, + const std::string& hash_state, InterruptReason reason) { - download_manager_->OnDownloadInterrupted(download_id, size, reason); + download_manager_->OnDownloadInterrupted(download_id, size, + hash_state, reason); } // Get the download item with ID |id|. @@ -261,11 +265,13 @@ const size_t DownloadManagerTest::kTestDataLen = // A DownloadFile that we can inject errors into. class DownloadFileWithErrors : public DownloadFileImpl { public: - DownloadFileWithErrors(DownloadCreateInfo* info, DownloadManager* manager); + DownloadFileWithErrors(DownloadCreateInfo* info, + DownloadManager* manager, + bool calculate_hash); virtual ~DownloadFileWithErrors() {} // BaseFile delegated functions. - virtual net::Error Initialize(bool calculate_hash); + virtual net::Error Initialize(); virtual net::Error AppendDataToFile(const char* data, size_t data_len); virtual net::Error Rename(const FilePath& full_path); @@ -288,13 +294,17 @@ class DownloadFileWithErrors : public DownloadFileImpl { }; DownloadFileWithErrors::DownloadFileWithErrors(DownloadCreateInfo* info, - DownloadManager* manager) - : DownloadFileImpl(info, new DownloadRequestHandle(), manager), + DownloadManager* manager, + bool calculate_hash) + : DownloadFileImpl(info, + new DownloadRequestHandle(), + manager, + calculate_hash), forced_error_(net::OK) { } -net::Error DownloadFileWithErrors::Initialize(bool calculate_hash) { - return ReturnError(DownloadFileImpl::Initialize(calculate_hash)); +net::Error DownloadFileWithErrors::Initialize() { + return ReturnError(DownloadFileImpl::Initialize()); } net::Error DownloadFileWithErrors::AppendDataToFile(const char* data, @@ -482,9 +492,9 @@ TEST_F(DownloadManagerTest, MAYBE_StartDownload) { DownloadFile* download_file( new DownloadFileImpl(info.get(), new DownloadRequestHandle(), - download_manager_)); + download_manager_, false)); AddDownloadToFileManager(info->download_id.local(), download_file); - download_file->Initialize(false); + download_file->Initialize(); download_manager_->StartDownload(info->download_id.local()); message_loop_.RunAllPending(); @@ -920,7 +930,7 @@ TEST_F(DownloadManagerTest, DownloadInterruptTest) { EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); int64 error_size = 3; - OnDownloadInterrupted(0, error_size, + OnDownloadInterrupted(0, error_size, "", DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED); message_loop_.RunAllPending(); @@ -986,7 +996,8 @@ TEST_F(DownloadManagerTest, DownloadFileErrorTest) { // Create a download file that we can insert errors into. DownloadFileWithErrors* download_file(new DownloadFileWithErrors( - info.get(), download_manager_)); + info.get(), download_manager_, false)); + download_file->Initialize(); AddDownloadToFileManager(local_id, download_file); // |download_file| is owned by DownloadFileManager. @@ -1160,10 +1171,10 @@ TEST_F(DownloadManagerTest, MAYBE_DownloadOverwriteTest) { // properly. DownloadFile* download_file( new DownloadFileImpl(info.get(), new DownloadRequestHandle(), - download_manager_)); + download_manager_, false)); download_file->Rename(cr_path); // This creates the .crdownload version of the file. - download_file->Initialize(false); + download_file->Initialize(); // |download_file| is owned by DownloadFileManager. AddDownloadToFileManager(info->download_id.local(), download_file); @@ -1237,10 +1248,10 @@ TEST_F(DownloadManagerTest, MAYBE_DownloadRemoveTest) { // properly. DownloadFile* download_file( new DownloadFileImpl(info.get(), new DownloadRequestHandle(), - download_manager_)); + download_manager_, false)); download_file->Rename(cr_path); // This creates the .crdownload version of the file. - download_file->Initialize(false); + download_file->Initialize(); // |download_file| is owned by DownloadFileManager. AddDownloadToFileManager(info->download_id.local(), download_file); |