| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 class CONTENT_EXPORT Observer { | 76 class CONTENT_EXPORT Observer { |
| 77 public: | 77 public: |
| 78 // A DownloadItem was created. Unlike ModelChanged, this item may be | 78 // A DownloadItem was created. Unlike ModelChanged, this item may be |
| 79 // visible before the filename is determined; in this case the return value | 79 // visible before the filename is determined; in this case the return value |
| 80 // of GetTargetFileName() will be null. This method may be called an | 80 // of GetTargetFileName() will be null. This method may be called an |
| 81 // arbitrary number of times, e.g. when loading history on startup. As a | 81 // arbitrary number of times, e.g. when loading history on startup. As a |
| 82 // result, consumers should avoid doing large amounts of work in | 82 // result, consumers should avoid doing large amounts of work in |
| 83 // OnDownloadCreated(). TODO(<whoever>): When we've fully specified the | 83 // OnDownloadCreated(). TODO(<whoever>): When we've fully specified the |
| 84 // possible states of the DownloadItem in download_item.h and removed | 84 // possible states of the DownloadItem in download_item.h and removed |
| 85 // ModelChanged, we should remove the caveat above. | 85 // ModelChanged, we should remove the caveat above. |
| 86 // DO NOT create another download synchronously in OnDownloadCreated(). |
| 86 virtual void OnDownloadCreated( | 87 virtual void OnDownloadCreated( |
| 87 DownloadManager* manager, DownloadItem* item) {} | 88 DownloadManager* manager, DownloadItem* item) {} |
| 88 | 89 |
| 89 // New or deleted download, observers should query us for the current set | 90 // New or deleted download, observers should query us for the current set |
| 90 // of downloads. | 91 // of downloads. |
| 91 virtual void ModelChanged(DownloadManager* manager) {} | 92 virtual void ModelChanged(DownloadManager* manager) {} |
| 92 | 93 |
| 93 // Called when the DownloadManager is being destroyed to prevent Observers | 94 // Called when the DownloadManager is being destroyed to prevent Observers |
| 94 // from calling back to a stale pointer. | 95 // from calling back to a stale pointer. |
| 95 virtual void ManagerGoingDown(DownloadManager* manager) {} | 96 virtual void ManagerGoingDown(DownloadManager* manager) {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; | 139 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; |
| 139 | 140 |
| 140 // Allow objects to observe the download creation process. | 141 // Allow objects to observe the download creation process. |
| 141 virtual void AddObserver(Observer* observer) = 0; | 142 virtual void AddObserver(Observer* observer) = 0; |
| 142 | 143 |
| 143 // Remove a download observer from ourself. | 144 // Remove a download observer from ourself. |
| 144 virtual void RemoveObserver(Observer* observer) = 0; | 145 virtual void RemoveObserver(Observer* observer) = 0; |
| 145 | 146 |
| 146 // Called by the embedder, after creating the download manager, to let it know | 147 // Called by the embedder, after creating the download manager, to let it know |
| 147 // about downloads from previous runs of the browser. | 148 // about downloads from previous runs of the browser. |
| 148 virtual void OnPersistentStoreQueryComplete( | 149 virtual DownloadItem* CreateDownloadItem( |
| 149 std::vector<DownloadPersistentStoreInfo>* entries) = 0; | 150 const FilePath& path, |
| 150 | 151 const GURL& url, |
| 151 // Called by the embedder, in response to | 152 const GURL& referrer_url, |
| 152 // DownloadManagerDelegate::AddItemToPersistentStore. | 153 const base::Time& start_time, |
| 153 virtual void OnItemAddedToPersistentStore(int32 download_id, | 154 const base::Time& end_time, |
| 154 int64 db_handle) = 0; | 155 int64 received_bytes, |
| 156 int64 total_bytes, |
| 157 DownloadItem::DownloadState state, |
| 158 bool opened) = 0; |
| 155 | 159 |
| 156 // The number of in progress (including paused) downloads. | 160 // The number of in progress (including paused) downloads. |
| 157 virtual int InProgressCount() const = 0; | 161 virtual int InProgressCount() const = 0; |
| 158 | 162 |
| 159 virtual BrowserContext* GetBrowserContext() const = 0; | 163 virtual BrowserContext* GetBrowserContext() const = 0; |
| 160 | 164 |
| 161 // Checks whether downloaded files still exist. Updates state of downloads | 165 // Checks whether downloaded files still exist. Updates state of downloads |
| 162 // that refer to removed files. The check runs in the background and may | 166 // that refer to removed files. The check runs in the background and may |
| 163 // finish asynchronously after this method returns. | 167 // finish asynchronously after this method returns. |
| 164 virtual void CheckForHistoryFilesRemoval() = 0; | 168 virtual void CheckForHistoryFilesRemoval() = 0; |
| 165 | 169 |
| 166 // Get the download item for |id| if present, no matter what type of download | 170 // Get the download item for |id| if present, no matter what type of download |
| 167 // it is or state it's in. | 171 // it is or state it's in. |
| 168 virtual DownloadItem* GetDownload(int id) = 0; | 172 virtual DownloadItem* GetDownload(int id) = 0; |
| 169 | 173 |
| 170 // Called when Save Page download is done. | |
| 171 virtual void SavePageDownloadFinished(DownloadItem* download) = 0; | |
| 172 | |
| 173 protected: | 174 protected: |
| 174 virtual ~DownloadManager() {} | 175 virtual ~DownloadManager() {} |
| 175 | 176 |
| 176 private: | 177 private: |
| 177 friend class base::RefCountedThreadSafe<DownloadManager>; | 178 friend class base::RefCountedThreadSafe<DownloadManager>; |
| 178 }; | 179 }; |
| 179 | 180 |
| 180 } // namespace content | 181 } // namespace content |
| 181 | 182 |
| 182 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 183 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |