| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // cancelled, the DownloadFile is destroyed. | 24 // cancelled, the DownloadFile is destroyed. |
| 25 class CONTENT_EXPORT DownloadFile { | 25 class CONTENT_EXPORT DownloadFile { |
| 26 public: | 26 public: |
| 27 // Callback used with Rename(). On a successful rename |reason| will be | 27 // Callback used with Rename(). On a successful rename |reason| will be |
| 28 // DOWNLOAD_INTERRUPT_REASON_NONE and |path| the path the rename | 28 // DOWNLOAD_INTERRUPT_REASON_NONE and |path| the path the rename |
| 29 // was done to. On a failed rename, |reason| will contain the | 29 // was done to. On a failed rename, |reason| will contain the |
| 30 // error. | 30 // error. |
| 31 typedef base::Callback<void(DownloadInterruptReason reason, | 31 typedef base::Callback<void(DownloadInterruptReason reason, |
| 32 const FilePath& path)> RenameCompletionCallback; | 32 const FilePath& path)> RenameCompletionCallback; |
| 33 | 33 |
| 34 // Callback used with Detach(). On success, |reason| will be |
| 35 // DOWNLOAD_INTERRUPT_REASON_NONE. |
| 36 typedef base::Callback<void(DownloadInterruptReason reason)> |
| 37 DetachCompletionCallback; |
| 38 |
| 34 virtual ~DownloadFile() {} | 39 virtual ~DownloadFile() {} |
| 35 | 40 |
| 36 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a network | 41 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a network |
| 37 // error code on failure. Upon completion, |callback| will be | 42 // error code on failure. Upon completion, |callback| will be |
| 38 // called on the UI thread as per the comment above. | 43 // called on the UI thread as per the comment above. |
| 39 virtual content::DownloadInterruptReason Initialize() = 0; | 44 virtual content::DownloadInterruptReason Initialize() = 0; |
| 40 | 45 |
| 41 // Rename the download file to |full_path|. If that file exists and | 46 // Rename the download file to |full_path|. If that file exists and |
| 42 // |overwrite_existing_file| is false, |full_path| will be uniquified by | 47 // |overwrite_existing_file| is false, |full_path| will be uniquified by |
| 43 // suffixing " (<number>)" to the file name before the extension. | 48 // suffixing " (<number>)" to the file name before the extension. |
| 44 // Upon completion, |callback| will be called on the UI thread | 49 // Upon completion, |callback| will be called on the UI thread |
| 45 // as per the comment above. | 50 // as per the comment above. |
| 46 virtual void Rename(const FilePath& full_path, | 51 virtual void Rename(const FilePath& full_path, |
| 47 bool overwrite_existing_file, | 52 bool overwrite_existing_file, |
| 48 const RenameCompletionCallback& callback) = 0; | 53 const RenameCompletionCallback& callback) = 0; |
| 49 | 54 |
| 50 // Detach the file so it is not deleted on destruction. | 55 // Detach the file so it is not deleted on destruction. |
| 51 // |callback| will be called on the UI thread after detach. | 56 // |callback| will be called on the UI thread after detach. |
| 52 virtual void Detach(base::Closure callback) = 0; | 57 virtual void Detach(const DetachCompletionCallback& callback) = 0; |
| 53 | 58 |
| 54 // Abort the download and automatically close the file. | 59 // Abort the download and automatically close the file. |
| 55 virtual void Cancel() = 0; | 60 virtual void Cancel() = 0; |
| 56 | 61 |
| 57 // Informs the OS that this file came from the internet. | |
| 58 virtual void AnnotateWithSourceInformation() = 0; | |
| 59 | |
| 60 virtual FilePath FullPath() const = 0; | 62 virtual FilePath FullPath() const = 0; |
| 61 virtual bool InProgress() const = 0; | 63 virtual bool InProgress() const = 0; |
| 62 virtual int64 BytesSoFar() const = 0; | 64 virtual int64 BytesSoFar() const = 0; |
| 63 virtual int64 CurrentSpeed() const = 0; | 65 virtual int64 CurrentSpeed() const = 0; |
| 64 | 66 |
| 65 // Set |hash| with sha256 digest for the file. | 67 // Set |hash| with sha256 digest for the file. |
| 66 // Returns true if digest is successfully calculated. | 68 // Returns true if digest is successfully calculated. |
| 67 virtual bool GetHash(std::string* hash) = 0; | 69 virtual bool GetHash(std::string* hash) = 0; |
| 68 | 70 |
| 69 // Returns the current (intermediate) state of the hash as a byte string. | 71 // Returns the current (intermediate) state of the hash as a byte string. |
| 70 virtual std::string GetHashState() = 0; | 72 virtual std::string GetHashState() = 0; |
| 71 | 73 |
| 72 // Cancels the download request associated with this file. | 74 // Cancels the download request associated with this file. |
| 73 virtual void CancelDownloadRequest() = 0; | 75 virtual void CancelDownloadRequest() = 0; |
| 74 | 76 |
| 75 virtual int Id() const = 0; | 77 virtual int Id() const = 0; |
| 76 virtual DownloadManager* GetDownloadManager() = 0; | 78 virtual DownloadManager* GetDownloadManager() = 0; |
| 77 virtual const DownloadId& GlobalId() const = 0; | 79 virtual const DownloadId& GlobalId() const = 0; |
| 78 | 80 |
| 79 virtual std::string DebugString() const = 0; | 81 virtual std::string DebugString() const = 0; |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 } // namespace content | 84 } // namespace content |
| 83 | 85 |
| 84 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 86 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| OLD | NEW |