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

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
Index: chrome/browser/download/download_manager.cc
===================================================================
--- chrome/browser/download/download_manager.cc (revision 73953)
+++ chrome/browser/download/download_manager.cc (working copy)
@@ -829,6 +829,24 @@
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);
+
+ // Insert into our full map.
Paweł Hajdan Jr. 2011/02/11 19:17:49 nit: This comment doesn't add value, could you rem
magnus 2011/02/13 03:32:41 Done.
+ 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);
@@ -987,21 +1005,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.
ShowDownloadInBrowser(info, download);

Powered by Google App Engine
This is Rietveld 408576698