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

Unified Diff: chrome/browser/download/download_manager.cc

Issue 6312027: Add files saved using 'Save page as' to the download history.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 10 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
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/save_package.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager.cc
===================================================================
--- chrome/browser/download/download_manager.cc (revision 76501)
+++ chrome/browser/download/download_manager.cc (working copy)
@@ -854,6 +854,22 @@
return RemoveDownloadsBetween(base::Time(), base::Time());
}
+void DownloadManager::AddDownloadItemToHistory(DownloadItem* item,
+ int64 db_handle) {
+ // It's not immediately obvious, but HistoryBackend::CreateDownload() can
+ // call this function with an invalid |db_handle|. For instance, this can
+ // happen when the history database is offline. We cannot have multiple
+ // DownloadItems with the same invalid db_handle, so we need to assign a
+ // unique |db_handle| here.
+ if (db_handle == DownloadHistory::kUninitializedHandle)
+ db_handle = download_history_->GetNextFakeDbHandle();
+
+ DCHECK(item->db_handle() == DownloadHistory::kUninitializedHandle);
+ item->set_db_handle(db_handle);
+ DCHECK(!ContainsKey(history_downloads_, db_handle));
+ history_downloads_[db_handle] = item;
+}
+
void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download_item) {
#if !defined(NDEBUG)
save_page_as_downloads_.insert(download_item);
@@ -1005,21 +1021,8 @@
<< " download_id = " << info.download_id
<< " download = " << download->DebugString(true);
- // It's not immediately obvious, but HistoryBackend::CreateDownload() can
- // call this function with an invalid |db_handle|. For instance, this can
- // happen when the history database is offline. We cannot have multiple
- // DownloadItems with the same invalid db_handle, so we need to assign a
- // unique |db_handle| here.
- if (db_handle == DownloadHistory::kUninitializedHandle)
- db_handle = download_history_->GetNextFakeDbHandle();
+ AddDownloadItemToHistory(download, db_handle);
- DCHECK(download->db_handle() == DownloadHistory::kUninitializedHandle);
- download->set_db_handle(db_handle);
-
- // Insert into our full map.
- DCHECK(!ContainsKey(history_downloads_, download->db_handle()));
- history_downloads_[download->db_handle()] = download;
-
// Show in the appropriate browser UI.
// This includes buttons to save or cancel, for a dangerous download.
ShowDownloadInBrowser(info, download);
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/save_package.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698