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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 virtual bool Init(BrowserContext* browser_context) = 0; | 125 virtual bool Init(BrowserContext* browser_context) = 0; |
126 | 126 |
127 // Called by a download source (Currently DownloadResourceHandler) | 127 // Called by a download source (Currently DownloadResourceHandler) |
128 // to initiate the non-source portions of a download. | 128 // to initiate the non-source portions of a download. |
129 // Returns the id assigned to the download. If the DownloadCreateInfo | 129 // Returns the id assigned to the download. If the DownloadCreateInfo |
130 // specifies an id, that id will be used. | 130 // specifies an id, that id will be used. |
131 virtual DownloadId StartDownload( | 131 virtual DownloadId StartDownload( |
132 scoped_ptr<DownloadCreateInfo> info, | 132 scoped_ptr<DownloadCreateInfo> info, |
133 scoped_ptr<ByteStreamReader> stream) = 0; | 133 scoped_ptr<ByteStreamReader> stream) = 0; |
134 | 134 |
| 135 // Notifications sent from the download thread to the UI thread |
| 136 virtual void UpdateDownload(int32 download_id, |
| 137 int64 bytes_so_far, |
| 138 int64 bytes_per_sec, |
| 139 const std::string& hash_state) = 0; |
| 140 |
| 141 // |download_id| is the ID of the download. |
| 142 // |size| is the number of bytes that have been downloaded. |
| 143 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
| 144 // is not available. |
| 145 virtual void OnResponseCompleted(int32 download_id, int64 size, |
| 146 const std::string& hash) = 0; |
| 147 |
135 // Offthread target for cancelling a particular download. Will be a no-op | 148 // Offthread target for cancelling a particular download. Will be a no-op |
136 // if the download has already been cancelled. | 149 // if the download has already been cancelled. |
137 virtual void CancelDownload(int32 download_id) = 0; | 150 virtual void CancelDownload(int32 download_id) = 0; |
138 | 151 |
| 152 // Called when there is an error in the download. |
| 153 // |download_id| is the ID of the download. |
| 154 // |size| is the number of bytes that are currently downloaded. |
| 155 // |hash_state| is the current state of the hash of the data that has been |
| 156 // downloaded. |
| 157 // |reason| is a download interrupt reason code. |
| 158 virtual void OnDownloadInterrupted( |
| 159 int32 download_id, |
| 160 DownloadInterruptReason reason) = 0; |
| 161 |
139 // Remove downloads after remove_begin (inclusive) and before remove_end | 162 // Remove downloads after remove_begin (inclusive) and before remove_end |
140 // (exclusive). You may pass in null Time values to do an unbounded delete | 163 // (exclusive). You may pass in null Time values to do an unbounded delete |
141 // in either direction. | 164 // in either direction. |
142 virtual int RemoveDownloadsBetween(base::Time remove_begin, | 165 virtual int RemoveDownloadsBetween(base::Time remove_begin, |
143 base::Time remove_end) = 0; | 166 base::Time remove_end) = 0; |
144 | 167 |
145 // Remove downloads will delete all downloads that have a timestamp that is | 168 // Remove downloads will delete all downloads that have a timestamp that is |
146 // the same or more recent than |remove_begin|. The number of downloads | 169 // the same or more recent than |remove_begin|. The number of downloads |
147 // deleted is returned back to the caller. | 170 // deleted is returned back to the caller. |
148 virtual int RemoveDownloads(base::Time remove_begin) = 0; | 171 virtual int RemoveDownloads(base::Time remove_begin) = 0; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 protected: | 223 protected: |
201 virtual ~DownloadManager() {} | 224 virtual ~DownloadManager() {} |
202 | 225 |
203 private: | 226 private: |
204 friend class base::RefCountedThreadSafe<DownloadManager>; | 227 friend class base::RefCountedThreadSafe<DownloadManager>; |
205 }; | 228 }; |
206 | 229 |
207 } // namespace content | 230 } // namespace content |
208 | 231 |
209 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 232 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
OLD | NEW |