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

Unified Diff: content/browser/download/save_package.cc

Issue 10872102: Revert 153563 - Remove DownloadFileManager in favor of direct ownership of DownloadFiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/save_package.cc
===================================================================
--- content/browser/download/save_package.cc (revision 153592)
+++ content/browser/download/save_package.cc (working copy)
@@ -18,6 +18,7 @@
#include "base/sys_string_conversions.h"
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
+#include "content/browser/download/download_file_manager.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_manager_impl.h"
#include "content/browser/download/download_stats.h"
@@ -34,8 +35,6 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/download_manager_delegate.h"
#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_types.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
@@ -334,19 +333,12 @@
return;
}
wrote_to_completed_file_ = true;
-
- // Hack to avoid touching download_ after user cancel.
- // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
- // with SavePackage flow.
- if (download_->IsInProgress()) {
- download_->SetTotalBytes(size);
- download_->UpdateProgress(size, size, DownloadItem::kEmptyFileHash);
- // Must call OnAllDataSaved here in order for
- // GDataDownloadObserver::ShouldUpload() to return true.
- // ShouldCompleteDownload() may depend on the gdata uploader to finish.
- download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
- }
-
+ download_->SetTotalBytes(size);
+ download_->UpdateProgress(size, size, DownloadItem::kEmptyFileHash);
+ // Must call OnAllDataSaved here in order for
+ // GDataDownloadObserver::ShouldUpload() to return true.
+ // ShouldCompleteDownload() may depend on the gdata uploader to finish.
+ download_->OnAllDataSaved(size, DownloadItem::kEmptyFileHash);
if (!download_manager_->GetDelegate() ||
download_manager_->GetDelegate()->ShouldCompleteDownload(
download_, base::Bind(&SavePackage::Finish, this))) {
@@ -748,17 +740,13 @@
file_manager_,
save_ids));
- // Hack to avoid touching download_ after user cancel.
- // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
- // with SavePackage flow.
- if (download_ && download_->IsInProgress()) {
- if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) {
- download_->UpdateProgress(all_save_items_count_, CurrentSpeed(), "");
- download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
- }
+ if (download_) {
+ if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML)
+ download_->OnAllDataSaved(all_save_items_count_,
+ DownloadItem::kEmptyFileHash);
download_->MarkAsComplete();
+ FinalizeDownloadEntry();
}
- FinalizeDownloadEntry();
}
// Called for updating end state.
@@ -778,10 +766,7 @@
// Inform the DownloadItem to update UI.
// We use the received bytes as number of saved files.
- // Hack to avoid touching download_ after user cancel.
- // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
- // with SavePackage flow.
- if (download_ && download_->IsInProgress())
+ if (download_)
download_->UpdateProgress(completed_count(), CurrentSpeed(), "");
if (save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM &&
@@ -823,10 +808,7 @@
// Inform the DownloadItem to update UI.
// We use the received bytes as number of saved files.
- // Hack to avoid touching download_ after user cancel.
- // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
- // with SavePackage flow.
- if (download_ && download_->IsInProgress())
+ if (download_)
download_->UpdateProgress(completed_count(), CurrentSpeed(), "");
if ((save_type_ == content::SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
@@ -1114,10 +1096,7 @@
static_cast<int>(frames_list.size());
// We use total bytes as the total number of files we want to save.
- // Hack to avoid touching download_ after user cancel.
- // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
- // with SavePackage flow.
- if (download_ && download_->IsInProgress())
+ if (download_)
download_->SetTotalBytes(all_save_items_count_);
if (all_save_items_count_) {
@@ -1386,16 +1365,6 @@
DCHECK(download_);
DCHECK(download_manager_);
- content::NotificationService::current()->Notify(
- content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
- // We use the DownloadManager as the source as that's a
- // central SavePackage related location that observers can
- // get to if they want to wait for notifications for a
- // particular BrowserContext. Alternatively, we could make
- // it come from the WebContents, which would be more specific
- // but less useful to (current) customers.
- content::Source<content::DownloadManager>(download_manager_),
- content::Details<content::DownloadItem>(download_));
download_manager_->SavePageDownloadFinished(download_);
StopObservation();
}
« 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