Chromium Code Reviews| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 // should be considered complete. | 209 // should be considered complete. |
| 210 virtual void MarkAsComplete(); | 210 virtual void MarkAsComplete(); |
| 211 | 211 |
| 212 private: | 212 private: |
| 213 // Fine grained states of a download. | 213 // Fine grained states of a download. |
| 214 enum DownloadInternalState { | 214 enum DownloadInternalState { |
| 215 // Unless otherwise specified, state transitions are linear forward | 215 // Unless otherwise specified, state transitions are linear forward |
| 216 // in this list. | 216 // in this list. |
| 217 | 217 |
| 218 // Includes both before and after file name determination. | 218 // Includes both before and after file name determination. |
| 219 // TODO(rdsmith): Put in state variable for file name determination. | 219 // TODO(rdsmith): Put in state variable for file name determination. |
|
Randy Smith (Not in Mondays)
2013/05/09 01:00:57
Add a note that RESUMING_INTERNAL can transition i
asanka
2013/05/09 16:54:33
Done.
| |
| 220 IN_PROGRESS_INTERNAL, | 220 IN_PROGRESS_INTERNAL, |
| 221 | 221 |
| 222 // Between commit point (dispatch of download file release) and completed. | 222 // Between commit point (dispatch of download file release) and completed. |
| 223 // Embedder may be opening the file in this state. Note that the | 223 // Embedder may be opening the file in this state. Note that the |
| 224 // DownloadItem may be deleted (by shutdown) or interrupted (e.g. due to a | 224 // DownloadItem may be deleted (by shutdown) or interrupted (e.g. due to a |
| 225 // failure during AnnotateWithSourceInformation()) in this state. | 225 // failure during AnnotateWithSourceInformation()) in this state. |
| 226 COMPLETING_INTERNAL, | 226 COMPLETING_INTERNAL, |
| 227 | 227 |
| 228 // After embedder has had a chance to auto-open. User may now open | 228 // After embedder has had a chance to auto-open. User may now open |
| 229 // or auto-open based on extension. | 229 // or auto-open based on extension. |
| 230 COMPLETE_INTERNAL, | 230 COMPLETE_INTERNAL, |
| 231 | 231 |
| 232 // User has cancelled the download. | 232 // User has cancelled the download. |
| 233 // Only incoming transition IN_PROGRESS-> | 233 // Only incoming transition IN_PROGRESS-> |
|
Randy Smith (Not in Mondays)
2013/05/09 01:00:57
This is wrong; we can cancel interrupted downloads
asanka
2013/05/09 16:54:33
Done.
| |
| 234 CANCELLED_INTERNAL, | 234 CANCELLED_INTERNAL, |
| 235 | 235 |
| 236 // An error has interrupted the download. | 236 // An error has interrupted the download. |
| 237 // Only incoming transition IN_PROGRESS-> | 237 // Only incoming transitions IN_PROGRESS-> and RESUMING_INTERNAL. |
|
Randy Smith (Not in Mondays)
2013/05/09 01:00:57
I don't actually remember how I was thinking of th
asanka
2013/05/09 16:54:33
I added notes listing all the transitions. Let me
| |
| 238 INTERRUPTED_INTERNAL, | 238 INTERRUPTED_INTERNAL, |
| 239 | 239 |
| 240 // A request to resume this interrupted download is in progress. | |
| 241 // Only incoming transition INTERRUPTED_INTERNAL. | |
| 242 RESUMING_INTERNAL, | |
| 243 | |
| 240 MAX_DOWNLOAD_INTERNAL_STATE, | 244 MAX_DOWNLOAD_INTERNAL_STATE, |
| 241 }; | 245 }; |
| 242 | 246 |
| 243 // DownloadDestinationObserver | 247 // DownloadDestinationObserver |
| 244 virtual void DestinationUpdate(int64 bytes_so_far, | 248 virtual void DestinationUpdate(int64 bytes_so_far, |
| 245 int64 bytes_per_sec, | 249 int64 bytes_per_sec, |
| 246 const std::string& hash_state) OVERRIDE; | 250 const std::string& hash_state) OVERRIDE; |
| 247 virtual void DestinationError(DownloadInterruptReason reason) OVERRIDE; | 251 virtual void DestinationError(DownloadInterruptReason reason) OVERRIDE; |
| 248 virtual void DestinationCompleted(const std::string& final_hash) OVERRIDE; | 252 virtual void DestinationCompleted(const std::string& final_hash) OVERRIDE; |
| 249 | 253 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 const base::FilePath& full_path); | 294 const base::FilePath& full_path); |
| 291 | 295 |
| 292 // Called if the embedder took over opening a download, to indicate that | 296 // Called if the embedder took over opening a download, to indicate that |
| 293 // the download has been opened. | 297 // the download has been opened. |
| 294 void DelayedDownloadOpened(bool auto_opened); | 298 void DelayedDownloadOpened(bool auto_opened); |
| 295 | 299 |
| 296 // Called when the entire download operation (including renaming etc) | 300 // Called when the entire download operation (including renaming etc) |
| 297 // is completed. | 301 // is completed. |
| 298 void Completed(); | 302 void Completed(); |
| 299 | 303 |
| 304 // Callback invoked when the URLRequest for a download resumption has started. | |
| 305 void OnResumeRequestStarted(DownloadItem* item, net::Error error); | |
| 306 | |
| 300 // Helper routines ----------------------------------------------------------- | 307 // Helper routines ----------------------------------------------------------- |
| 301 | 308 |
| 302 // Indicate that an error has occurred on the download. | 309 // Indicate that an error has occurred on the download. |
| 303 void Interrupt(DownloadInterruptReason reason); | 310 void Interrupt(DownloadInterruptReason reason); |
| 304 | 311 |
| 305 // Destroy the DownloadFile object. If |destroy_file| is true, the file is | 312 // Destroy the DownloadFile object. If |destroy_file| is true, the file is |
| 306 // destroyed with it. Otherwise, DownloadFile::Detach() is called before | 313 // destroyed with it. Otherwise, DownloadFile::Detach() is called before |
| 307 // object destruction to prevent file destruction. Destroying the file also | 314 // object destruction to prevent file destruction. Destroying the file also |
| 308 // resets |current_path_|. | 315 // resets |current_path_|. |
| 309 void ReleaseDownloadFile(bool destroy_file); | 316 void ReleaseDownloadFile(bool destroy_file); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 const net::BoundNetLog bound_net_log_; | 502 const net::BoundNetLog bound_net_log_; |
| 496 | 503 |
| 497 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 504 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
| 498 | 505 |
| 499 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 506 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
| 500 }; | 507 }; |
| 501 | 508 |
| 502 } // namespace content | 509 } // namespace content |
| 503 | 510 |
| 504 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 511 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
| OLD | NEW |