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_FILE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | |
| 12 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 14 #include "content/public/browser/download_id.h" | 15 #include "content/public/browser/download_id.h" |
| 15 #include "content/public/browser/download_interrupt_reasons.h" | 16 #include "content/public/browser/download_interrupt_reasons.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class DownloadManager; | 20 class DownloadManager; |
| 20 | 21 |
| 21 // These objects live exclusively on the file thread and handle the writing | 22 // These objects live exclusively on the file thread and handle the writing |
| 22 // operations for one download. These objects live only for the duration that | 23 // operations for one download. These objects live only for the duration that |
| 23 // the download is 'in progress': once the download has been completed or | 24 // the download is 'in progress': once the download has been completed or |
| 24 // cancelled, the DownloadFile is destroyed. | 25 // cancelled, the DownloadFile is destroyed. |
| 25 class CONTENT_EXPORT DownloadFile { | 26 class CONTENT_EXPORT DownloadFile { |
| 26 public: | 27 public: |
| 28 // Callback used with Rename(). |reason| will be | |
| 29 // DOWNLOAD_INTERRUPT_REASON_NONE on a successful rename. | |
| 30 typedef base::Callback<void(content::DownloadInterruptReason reason, | |
| 31 const FilePath&)> RenameCompletionCallback; | |
| 32 | |
| 27 virtual ~DownloadFile() {} | 33 virtual ~DownloadFile() {} |
| 28 | 34 |
| 29 // If calculate_hash is true, sha256 hash will be calculated. | 35 // If calculate_hash is true, sha256 hash will be calculated. |
| 30 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a network | 36 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a network |
| 31 // error code on failure. | 37 // error code on failure. |
| 32 virtual DownloadInterruptReason Initialize() = 0; | 38 virtual DownloadInterruptReason Initialize() = 0; |
| 33 | 39 |
| 34 // Rename the download file. | 40 // Rename the download file. |
| 35 // Returns net::OK on success, or a network error code on failure. | 41 // Returns net::OK on success, or a network error code on failure. |
|
asanka
2012/07/05 18:47:21
Mention new arguments. In particular also mention
Randy Smith (Not in Mondays)
2012/07/09 20:35:51
Good point--thanks for catching this. Done.
| |
| 36 virtual DownloadInterruptReason Rename(const FilePath& full_path) = 0; | 42 virtual void Rename(const FilePath& full_path, |
| 43 bool overwrite_existing_file, | |
| 44 const RenameCompletionCallback& callback) = 0; | |
| 37 | 45 |
| 38 // Detach the file so it is not deleted on destruction. | 46 // Detach the file so it is not deleted on destruction. |
| 39 virtual void Detach() = 0; | 47 virtual void Detach() = 0; |
| 40 | 48 |
| 41 // Abort the download and automatically close the file. | 49 // Abort the download and automatically close the file. |
| 42 virtual void Cancel() = 0; | 50 virtual void Cancel() = 0; |
| 43 | 51 |
| 44 // Informs the OS that this file came from the internet. | 52 // Informs the OS that this file came from the internet. |
| 45 virtual void AnnotateWithSourceInformation() = 0; | 53 virtual void AnnotateWithSourceInformation() = 0; |
| 46 | 54 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 62 virtual int Id() const = 0; | 70 virtual int Id() const = 0; |
| 63 virtual DownloadManager* GetDownloadManager() = 0; | 71 virtual DownloadManager* GetDownloadManager() = 0; |
| 64 virtual const DownloadId& GlobalId() const = 0; | 72 virtual const DownloadId& GlobalId() const = 0; |
| 65 | 73 |
| 66 virtual std::string DebugString() const = 0; | 74 virtual std::string DebugString() const = 0; |
| 67 }; | 75 }; |
| 68 | 76 |
| 69 } // namespace content | 77 } // namespace content |
| 70 | 78 |
| 71 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 79 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| OLD | NEW |