diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 20:59:51 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 20:59:51 +0000 |
commit | 08ef5bcfb8c4acb8a2f16b13b4b013203b210fae (patch) | |
tree | 4c73ae632af16896aa2b89bd13cc9f1402a16c61 | |
parent | fad00de4a264f6b695b4127bbe20be4eb24e5754 (diff) | |
download | chromium_src-08ef5bcfb8c4acb8a2f16b13b4b013203b210fae.zip chromium_src-08ef5bcfb8c4acb8a2f16b13b4b013203b210fae.tar.gz chromium_src-08ef5bcfb8c4acb8a2f16b13b4b013203b210fae.tar.bz2 |
Revert 121031 - Eliminate DownloadProgressUpdated.
content::DownloadManagerDelegate::DownloadProgressUpdated was called out of sync with the content::DownloadItem::Observer calls. Eliminate it, as the notification that it provides is anti-useful.
BUG=112841
TEST=as in bug
Review URL: https://chromiumcodereview.appspot.com/9363001
TBR=avi@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9361046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121041 0039d316-1c4b-4281-b951-d872f2087c98
7 files changed, 30 insertions, 18 deletions
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 433800a..04746e5 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -296,6 +296,19 @@ void ChromeDownloadManagerDelegate::ChooseSavePath( download_prefs_.get(), callback); } +void ChromeDownloadManagerDelegate::DownloadProgressUpdated() { + if (!g_browser_process->download_status_updater()) + return; + + float progress = 0; + int download_count = 0; + bool progress_known = + g_browser_process->download_status_updater()->GetProgress( + &progress, &download_count); + download_util::UpdateAppIconDownloadProgress( + download_count, progress_known, progress); +} + #if defined(ENABLE_SAFE_BROWSING) DownloadProtectionService* ChromeDownloadManagerDelegate::GetDownloadProtectionService() { diff --git a/chrome/browser/download/chrome_download_manager_delegate.h b/chrome/browser/download/chrome_download_manager_delegate.h index 7346c73..6d7c6ea 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.h +++ b/chrome/browser/download/chrome_download_manager_delegate.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -86,6 +86,7 @@ class ChromeDownloadManagerDelegate const FilePath::StringType& default_extension, bool can_save_as_complete, content::SaveFilePathPickedCallback callback) OVERRIDE; + virtual void DownloadProgressUpdated() OVERRIDE; DownloadPrefs* download_prefs() { return download_prefs_.get(); } DownloadHistory* download_history() { return download_history_.get(); } diff --git a/chrome/browser/download/download_status_updater.cc b/chrome/browser/download/download_status_updater.cc index 2bbb045..d06df41 100644 --- a/chrome/browser/download/download_status_updater.cc +++ b/chrome/browser/download/download_status_updater.cc @@ -8,7 +8,6 @@ #include "base/logging.h" #include "base/stl_util.h" -#include "chrome/browser/download/download_util.h" DownloadStatusUpdater::DownloadStatusUpdater() { } @@ -59,8 +58,6 @@ void DownloadStatusUpdater::ModelChanged(content::DownloadManager* manager) { it != downloads.end(); ++it) { UpdateItem(*it); } - - UpdateAppIconDownloadProgress(); } void DownloadStatusUpdater::ManagerGoingDown( @@ -80,21 +77,11 @@ void DownloadStatusUpdater::SelectFileDialogDisplayed( void DownloadStatusUpdater::OnDownloadUpdated( content::DownloadItem* download) { UpdateItem(download); - UpdateAppIconDownloadProgress(); } void DownloadStatusUpdater::OnDownloadOpened(content::DownloadItem* download) { } -void DownloadStatusUpdater::UpdateAppIconDownloadProgress() { - float progress = 0; - int download_count = 0; - bool progress_known = GetProgress(&progress, &download_count); - download_util::UpdateAppIconDownloadProgress(download_count, - progress_known, - progress); -} - // React to a transition that a download associated with one of our // download managers has made. Our goal is to have only IN_PROGRESS // items on our set list, as they're the only ones that have relevance diff --git a/chrome/browser/download/download_status_updater.h b/chrome/browser/download/download_status_updater.h index 8fa892ba..d220163 100644 --- a/chrome/browser/download/download_status_updater.h +++ b/chrome/browser/download/download_status_updater.h @@ -43,9 +43,6 @@ class DownloadStatusUpdater virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; private: - // Update the app icon. - void UpdateAppIconDownloadProgress(); - // Update the internal state tracking an item. void UpdateItem(content::DownloadItem* download); diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index 7049785..617494f 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -450,6 +450,7 @@ void DownloadManagerImpl::ContinueDownloadWithPath( << " download = " << download->DebugString(true); in_progress_[download_id] = download; + UpdateDownloadProgress(); // Reflect entry into in_progress_. // Rename to intermediate name. FilePath download_path; @@ -496,6 +497,7 @@ void DownloadManagerImpl::UpdateDownload(int32 download_id, DownloadItem* download = it->second; if (download->IsInProgress()) { download->UpdateProgress(bytes_so_far, bytes_per_sec, hash_state); + UpdateDownloadProgress(); // Reflect size updates. delegate_->UpdateItemInPersistentStore(download); } } @@ -609,6 +611,7 @@ void DownloadManagerImpl::MaybeCompleteDownload(DownloadItem* download) { // Remove the id from in_progress in_progress_.erase(download->GetId()); + UpdateDownloadProgress(); // Reflect removal from in_progress_. delegate_->UpdateItemInPersistentStore(download); @@ -725,6 +728,7 @@ void DownloadManagerImpl::RemoveFromActiveList(DownloadItem* download) { if (download->GetDbHandle() != DownloadItem::kUninitializedHandle) { in_progress_.erase(download->GetId()); active_downloads_.erase(download->GetId()); + UpdateDownloadProgress(); // Reflect removal from in_progress_. delegate_->UpdateItemInPersistentStore(download); } } @@ -742,6 +746,10 @@ void DownloadManagerImpl::SetDownloadManagerDelegate( delegate_ = delegate; } +void DownloadManagerImpl::UpdateDownloadProgress() { + delegate_->DownloadProgressUpdated(); +} + int DownloadManagerImpl::RemoveDownloadItems( const DownloadVector& pending_deletes) { if (pending_deletes.empty()) diff --git a/content/browser/download/download_manager_impl.h b/content/browser/download/download_manager_impl.h index 7eeb06f..ce28cc8 100644 --- a/content/browser/download/download_manager_impl.h +++ b/content/browser/download/download_manager_impl.h @@ -158,6 +158,9 @@ class CONTENT_EXPORT DownloadManagerImpl // Does nothing if the download is not in the history DB. void RemoveFromActiveList(content::DownloadItem* download); + // Updates the delegate about the overall download progress. + void UpdateDownloadProgress(); + // Inform observers that the model has changed. void NotifyModelChanged(); diff --git a/content/public/browser/download_manager_delegate.h b/content/public/browser/download_manager_delegate.h index 92b969a..bf02083a 100644 --- a/content/public/browser/download_manager_delegate.h +++ b/content/public/browser/download_manager_delegate.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -115,6 +115,9 @@ class CONTENT_EXPORT DownloadManagerDelegate { const FilePath::StringType& default_extension, bool can_save_as_complete, SaveFilePathPickedCallback callback) {} + + // Informs the delegate that the progress of downloads has changed. + virtual void DownloadProgressUpdated() {} }; } // namespace content |