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

Side by Side Diff: content/browser/download/save_package.cc

Issue 10912173: Replace the DownloadFileManager with direct ownership of DownloadFileImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR (r162700) Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/save_package.h" 5 #include "content/browser/download/save_package.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 Cancel(false); 333 Cancel(false);
334 return; 334 return;
335 } 335 }
336 wrote_to_completed_file_ = true; 336 wrote_to_completed_file_ = true;
337 337
338 // Hack to avoid touching download_ after user cancel. 338 // Hack to avoid touching download_ after user cancel.
339 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem 339 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
340 // with SavePackage flow. 340 // with SavePackage flow.
341 if (download_->IsInProgress()) { 341 if (download_->IsInProgress()) {
342 download_->SetTotalBytes(size); 342 download_->SetTotalBytes(size);
343 download_->UpdateProgress(size, 0, "");
343 // Must call OnAllDataSaved here in order for 344 // Must call OnAllDataSaved here in order for
344 // GDataDownloadObserver::ShouldUpload() to return true. 345 // GDataDownloadObserver::ShouldUpload() to return true.
345 // ShouldCompleteDownload() may depend on the gdata uploader to finish. 346 // ShouldCompleteDownload() may depend on the gdata uploader to finish.
346 download_->OnAllDataSaved(size, DownloadItem::kEmptyFileHash); 347 download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
347 } 348 }
348 349
349 if (!download_manager_->GetDelegate()) { 350 if (!download_manager_->GetDelegate()) {
350 Finish(); 351 Finish();
351 return; 352 return;
352 } 353 }
353 354
354 if (download_manager_->GetDelegate()->ShouldCompleteDownload( 355 if (download_manager_->GetDelegate()->ShouldCompleteDownload(
355 download_, base::Bind(&SavePackage::Finish, this))) { 356 download_, base::Bind(&SavePackage::Finish, this))) {
356 Finish(); 357 Finish();
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, 751 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap,
751 file_manager_, 752 file_manager_,
752 save_ids)); 753 save_ids));
753 754
754 if (download_) { 755 if (download_) {
755 // Hack to avoid touching download_ after user cancel. 756 // Hack to avoid touching download_ after user cancel.
756 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem 757 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
757 // with SavePackage flow. 758 // with SavePackage flow.
758 if (download_->IsInProgress()) { 759 if (download_->IsInProgress()) {
759 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) { 760 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) {
760 download_->OnAllDataSaved(all_save_items_count_, 761 download_->UpdateProgress(all_save_items_count_, CurrentSpeed(), "");
761 DownloadItem::kEmptyFileHash); 762 download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
762 } 763 }
763 download_->MarkAsComplete(); 764 download_->MarkAsComplete();
764 } 765 }
765 FinalizeDownloadEntry(); 766 FinalizeDownloadEntry();
766 } 767 }
767 } 768 }
768 769
769 // Called for updating end state. 770 // Called for updating end state.
770 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { 771 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) {
771 // Because we might have canceled this saving job before, 772 // Because we might have canceled this saving job before,
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 // central SavePackage related location that observers can 1399 // central SavePackage related location that observers can
1399 // get to if they want to wait for notifications for a 1400 // get to if they want to wait for notifications for a
1400 // particular BrowserContext. Alternatively, we could make 1401 // particular BrowserContext. Alternatively, we could make
1401 // it come from the WebContents, which would be more specific 1402 // it come from the WebContents, which would be more specific
1402 // but less useful to (current) customers. 1403 // but less useful to (current) customers.
1403 content::Source<content::DownloadManager>(download_manager_), 1404 content::Source<content::DownloadManager>(download_manager_),
1404 content::Details<content::DownloadItem>(download_)); 1405 content::Details<content::DownloadItem>(download_));
1405 download_manager_->SavePageDownloadFinished(download_); 1406 download_manager_->SavePageDownloadFinished(download_);
1406 StopObservation(); 1407 StopObservation();
1407 } 1408 }
OLDNEW
« no previous file with comments | « content/browser/download/mock_download_file.cc ('k') | content/browser/renderer_host/resource_dispatcher_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698