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 #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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 // the download is 'in progress': once the download has been completed or | 23 // the download is 'in progress': once the download has been completed or |
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 virtual ~DownloadFile() {} | 27 virtual ~DownloadFile() {} |
28 | 28 |
29 // If calculate_hash is true, sha256 hash will be calculated. | 29 // If calculate_hash is true, sha256 hash will be calculated. |
30 // Returns net::OK on success, or a network error code on failure. | 30 // Returns net::OK on success, or a network error code on failure. |
31 virtual net::Error Initialize() = 0; | 31 virtual net::Error Initialize() = 0; |
32 | 32 |
33 // Write a new chunk of data to the file. | |
34 // Returns net::OK on success (all bytes written to the file), | |
35 // or a network error code on failure. | |
36 virtual net::Error AppendDataToFile(const char* data, size_t data_len) = 0; | |
37 | |
38 // Rename the download file. | 33 // Rename the download file. |
39 // Returns net::OK on success, or a network error code on failure. | 34 // Returns net::OK on success, or a network error code on failure. |
40 virtual net::Error Rename(const FilePath& full_path) = 0; | 35 virtual net::Error Rename(const FilePath& full_path) = 0; |
41 | 36 |
42 // Detach the file so it is not deleted on destruction. | 37 // Detach the file so it is not deleted on destruction. |
43 virtual void Detach() = 0; | 38 virtual void Detach() = 0; |
44 | 39 |
45 // Abort the download and automatically close the file. | 40 // Abort the download and automatically close the file. |
46 virtual void Cancel() = 0; | 41 virtual void Cancel() = 0; |
47 | 42 |
48 // Indicate that the download has finished. No new data will be received. | |
49 virtual void Finish() = 0; | |
50 | |
51 // Informs the OS that this file came from the internet. | 43 // Informs the OS that this file came from the internet. |
52 virtual void AnnotateWithSourceInformation() = 0; | 44 virtual void AnnotateWithSourceInformation() = 0; |
53 | 45 |
54 virtual FilePath FullPath() const = 0; | 46 virtual FilePath FullPath() const = 0; |
55 virtual bool InProgress() const = 0; | 47 virtual bool InProgress() const = 0; |
56 virtual int64 BytesSoFar() const = 0; | 48 virtual int64 BytesSoFar() const = 0; |
57 virtual int64 CurrentSpeed() const = 0; | 49 virtual int64 CurrentSpeed() const = 0; |
58 | 50 |
59 // Set |hash| with sha256 digest for the file. | 51 // Set |hash| with sha256 digest for the file. |
60 // Returns true if digest is successfully calculated. | 52 // Returns true if digest is successfully calculated. |
61 virtual bool GetHash(std::string* hash) = 0; | 53 virtual bool GetHash(std::string* hash) = 0; |
62 | 54 |
63 // Returns the current (intermediate) state of the hash as a byte string. | 55 // Returns the current (intermediate) state of the hash as a byte string. |
64 virtual std::string GetHashState() = 0; | 56 virtual std::string GetHashState() = 0; |
65 | 57 |
66 // Cancels the download request associated with this file. | 58 // Cancels the download request associated with this file. |
67 virtual void CancelDownloadRequest() = 0; | 59 virtual void CancelDownloadRequest() = 0; |
68 | 60 |
69 virtual int Id() const = 0; | 61 virtual int Id() const = 0; |
70 virtual DownloadManager* GetDownloadManager() = 0; | 62 virtual DownloadManager* GetDownloadManager() = 0; |
71 virtual const DownloadId& GlobalId() const = 0; | 63 virtual const DownloadId& GlobalId() const = 0; |
72 | 64 |
73 virtual std::string DebugString() const = 0; | 65 virtual std::string DebugString() const = 0; |
74 }; | 66 }; |
75 | 67 |
76 } // namespace content | 68 } // namespace content |
77 | 69 |
78 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 70 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
OLD | NEW |