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

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

Issue 7277073: Support for adding save page download items into downloads history. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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_item.cc ('k') | chrome/browser/download/download_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager.h
===================================================================
--- chrome/browser/download/download_manager.h (revision 94744)
+++ chrome/browser/download/download_manager.h (working copy)
@@ -91,24 +91,22 @@
virtual ~Observer() {}
};
+ typedef std::vector<DownloadItem*> DownloadVector;
+
// Return all temporary downloads that reside in the specified directory.
- void GetTemporaryDownloads(const FilePath& dir_path,
- std::vector<DownloadItem*>* result);
+ void GetTemporaryDownloads(const FilePath& dir_path, DownloadVector* result);
// Return all non-temporary downloads in the specified directory that are
// are in progress or have completed.
- void GetAllDownloads(const FilePath& dir_path,
- std::vector<DownloadItem*>* result);
+ void GetAllDownloads(const FilePath& dir_path, DownloadVector* result);
// Return all non-temporary downloads in the specified directory that are
// in-progress (including dangerous downloads waiting for user confirmation).
- void GetCurrentDownloads(const FilePath& dir_path,
- std::vector<DownloadItem*>* result);
+ void GetCurrentDownloads(const FilePath& dir_path, DownloadVector* result);
// Returns all non-temporary downloads matching |query|. Empty query matches
// everything.
- void SearchDownloads(const string16& query,
- std::vector<DownloadItem*>* result);
+ void SearchDownloads(const string16& query, DownloadVector* result);
// Returns true if initialized properly.
bool Init(Profile* profile);
@@ -162,10 +160,6 @@
// history and remove the download from |active_downloads_|.
void DownloadCompleted(int32 download_id);
- // Called when a Save Page As download is started. Transfers ownership
- // of |download_item| to the DownloadManager.
- void SavePageAsDownloadStarted(DownloadItem* download_item);
-
// Download the object at the URL. Used in cases such as "Save Link As..."
void DownloadUrl(const GURL& url,
const GURL& referrer,
@@ -261,10 +255,27 @@
// been removed from the active map, or was retrieved from the history DB.
DownloadItem* GetDownloadItem(int id);
+ // Called when Save Page download starts. Transfers ownership of |download|
+ // to the DownloadManager.
+ void SavePageDownloadStarted(DownloadItem* download);
+
+ // Callback when Save Page As entry is commited to the history system.
+ void OnSavePageDownloadEntryAdded(int32 download_id, int64 db_handle);
+
+ // Called when Save Page download is done.
+ void SavePageDownloadFinished(DownloadItem* download);
+
+ // Id for next Save Page.
+ int32 GetNextSavePageId();
+
private:
+ typedef std::set<DownloadItem*> DownloadSet;
+ typedef base::hash_map<int64, DownloadItem*> DownloadMap;
+
// For testing.
friend class DownloadManagerTest;
friend class MockDownloadManager;
+ friend class SavePageBrowserTest;
// This class is used to let an incognito DownloadManager observe changes to
// a normal DownloadManager, to propagate ModelChanged() calls from the parent
@@ -293,6 +304,8 @@
virtual ~DownloadManager();
+ DownloadHistory* download_history() { return download_history_.get(); }
Paweł Hajdan Jr. 2011/08/01 18:22:59 nit: Why private? If it's needed just go ahead and
achuithb 2011/08/01 21:19:54 I had it as public but Randy preferred to have thi
achuithb 2011/08/02 19:00:41 I forgot Randy is on vacation. I'm going to make t
Randy Smith (Not in Mondays) 2011/08/03 16:03:09 My memory is that it was only needed by tests. I
Paweł Hajdan Jr. 2011/08/03 19:07:46 I think it's better to use #ifdef UNIT_TEST then r
achuithb 2011/08/03 19:52:43 Pawel: It's not a unit test. Is UNIT_TEST also app
Paweł Hajdan Jr. 2011/08/03 20:49:40 If it isn't it's a bug.
achuithb 2011/08/03 21:05:28 Done.
+
// Called on the FILE thread to check the existence of a downloaded file.
void CheckForFileRemovalOnFileThread(int64 db_handle, const FilePath& path);
@@ -348,6 +361,9 @@
// Add a DownloadItem to history_downloads_.
void AddDownloadItemToHistory(DownloadItem* item, int64 db_handle);
+ // Remove from internal maps.
+ int RemoveDownloadItems(const DownloadVector& pending_deletes);
+
// |downloads_| is the owning set for all downloads known to the
// DownloadManager. This includes downloads started by the user in
// this session, downloads initialized from the history system, and
@@ -384,16 +400,12 @@
// Downloads from past sessions read from a persisted state from the
// history system are placed directly into |history_downloads_| since
// they have valid handles in the history system.
- typedef std::set<DownloadItem*> DownloadSet;
- typedef base::hash_map<int64, DownloadItem*> DownloadMap;
DownloadSet downloads_;
DownloadMap history_downloads_;
DownloadMap in_progress_;
DownloadMap active_downloads_;
-#if !defined(NDEBUG)
- DownloadSet save_page_as_downloads_;
-#endif
+ DownloadMap save_page_downloads_;
// True if the download manager has been initialized and requires a shutdown.
bool shutdown_needed_;
@@ -418,6 +430,9 @@
// user wants us to prompt for a save location for each download.
FilePath last_download_path_;
+ // Save Page Ids.
Paweł Hajdan Jr. 2011/08/01 18:22:59 nit: Hey, please actually see my earlier comment a
achuithb 2011/08/01 21:19:54 Sorry, I changed the comments of the public GetNex
+ int32 next_save_page_id_;
+
scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_;
DISALLOW_COPY_AND_ASSIGN(DownloadManager);
« no previous file with comments | « chrome/browser/download/download_item.cc ('k') | chrome/browser/download/download_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698