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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 DestinationObserverAsWeakPtr(); | 190 DestinationObserverAsWeakPtr(); |
191 | 191 |
192 // Get the download's BoundNetLog. | 192 // Get the download's BoundNetLog. |
193 virtual const net::BoundNetLog& GetBoundNetLog() const; | 193 virtual const net::BoundNetLog& GetBoundNetLog() const; |
194 | 194 |
195 // DownloadItemImpl routines only needed by SavePackage ---------------------- | 195 // DownloadItemImpl routines only needed by SavePackage ---------------------- |
196 | 196 |
197 // Called by SavePackage to set the total number of bytes on the item. | 197 // Called by SavePackage to set the total number of bytes on the item. |
198 virtual void SetTotalBytes(int64 total_bytes); | 198 virtual void SetTotalBytes(int64 total_bytes); |
199 | 199 |
200 // Indicate progress in saving data to its destination. | |
201 // |bytes_so_far| is the number of bytes received so far. | |
202 // |hash_state| is the current hash state. | |
203 virtual void UpdateProgress(int64 bytes_so_far, | |
204 int64 bytes_per_sec, | |
205 const std::string& hash_state); | |
206 | |
207 virtual void OnAllDataSaved(const std::string& final_hash); | 200 virtual void OnAllDataSaved(const std::string& final_hash); |
208 | 201 |
209 // Called by SavePackage to display progress when the DownloadItem | 202 // Called by SavePackage to display progress when the DownloadItem |
210 // should be considered complete. | 203 // should be considered complete. |
211 virtual void MarkAsComplete(); | 204 virtual void MarkAsComplete(); |
212 | 205 |
| 206 // DownloadDestinationObserver |
| 207 virtual void DestinationUpdate(int64 bytes_so_far, |
| 208 int64 bytes_per_sec, |
| 209 const std::string& hash_state) OVERRIDE; |
| 210 virtual void DestinationError(DownloadInterruptReason reason) OVERRIDE; |
| 211 virtual void DestinationCompleted(const std::string& final_hash) OVERRIDE; |
| 212 |
213 private: | 213 private: |
214 // Fine grained states of a download. | 214 // Fine grained states of a download. |
215 enum DownloadInternalState { | 215 enum DownloadInternalState { |
216 // Unless otherwise specified, state transitions are linear forward | 216 // Unless otherwise specified, state transitions are linear forward |
217 // in this list. | 217 // in this list. |
218 | 218 |
219 // Includes both before and after file name determination. | 219 // Includes both before and after file name determination. |
220 // TODO(rdsmith): Put in state variable for file name determination. | 220 // TODO(rdsmith): Put in state variable for file name determination. |
221 IN_PROGRESS_INTERNAL, | 221 IN_PROGRESS_INTERNAL, |
222 | 222 |
(...skipping 11 matching lines...) Expand all Loading... |
234 // Only incoming transition IN_PROGRESS-> | 234 // Only incoming transition IN_PROGRESS-> |
235 CANCELLED_INTERNAL, | 235 CANCELLED_INTERNAL, |
236 | 236 |
237 // An error has interrupted the download. | 237 // An error has interrupted the download. |
238 // Only incoming transition IN_PROGRESS-> | 238 // Only incoming transition IN_PROGRESS-> |
239 INTERRUPTED_INTERNAL, | 239 INTERRUPTED_INTERNAL, |
240 | 240 |
241 MAX_DOWNLOAD_INTERNAL_STATE, | 241 MAX_DOWNLOAD_INTERNAL_STATE, |
242 }; | 242 }; |
243 | 243 |
244 // DownloadDestinationObserver | |
245 virtual void DestinationUpdate(int64 bytes_so_far, | |
246 int64 bytes_per_sec, | |
247 const std::string& hash_state) OVERRIDE; | |
248 virtual void DestinationError(DownloadInterruptReason reason) OVERRIDE; | |
249 virtual void DestinationCompleted(const std::string& final_hash) OVERRIDE; | |
250 | |
251 // Normal progression of a download ------------------------------------------ | 244 // Normal progression of a download ------------------------------------------ |
252 | 245 |
253 // These are listed in approximately chronological order. There are also | 246 // These are listed in approximately chronological order. There are also |
254 // public methods involved in normal download progression; see | 247 // public methods involved in normal download progression; see |
255 // the implementation ordering in download_item_impl.cc. | 248 // the implementation ordering in download_item_impl.cc. |
256 | 249 |
257 // Construction common to all constructors. |active| should be true for new | 250 // Construction common to all constructors. |active| should be true for new |
258 // downloads and false for downloads from the history. | 251 // downloads and false for downloads from the history. |
259 // |download_type| indicates to the net log system what kind of download | 252 // |download_type| indicates to the net log system what kind of download |
260 // this is. | 253 // this is. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const net::BoundNetLog bound_net_log_; | 487 const net::BoundNetLog bound_net_log_; |
495 | 488 |
496 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 489 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
497 | 490 |
498 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 491 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
499 }; | 492 }; |
500 | 493 |
501 } // namespace content | 494 } // namespace content |
502 | 495 |
503 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 496 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
OLD | NEW |