| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Each download is represented by a DownloadItem, and all DownloadItems | 5 // Each download is represented by a DownloadItem, and all DownloadItems |
| 6 // are owned by the DownloadManager which maintains a global list of all | 6 // are owned by the DownloadManager which maintains a global list of all |
| 7 // downloads. DownloadItems are created when a user initiates a download, | 7 // downloads. DownloadItems are created when a user initiates a download, |
| 8 // and exist for the duration of the browser life time. | 8 // and exist for the duration of the browser life time. |
| 9 // | 9 // |
| 10 // Download observers: | 10 // Download observers: |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // exit to prevent this crash. This may result in a difference between the | 163 // exit to prevent this crash. This may result in a difference between the |
| 164 // downloaded file's size on disk, and what the history system's last record | 164 // downloaded file's size on disk, and what the history system's last record |
| 165 // of it is. At worst, we'll end up re-downloading a small portion of the file | 165 // of it is. At worst, we'll end up re-downloading a small portion of the file |
| 166 // when resuming a download (assuming the server supports byte ranges). | 166 // when resuming a download (assuming the server supports byte ranges). |
| 167 void Cancel(bool update_history); | 167 void Cancel(bool update_history); |
| 168 | 168 |
| 169 // Called by external code (SavePackage) using the DownloadItem interface | 169 // Called by external code (SavePackage) using the DownloadItem interface |
| 170 // to display progress when the DownloadItem should be considered complete. | 170 // to display progress when the DownloadItem should be considered complete. |
| 171 void MarkAsComplete(); | 171 void MarkAsComplete(); |
| 172 | 172 |
| 173 // Called by the delegate after it delayed completing the download in | 173 // Called by the delegate after it delayed completing the download in |
| 174 // DownloadManagerDelegate::ShouldCompleteDownload. | 174 // DownloadManagerDelegate::ShouldCompleteDownload. |
| 175 void CompleteDelayedDownload(); | 175 void CompleteDelayedDownload(); |
| 176 | 176 |
| 177 // Called when all data has been saved. Only has display effects. | 177 // Called when all data has been saved. Only has display effects. |
| 178 void OnAllDataSaved(int64 size); | 178 void OnAllDataSaved(int64 size); |
| 179 | 179 |
| 180 // Called when the downloaded file is removed. | 180 // Called when the downloaded file is removed. |
| 181 void OnDownloadedFileRemoved(); | 181 void OnDownloadedFileRemoved(); |
| 182 | 182 |
| 183 // Download operation had an error. | 183 // Download operation had an error. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // Returns the user-verified target file path for the download. | 315 // Returns the user-verified target file path for the download. |
| 316 // This returns the same path as GetTargetFilePath() for safe downloads | 316 // This returns the same path as GetTargetFilePath() for safe downloads |
| 317 // but does not for dangerous downloads until the name is verified. | 317 // but does not for dangerous downloads until the name is verified. |
| 318 FilePath GetUserVerifiedFilePath() const; | 318 FilePath GetUserVerifiedFilePath() const; |
| 319 | 319 |
| 320 // Returns true if the current file name is not the final target name yet. | 320 // Returns true if the current file name is not the final target name yet. |
| 321 bool NeedsRename() const { | 321 bool NeedsRename() const { |
| 322 return state_info_.target_name != full_path_.BaseName(); | 322 return state_info_.target_name != full_path_.BaseName(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 // Cancels the off-thread aspects of the download. |
| 326 // TODO(rdsmith): This should be private and only called from |
| 327 // DownloadItem::Cancel/Interrupt; it isn't now because we can't |
| 328 // call those functions from |
| 329 // DownloadManager::FileSelectionCancelled() without doing some |
| 330 // rewrites of the DownloadManager queues. |
| 331 void OffThreadCancel(DownloadFileManager* file_manager); |
| 332 |
| 325 std::string DebugString(bool verbose) const; | 333 std::string DebugString(bool verbose) const; |
| 326 | 334 |
| 327 #ifdef UNIT_TEST | 335 #ifdef UNIT_TEST |
| 328 // Mock opening downloads (for testing only). | 336 // Mock opening downloads (for testing only). |
| 329 void TestMockDownloadOpen() { open_enabled_ = false; } | 337 void TestMockDownloadOpen() { open_enabled_ = false; } |
| 330 #endif | 338 #endif |
| 331 | 339 |
| 332 private: | 340 private: |
| 333 // Construction common to all constructors. |active| should be true for new | 341 // Construction common to all constructors. |active| should be true for new |
| 334 // downloads and false for downloads from the history. | 342 // downloads and false for downloads from the history. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // only. | 475 // only. |
| 468 bool open_enabled_; | 476 bool open_enabled_; |
| 469 | 477 |
| 470 // Did the delegate delay calling Complete on this download? | 478 // Did the delegate delay calling Complete on this download? |
| 471 bool delegate_delayed_complete_; | 479 bool delegate_delayed_complete_; |
| 472 | 480 |
| 473 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 481 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
| 474 }; | 482 }; |
| 475 | 483 |
| 476 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 484 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |