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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 class CONTENT_EXPORT Observer { | 80 class CONTENT_EXPORT Observer { |
81 public: | 81 public: |
82 // A DownloadItem was created. Unlike ModelChanged, this item may be | 82 // A DownloadItem was created. Unlike ModelChanged, this item may be |
83 // visible before the filename is determined; in this case the return value | 83 // visible before the filename is determined; in this case the return value |
84 // of GetTargetFileName() will be null. This method may be called an | 84 // of GetTargetFileName() will be null. This method may be called an |
85 // arbitrary number of times, e.g. when loading history on startup. As a | 85 // arbitrary number of times, e.g. when loading history on startup. As a |
86 // result, consumers should avoid doing large amounts of work in | 86 // result, consumers should avoid doing large amounts of work in |
87 // OnDownloadCreated(). TODO(<whoever>): When we've fully specified the | 87 // OnDownloadCreated(). TODO(<whoever>): When we've fully specified the |
88 // possible states of the DownloadItem in download_item.h and removed | 88 // possible states of the DownloadItem in download_item.h and removed |
89 // ModelChanged, we should remove the caveat above. | 89 // ModelChanged, we should remove the caveat above. |
| 90 // DO NOT create another download synchronously in OnDownloadCreated(). |
90 virtual void OnDownloadCreated( | 91 virtual void OnDownloadCreated( |
91 DownloadManager* manager, DownloadItem* item) {} | 92 DownloadManager* manager, DownloadItem* item) {} |
92 | 93 |
93 // New or deleted download, observers should query us for the current set | 94 // New or deleted download, observers should query us for the current set |
94 // of downloads. | 95 // of downloads. |
95 virtual void ModelChanged(DownloadManager* manager) {} | 96 virtual void ModelChanged(DownloadManager* manager) {} |
96 | 97 |
97 // Called when the DownloadManager is being destroyed to prevent Observers | 98 // Called when the DownloadManager is being destroyed to prevent Observers |
98 // from calling back to a stale pointer. | 99 // from calling back to a stale pointer. |
99 virtual void ManagerGoingDown(DownloadManager* manager) {} | 100 virtual void ManagerGoingDown(DownloadManager* manager) {} |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; | 166 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; |
166 | 167 |
167 // Allow objects to observe the download creation process. | 168 // Allow objects to observe the download creation process. |
168 virtual void AddObserver(Observer* observer) = 0; | 169 virtual void AddObserver(Observer* observer) = 0; |
169 | 170 |
170 // Remove a download observer from ourself. | 171 // Remove a download observer from ourself. |
171 virtual void RemoveObserver(Observer* observer) = 0; | 172 virtual void RemoveObserver(Observer* observer) = 0; |
172 | 173 |
173 // Called by the embedder, after creating the download manager, to let it know | 174 // Called by the embedder, after creating the download manager, to let it know |
174 // about downloads from previous runs of the browser. | 175 // about downloads from previous runs of the browser. |
175 virtual void OnPersistentStoreQueryComplete( | 176 virtual DownloadItem* CreateDownloadItem( |
176 std::vector<DownloadPersistentStoreInfo>* entries) = 0; | 177 const FilePath& path, |
177 | 178 const GURL& url, |
178 // Called by the embedder, in response to | 179 const GURL& referrer_url, |
179 // DownloadManagerDelegate::AddItemToPersistentStore. | 180 const base::Time& start_time, |
180 virtual void OnItemAddedToPersistentStore(int32 download_id, | 181 const base::Time& end_time, |
181 int64 db_handle) = 0; | 182 int64 received_bytes, |
| 183 int64 total_bytes, |
| 184 DownloadItem::DownloadState state, |
| 185 bool opened) = 0; |
182 | 186 |
183 // The number of in progress (including paused) downloads. | 187 // The number of in progress (including paused) downloads. |
184 virtual int InProgressCount() const = 0; | 188 virtual int InProgressCount() const = 0; |
185 | 189 |
186 virtual BrowserContext* GetBrowserContext() const = 0; | 190 virtual BrowserContext* GetBrowserContext() const = 0; |
187 | 191 |
188 // Checks whether downloaded files still exist. Updates state of downloads | 192 // Checks whether downloaded files still exist. Updates state of downloads |
189 // that refer to removed files. The check runs in the background and may | 193 // that refer to removed files. The check runs in the background and may |
190 // finish asynchronously after this method returns. | 194 // finish asynchronously after this method returns. |
191 virtual void CheckForHistoryFilesRemoval() = 0; | 195 virtual void CheckForHistoryFilesRemoval() = 0; |
192 | 196 |
193 // Get the download item from the history map. Useful after the item has | 197 // Get the download item from the history map. Useful after the item has |
194 // been removed from the active map, or was retrieved from the history DB. | 198 // been removed from the active map, or was retrieved from the history DB. |
195 virtual DownloadItem* GetDownloadItem(int id) = 0; | 199 virtual DownloadItem* GetDownloadItem(int id) = 0; |
196 | 200 |
197 // Get the download item for |id| if present, no matter what type of download | 201 // Get the download item for |id| if present, no matter what type of download |
198 // it is or state it's in. | 202 // it is or state it's in. |
199 virtual DownloadItem* GetDownload(int id) = 0; | 203 virtual DownloadItem* GetDownload(int id) = 0; |
200 | 204 |
201 // Called when Save Page download is done. | |
202 virtual void SavePageDownloadFinished(DownloadItem* download) = 0; | |
203 | |
204 // Get the download item from the active map. Useful when the item is not | 205 // Get the download item from the active map. Useful when the item is not |
205 // yet in the history map. | 206 // yet in the history map. |
206 virtual DownloadItem* GetActiveDownloadItem(int id) = 0; | 207 virtual DownloadItem* GetActiveDownloadItem(int id) = 0; |
207 | 208 |
208 protected: | 209 protected: |
209 virtual ~DownloadManager() {} | 210 virtual ~DownloadManager() {} |
210 | 211 |
211 private: | 212 private: |
212 friend class base::RefCountedThreadSafe<DownloadManager>; | 213 friend class base::RefCountedThreadSafe<DownloadManager>; |
213 }; | 214 }; |
214 | 215 |
215 } // namespace content | 216 } // namespace content |
216 | 217 |
217 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 218 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
OLD | NEW |