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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/download/download_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 int DownloadManager::RemoveAllDownloads() { 822 int DownloadManager::RemoveAllDownloads() {
823 if (this != profile_->GetOriginalProfile()->GetDownloadManager()) { 823 if (this != profile_->GetOriginalProfile()->GetDownloadManager()) {
824 // This is an incognito downloader. Clear All should clear main download 824 // This is an incognito downloader. Clear All should clear main download
825 // manager as well. 825 // manager as well.
826 profile_->GetOriginalProfile()->GetDownloadManager()->RemoveAllDownloads(); 826 profile_->GetOriginalProfile()->GetDownloadManager()->RemoveAllDownloads();
827 } 827 }
828 // The null times make the date range unbounded. 828 // The null times make the date range unbounded.
829 return RemoveDownloadsBetween(base::Time(), base::Time()); 829 return RemoveDownloadsBetween(base::Time(), base::Time());
830 } 830 }
831 831
832 void DownloadManager::AddDownloadItemToHistory(DownloadItem* item,
833 int64 db_handle) {
834 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
835 // call this function with an invalid |db_handle|. For instance, this can
Randy Smith (Not in Mondays) 2011/02/14 21:42:42 nit: Two spaces after "."
magnus 2011/02/16 04:43:23 Done.
836 // happen when the history database is offline. We cannot have multiple
837 // DownloadItems with the same invalid db_handle, so we need to assign a
838 // unique |db_handle| here.
839 if (db_handle == DownloadHistory::kUninitializedHandle)
840 db_handle = download_history_->GetNextFakeDbHandle();
841
842 DCHECK(item->db_handle() == DownloadHistory::kUninitializedHandle);
843 item->set_db_handle(db_handle);
844 DCHECK(!ContainsKey(history_downloads_, db_handle));
845 history_downloads_[db_handle] = item;
846 }
847
832 void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download_item) { 848 void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download_item) {
833 #if !defined(NDEBUG) 849 #if !defined(NDEBUG)
834 save_page_as_downloads_.insert(download_item); 850 save_page_as_downloads_.insert(download_item);
835 #endif 851 #endif
836 downloads_.insert(download_item); 852 downloads_.insert(download_item);
837 } 853 }
838 854
839 // Initiate a download of a specific URL. We send the request to the 855 // Initiate a download of a specific URL. We send the request to the
840 // ResourceDispatcherHost, and let it send us responses like a regular 856 // ResourceDispatcherHost, and let it send us responses like a regular
841 // download. 857 // download.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 int64 db_handle) { 996 int64 db_handle) {
981 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 997 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
982 DownloadMap::iterator it = in_progress_.find(info.download_id); 998 DownloadMap::iterator it = in_progress_.find(info.download_id);
983 DCHECK(it != in_progress_.end()); 999 DCHECK(it != in_progress_.end());
984 1000
985 DownloadItem* download = it->second; 1001 DownloadItem* download = it->second;
986 VLOG(20) << __FUNCTION__ << "()" << " db_handle = " << db_handle 1002 VLOG(20) << __FUNCTION__ << "()" << " db_handle = " << db_handle
987 << " download_id = " << info.download_id 1003 << " download_id = " << info.download_id
988 << " download = " << download->DebugString(true); 1004 << " download = " << download->DebugString(true);
989 1005
990 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 1006 AddDownloadItemToHistory(download, db_handle);
991 // call this function with an invalid |db_handle|. For instance, this can
992 // happen when the history database is offline. We cannot have multiple
993 // DownloadItems with the same invalid db_handle, so we need to assign a
994 // unique |db_handle| here.
995 if (db_handle == DownloadHistory::kUninitializedHandle)
996 db_handle = download_history_->GetNextFakeDbHandle();
997
998 DCHECK(download->db_handle() == DownloadHistory::kUninitializedHandle);
999 download->set_db_handle(db_handle);
1000
1001 // Insert into our full map.
1002 DCHECK(!ContainsKey(history_downloads_, download->db_handle()));
1003 history_downloads_[download->db_handle()] = download;
1004 1007
1005 // Show in the appropriate browser UI. 1008 // Show in the appropriate browser UI.
1006 ShowDownloadInBrowser(info, download); 1009 ShowDownloadInBrowser(info, download);
1007 1010
1008 // Inform interested objects about the new download. 1011 // Inform interested objects about the new download.
1009 NotifyModelChanged(); 1012 NotifyModelChanged();
1010 1013
1011 // If this download has been cancelled before we've received the DB handle, 1014 // If this download has been cancelled before we've received the DB handle,
1012 // post one final message to the history service so that it can be properly 1015 // post one final message to the history service so that it can be properly
1013 // in sync with the DownloadItem's completion status, and also inform any 1016 // in sync with the DownloadItem's completion status, and also inform any
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 observed_download_manager_->RemoveObserver(this); 1134 observed_download_manager_->RemoveObserver(this);
1132 } 1135 }
1133 1136
1134 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { 1137 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() {
1135 observing_download_manager_->NotifyModelChanged(); 1138 observing_download_manager_->NotifyModelChanged();
1136 } 1139 }
1137 1140
1138 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { 1141 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() {
1139 observed_download_manager_ = NULL; 1142 observed_download_manager_ = NULL;
1140 } 1143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698