| 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_BASE_FILE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // Indicate that the download has finished. No new data will be received. | 57 // Indicate that the download has finished. No new data will be received. |
| 58 void Finish(); | 58 void Finish(); |
| 59 | 59 |
| 60 // Informs the OS that this file came from the internet. | 60 // Informs the OS that this file came from the internet. |
| 61 void AnnotateWithSourceInformation(); | 61 void AnnotateWithSourceInformation(); |
| 62 | 62 |
| 63 FilePath full_path() const { return full_path_; } | 63 FilePath full_path() const { return full_path_; } |
| 64 bool in_progress() const { return file_stream_ != NULL; } | 64 bool in_progress() const { return file_stream_ != NULL; } |
| 65 int64 bytes_so_far() const { return bytes_so_far_; } | 65 int64 bytes_so_far() const { return bytes_so_far_; } |
| 66 | 66 |
| 67 // Set |hash| with sha256 digest for the file. | 67 // Sets the sha256 digest for the file from |hash|. |
| 68 // Used to restore the hash in the case of download resumption. |
| 69 // Returns true on success, false on failure. |
| 70 bool SetSha256Hash(const std::string& hash); |
| 71 |
| 72 // Sets |hash| with sha256 digest for the file. |
| 68 // Returns true if digest is successfully calculated. | 73 // Returns true if digest is successfully calculated. |
| 69 virtual bool GetSha256Hash(std::string* hash); | 74 virtual bool GetSha256Hash(std::string* hash); |
| 70 | 75 |
| 71 // Returns true if the given hash is considered empty. An empty hash is | 76 // Returns true if the given hash is considered empty. An empty hash is |
| 72 // a string of size kSha256HashLen that contains only zeros (initial value | 77 // a string of size kSha256HashLen that contains only zeros (initial value |
| 73 // for the hash). | 78 // for the hash). |
| 74 static bool IsEmptySha256Hash(const std::string& hash); | 79 static bool IsEmptySha256Hash(const std::string& hash); |
| 75 | 80 |
| 76 virtual std::string DebugString() const; | 81 virtual std::string DebugString() const; |
| 77 | 82 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 unsigned char sha256_hash_[kSha256HashLen]; | 122 unsigned char sha256_hash_[kSha256HashLen]; |
| 118 | 123 |
| 119 // Indicates that this class no longer owns the associated file, and so | 124 // Indicates that this class no longer owns the associated file, and so |
| 120 // won't delete it on destruction. | 125 // won't delete it on destruction. |
| 121 bool detached_; | 126 bool detached_; |
| 122 | 127 |
| 123 DISALLOW_COPY_AND_ASSIGN(BaseFile); | 128 DISALLOW_COPY_AND_ASSIGN(BaseFile); |
| 124 }; | 129 }; |
| 125 | 130 |
| 126 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ | 131 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ |
| OLD | NEW |