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

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: Incorporated comments and sync'd to r158560 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 download_manager_->GetDelegate()->ShouldCompleteDownload( 351 download_manager_->GetDelegate()->ShouldCompleteDownload(
351 download_, base::Bind(&SavePackage::Finish, this))) { 352 download_, base::Bind(&SavePackage::Finish, this))) {
352 Finish(); 353 Finish();
353 } 354 }
354 } 355 }
355 356
356 // On POSIX, the length of |pure_file_name| + |file_name_ext| is further 357 // On POSIX, the length of |pure_file_name| + |file_name_ext| is further
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, 747 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap,
747 file_manager_, 748 file_manager_,
748 save_ids)); 749 save_ids));
749 750
750 if (download_) { 751 if (download_) {
751 // Hack to avoid touching download_ after user cancel. 752 // Hack to avoid touching download_ after user cancel.
752 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem 753 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
753 // with SavePackage flow. 754 // with SavePackage flow.
754 if (download_->IsInProgress()) { 755 if (download_->IsInProgress()) {
755 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) { 756 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) {
756 download_->OnAllDataSaved(all_save_items_count_, 757 download_->UpdateProgress(all_save_items_count_, CurrentSpeed(), "");
757 DownloadItem::kEmptyFileHash); 758 download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
758 } 759 }
759 download_->MarkAsComplete(); 760 download_->MarkAsComplete();
760 } 761 }
761 FinalizeDownloadEntry(); 762 FinalizeDownloadEntry();
762 } 763 }
763 } 764 }
764 765
765 // Called for updating end state. 766 // Called for updating end state.
766 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { 767 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) {
767 // Because we might have canceled this saving job before, 768 // Because we might have canceled this saving job before,
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 // central SavePackage related location that observers can 1395 // central SavePackage related location that observers can
1395 // get to if they want to wait for notifications for a 1396 // get to if they want to wait for notifications for a
1396 // particular BrowserContext. Alternatively, we could make 1397 // particular BrowserContext. Alternatively, we could make
1397 // it come from the WebContents, which would be more specific 1398 // it come from the WebContents, which would be more specific
1398 // but less useful to (current) customers. 1399 // but less useful to (current) customers.
1399 content::Source<content::DownloadManager>(download_manager_), 1400 content::Source<content::DownloadManager>(download_manager_),
1400 content::Details<content::DownloadItem>(download_)); 1401 content::Details<content::DownloadItem>(download_));
1401 download_manager_->SavePageDownloadFinished(download_); 1402 download_manager_->SavePageDownloadFinished(download_);
1402 StopObservation(); 1403 StopObservation();
1403 } 1404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698