OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The DownloadManager object manages the process of downloading, including | 5 // The DownloadManager object manages the process of downloading, including |
6 // updates to the history system and providing the information for displaying | 6 // updates to the history system and providing the information for displaying |
7 // the downloads view in the Destinations tab. There is one DownloadManager per | 7 // the downloads view in the Destinations tab. There is one DownloadManager per |
8 // active browser context in Chrome. | 8 // active browser context in Chrome. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 DownloadManager* manager, DownloadItem* item) {} | 91 DownloadManager* manager, DownloadItem* item) {} |
92 | 92 |
93 // New or deleted download, observers should query us for the current set | 93 // New or deleted download, observers should query us for the current set |
94 // of downloads. | 94 // of downloads. |
95 virtual void ModelChanged(DownloadManager* manager) {} | 95 virtual void ModelChanged(DownloadManager* manager) {} |
96 | 96 |
97 // Called when the DownloadManager is being destroyed to prevent Observers | 97 // Called when the DownloadManager is being destroyed to prevent Observers |
98 // from calling back to a stale pointer. | 98 // from calling back to a stale pointer. |
99 virtual void ManagerGoingDown(DownloadManager* manager) {} | 99 virtual void ManagerGoingDown(DownloadManager* manager) {} |
100 | 100 |
101 // Called immediately after the DownloadManager puts up a select file | |
102 // dialog. | |
103 // |id| indicates which download opened the dialog. | |
104 virtual void SelectFileDialogDisplayed( | |
105 DownloadManager* manager, int32 id) {} | |
106 | |
107 protected: | 101 protected: |
108 virtual ~Observer() {} | 102 virtual ~Observer() {} |
109 }; | 103 }; |
110 | 104 |
111 typedef std::vector<DownloadItem*> DownloadVector; | 105 typedef std::vector<DownloadItem*> DownloadVector; |
112 | 106 |
113 // If |dir_path| is empty, appends all temporary downloads to |*result|. | 107 // If |dir_path| is empty, appends all temporary downloads to |*result|. |
114 // Otherwise, appends all temporary downloads that reside in |dir_path| to | 108 // Otherwise, appends all temporary downloads that reside in |dir_path| to |
115 // |*result|. | 109 // |*result|. |
116 virtual void GetTemporaryDownloads(const FilePath& dir_path, | 110 virtual void GetTemporaryDownloads(const FilePath& dir_path, |
(...skipping 10 matching lines...) Expand all Loading... |
127 virtual void SearchDownloads(const string16& query, | 121 virtual void SearchDownloads(const string16& query, |
128 DownloadVector* result) = 0; | 122 DownloadVector* result) = 0; |
129 | 123 |
130 // Returns true if initialized properly. | 124 // Returns true if initialized properly. |
131 virtual bool Init(BrowserContext* browser_context) = 0; | 125 virtual bool Init(BrowserContext* browser_context) = 0; |
132 | 126 |
133 // Called by a download source (Currently DownloadResourceHandler) | 127 // Called by a download source (Currently DownloadResourceHandler) |
134 // to initiate the non-source portions of a download. | 128 // to initiate the non-source portions of a download. |
135 // Returns the id assigned to the download. If the DownloadCreateInfo | 129 // Returns the id assigned to the download. If the DownloadCreateInfo |
136 // specifies an id, that id will be used. | 130 // specifies an id, that id will be used. |
137 virtual content::DownloadId StartDownload( | 131 virtual DownloadId StartDownload( |
138 scoped_ptr<DownloadCreateInfo> info, | 132 scoped_ptr<DownloadCreateInfo> info, |
139 scoped_ptr<content::ByteStreamReader> stream) = 0; | 133 scoped_ptr<ByteStreamReader> stream) = 0; |
140 | 134 |
141 // Notifications sent from the download thread to the UI thread | 135 // Notifications sent from the download thread to the UI thread |
142 virtual void UpdateDownload(int32 download_id, | 136 virtual void UpdateDownload(int32 download_id, |
143 int64 bytes_so_far, | 137 int64 bytes_so_far, |
144 int64 bytes_per_sec, | 138 int64 bytes_per_sec, |
145 const std::string& hash_state) = 0; | 139 const std::string& hash_state) = 0; |
146 | 140 |
147 // |download_id| is the ID of the download. | 141 // |download_id| is the ID of the download. |
148 // |size| is the number of bytes that have been downloaded. | 142 // |size| is the number of bytes that have been downloaded. |
149 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 143 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Called by the embedder, in response to | 191 // Called by the embedder, in response to |
198 // DownloadManagerDelegate::AddItemToPersistentStore. | 192 // DownloadManagerDelegate::AddItemToPersistentStore. |
199 virtual void OnItemAddedToPersistentStore(int32 download_id, | 193 virtual void OnItemAddedToPersistentStore(int32 download_id, |
200 int64 db_handle) = 0; | 194 int64 db_handle) = 0; |
201 | 195 |
202 // The number of in progress (including paused) downloads. | 196 // The number of in progress (including paused) downloads. |
203 virtual int InProgressCount() const = 0; | 197 virtual int InProgressCount() const = 0; |
204 | 198 |
205 virtual BrowserContext* GetBrowserContext() const = 0; | 199 virtual BrowserContext* GetBrowserContext() const = 0; |
206 | 200 |
207 virtual FilePath LastDownloadPath() = 0; | |
208 | |
209 // Clears the last download path, used to initialize "save as" dialogs. | |
210 virtual void ClearLastDownloadPath() = 0; | |
211 | |
212 // Called by the delegate after the save as dialog is closed. | |
213 virtual void FileSelected(const FilePath& path, int32 download_id) = 0; | |
214 virtual void FileSelectionCanceled(int32 download_id) = 0; | |
215 | |
216 // Called by the delegate if it delayed the download in | |
217 // DownloadManagerDelegate::ShouldStartDownload and now is ready. | |
218 virtual void RestartDownload(int32 download_id) = 0; | |
219 | |
220 // Checks whether downloaded files still exist. Updates state of downloads | 201 // Checks whether downloaded files still exist. Updates state of downloads |
221 // that refer to removed files. The check runs in the background and may | 202 // that refer to removed files. The check runs in the background and may |
222 // finish asynchronously after this method returns. | 203 // finish asynchronously after this method returns. |
223 virtual void CheckForHistoryFilesRemoval() = 0; | 204 virtual void CheckForHistoryFilesRemoval() = 0; |
224 | 205 |
225 // Get the download item from the history map. Useful after the item has | 206 // Get the download item from the history map. Useful after the item has |
226 // been removed from the active map, or was retrieved from the history DB. | 207 // been removed from the active map, or was retrieved from the history DB. |
227 virtual DownloadItem* GetDownloadItem(int id) = 0; | 208 virtual DownloadItem* GetDownloadItem(int id) = 0; |
228 | 209 |
229 // Get the download item for |id| if present, no matter what type of download | 210 // Get the download item for |id| if present, no matter what type of download |
(...skipping 12 matching lines...) Expand all Loading... |
242 protected: | 223 protected: |
243 virtual ~DownloadManager() {} | 224 virtual ~DownloadManager() {} |
244 | 225 |
245 private: | 226 private: |
246 friend class base::RefCountedThreadSafe<DownloadManager>; | 227 friend class base::RefCountedThreadSafe<DownloadManager>; |
247 }; | 228 }; |
248 | 229 |
249 } // namespace content | 230 } // namespace content |
250 | 231 |
251 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 232 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
OLD | NEW |