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

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

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merged db_handle, id; onCreated, onErased 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
diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h
index 828c83c3bdda7d7f630618b3143257e02834de4e..aa8719692cfced55c99269da8821a3957435ae42 100644
--- a/chrome/browser/download/download_manager.h
+++ b/chrome/browser/download/download_manager.h
@@ -53,12 +53,17 @@ class DownloadHistory;
class DownloadPrefs;
class DownloadStatusUpdater;
class GURL;
+class ListValue;
class Profile;
class ResourceDispatcherHost;
class TabContents;
struct DownloadCreateInfo;
struct DownloadHistoryInfo;
struct DownloadSaveInfo;
+namespace download_util {
+// Try to avoid including download_query.h because it defines some macros.
+class DownloadQuery;
+} // namespace download_util
// Browser's download manager: manages all downloads and destination view.
class DownloadManager
@@ -67,6 +72,8 @@ class DownloadManager
public DownloadStatusUpdaterDelegate,
public SelectFileDialog::Listener {
public:
+ typedef std::vector<DownloadItem*> ItemVector;
+
explicit DownloadManager(DownloadStatusUpdater* status_updater);
// Shutdown the download manager. Must be called before destruction.
@@ -95,22 +102,28 @@ class DownloadManager
// Return all temporary downloads that reside in the specified directory.
void GetTemporaryDownloads(const FilePath& dir_path,
- std::vector<DownloadItem*>* result);
+ ItemVector* 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);
+ ItemVector* 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);
+ ItemVector* result);
+
+ bool Search(const download_util::DownloadQuery& query,
+ ItemVector* results = NULL,
+ bool merge_parent_manager = true,
+ std::string* error_msg = NULL,
+ ListValue* json_results = NULL) const;
// Returns all non-temporary downloads matching |query|. Empty query matches
// everything.
void SearchDownloads(const string16& query,
- std::vector<DownloadItem*>* result);
+ ItemVector* result);
// Returns true if initialized properly.
bool Init(Profile* profile);
@@ -125,7 +138,7 @@ class DownloadManager
// Called from a view when a user clicks a UI button or link.
void DownloadCancelled(int32 download_id);
- void RemoveDownload(int64 download_handle);
+ void RemoveDownload(int64 id);
// Determine if the download is ready for completion, i.e. has had
// all data saved, and completed the filename determination and
@@ -192,14 +205,14 @@ class DownloadManager
// Methods called on completion of a query sent to the history system.
void OnQueryDownloadEntriesComplete(
std::vector<DownloadHistoryInfo>* entries);
- void OnCreateDownloadEntryComplete(int32 download_id, int64 db_handle);
+ void OnCreateDownloadEntryComplete(int32 download_id);
// Display a new download in the appropriate browser UI.
void ShowDownloadInBrowser(DownloadItem* download);
// The number of in progress (including paused) downloads.
int in_progress_count() const {
- return static_cast<int>(in_progress_.size());
+ return GetInProgressDownloadCount();
}
Profile* profile() { return profile_; }
@@ -217,7 +230,7 @@ class DownloadManager
// Overridden from DownloadStatusUpdaterDelegate:
virtual bool IsDownloadProgressKnown();
- virtual int64 GetInProgressDownloadCount();
+ virtual int64 GetInProgressDownloadCount() const;
virtual int64 GetReceivedDownloadBytes();
virtual int64 GetTotalDownloadBytes();
@@ -298,13 +311,16 @@ class DownloadManager
virtual ~DownloadManager();
+ void MergeItems(bool merge_parent_manager,
+ ItemVector* items) const;
+
// Called on the FILE thread to check the existence of a downloaded file.
- void CheckForFileRemovalOnFileThread(int64 db_handle, const FilePath& path);
+ void CheckForFileRemovalOnFileThread(int64 id, const FilePath& path);
// Called on the UI thread if the FILE thread detects the removal of
// the downloaded file. The UI thread updates the state of the file
// and then notifies this update to the file's observer.
- void OnFileRemovalDetected(int64 db_handle);
+ void OnFileRemovalDetected(int64 id);
// Called on the download thread to check whether the suggested file path
// exists. We don't check if the file exists on the UI thread to avoid UI
@@ -351,55 +367,18 @@ class DownloadManager
void AssertContainersConsistent() const;
// Add a DownloadItem to history_downloads_.
- void AddDownloadItemToHistory(DownloadItem* item, int64 db_handle);
-
- // |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
- // "save page as" downloads. All other DownloadItem containers in
- // the DownloadManager are maps; they do not own the DownloadItems.
- // Note that this is the only place (with any functional implications;
- // see save_page_as_downloads_ below) that "save page as" downloads are
- // kept, as the DownloadManager's only job is to hold onto those
- // until destruction.
- //
- // |history_downloads_| is map of all downloads in this profile. The key
- // is the handle returned by the history system, which is unique
- // across sessions.
- //
- // |active_downloads_| is a map of all downloads that are currently being
- // processed. The key is the ID assigned by the ResourceDispatcherHost,
- // which is unique for the current session.
- //
- // |in_progress_| is a map of all downloads that are in progress and that have
- // not yet received a valid history handle. The key is the ID assigned by the
- // ResourceDispatcherHost, which is unique for the current session.
- //
- // |save_page_as_downloads_| (if defined) is a collection of all the
- // downloads the "save page as" system has given to us to hold onto
- // until we are destroyed. It is only used for debugging.
- //
- // When a download is created through a user action, the corresponding
- // DownloadItem* is placed in |active_downloads_| and remains there until the
- // download is in a terminal state (COMPLETE or CANCELLED). It is also
- // placed in |in_progress_| and remains there until it has received a
- // valid handle from the history system. Once it has a valid handle, the
- // DownloadItem* is placed in the |history_downloads_| map. When the
- // download reaches a terminal state, it is removed from |in_progress_|.
- // 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.
+ void AddDownloadItemToHistory(DownloadItem* item);
+
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
+ // Map from id to DownloadItem. Owns the DownloadItem.
+ DownloadMap downloads_;
+
// True if the download manager has been initialized and requires a shutdown.
bool shutdown_needed_;
« 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