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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; | 171 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; |
171 | 172 |
172 // Allow objects to observe the download creation process. | 173 // Allow objects to observe the download creation process. |
173 virtual void AddObserver(Observer* observer) = 0; | 174 virtual void AddObserver(Observer* observer) = 0; |
174 | 175 |
175 // Remove a download observer from ourself. | 176 // Remove a download observer from ourself. |
176 virtual void RemoveObserver(Observer* observer) = 0; | 177 virtual void RemoveObserver(Observer* observer) = 0; |
177 | 178 |
178 // Called by the embedder, after creating the download manager, to let it know | 179 // Called by the embedder, after creating the download manager, to let it know |
179 // about downloads from previous runs of the browser. | 180 // about downloads from previous runs of the browser. |
180 virtual void OnPersistentStoreQueryComplete( | 181 virtual DownloadItem* CreateDownloadItem( |
181 std::vector<DownloadPersistentStoreInfo>* entries) = 0; | 182 const FilePath& path, |
182 | 183 const GURL& url, |
183 // Called by the embedder, in response to | 184 const GURL& referrer_url, |
184 // DownloadManagerDelegate::AddItemToPersistentStore. | 185 const base::Time& start_time, |
185 virtual void OnItemAddedToPersistentStore(int32 download_id, | 186 const base::Time& end_time, |
186 int64 db_handle) = 0; | 187 int64 received_bytes, |
| 188 int64 total_bytes, |
| 189 DownloadItem::DownloadState state, |
| 190 bool opened) = 0; |
187 | 191 |
188 // The number of in progress (including paused) downloads. | 192 // The number of in progress (including paused) downloads. |
189 virtual int InProgressCount() const = 0; | 193 virtual int InProgressCount() const = 0; |
190 | 194 |
191 virtual BrowserContext* GetBrowserContext() const = 0; | 195 virtual BrowserContext* GetBrowserContext() const = 0; |
192 | 196 |
193 // Checks whether downloaded files still exist. Updates state of downloads | 197 // Checks whether downloaded files still exist. Updates state of downloads |
194 // that refer to removed files. The check runs in the background and may | 198 // that refer to removed files. The check runs in the background and may |
195 // finish asynchronously after this method returns. | 199 // finish asynchronously after this method returns. |
196 virtual void CheckForHistoryFilesRemoval() = 0; | 200 virtual void CheckForHistoryFilesRemoval() = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
213 protected: | 217 protected: |
214 virtual ~DownloadManager() {} | 218 virtual ~DownloadManager() {} |
215 | 219 |
216 private: | 220 private: |
217 friend class base::RefCountedThreadSafe<DownloadManager>; | 221 friend class base::RefCountedThreadSafe<DownloadManager>; |
218 }; | 222 }; |
219 | 223 |
220 } // namespace content | 224 } // namespace content |
221 | 225 |
222 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 226 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
OLD | NEW |