| 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_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "crypto/secure_hash.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 // Holds the information about how to save a download file. | 18 // Holds the information about how to save a download file. |
| 18 // In the case of download continuation, |file_path| is set to the current file | 19 // In the case of download continuation, |file_path| is set to the current file |
| 19 // name, |offset| is set to the point where we left off, and |hash_state| will | 20 // name, |offset| is set to the point where we left off, and |hash_state| will |
| 20 // hold the state of the hash algorithm where we left off. | 21 // hold the state of the hash algorithm where we left off. |
| 21 struct CONTENT_EXPORT DownloadSaveInfo { | 22 struct CONTENT_EXPORT DownloadSaveInfo { |
| 22 DownloadSaveInfo(); | 23 DownloadSaveInfo(); |
| 23 ~DownloadSaveInfo(); | 24 ~DownloadSaveInfo(); |
| 25 DownloadSaveInfo(DownloadSaveInfo&& that); |
| 24 | 26 |
| 25 // If non-empty, contains the full target path of the download that has been | 27 // If non-empty, contains the full target path of the download that has been |
| 26 // determined prior to download initiation. This is considered to be a trusted | 28 // determined prior to download initiation. This is considered to be a trusted |
| 27 // path. | 29 // path. |
| 28 base::FilePath file_path; | 30 base::FilePath file_path; |
| 29 | 31 |
| 30 // If non-empty, contains an untrusted filename suggestion. This can't contain | 32 // If non-empty, contains an untrusted filename suggestion. This can't contain |
| 31 // a path (only a filename), and is only effective if |file_path| is empty. | 33 // a path (only a filename), and is only effective if |file_path| is empty. |
| 32 base::string16 suggested_name; | 34 base::string16 suggested_name; |
| 33 | 35 |
| 34 // If valid, contains the source data stream for the file contents. | 36 // If valid, contains the source data stream for the file contents. |
| 35 base::File file; | 37 base::File file; |
| 36 | 38 |
| 37 // The file offset at which to start the download. May be 0. | 39 // The file offset at which to start the download. May be 0. |
| 38 int64_t offset; | 40 int64_t offset; |
| 39 | 41 |
| 40 // The state of the hash at the start of the download. May be empty. | 42 // The state of the hash. If specified, this hash state must indicate the |
| 41 std::string hash_state; | 43 // state of the partial file for the first |offset| bytes. |
| 44 scoped_ptr<crypto::SecureHash> hash_state; |
| 45 |
| 46 // SHA-256 hash of the first |offset| bytes of the file. Only used if |offset| |
| 47 // is non-zero and either |file_path| or |file| specifies the file which |
| 48 // contains the |offset| number of bytes. Can be empty, in which case no |
| 49 // verification is done on the existing file. |
| 50 std::string hash_of_partial_file; |
| 42 | 51 |
| 43 // If |prompt_for_save_location| is true, and |file_path| is empty, then | 52 // If |prompt_for_save_location| is true, and |file_path| is empty, then |
| 44 // the user will be prompted for a location to save the download. Otherwise, | 53 // the user will be prompted for a location to save the download. Otherwise, |
| 45 // the location will be determined automatically using |file_path| as a | 54 // the location will be determined automatically using |file_path| as a |
| 46 // basis if |file_path| is not empty. | 55 // basis if |file_path| is not empty. |
| 47 // |prompt_for_save_location| defaults to false. | 56 // |prompt_for_save_location| defaults to false. |
| 48 bool prompt_for_save_location; | 57 bool prompt_for_save_location; |
| 49 | 58 |
| 50 private: | 59 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(DownloadSaveInfo); | 60 DISALLOW_COPY_AND_ASSIGN(DownloadSaveInfo); |
| 52 }; | 61 }; |
| 53 | 62 |
| 54 } // namespace content | 63 } // namespace content |
| 55 | 64 |
| 56 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_ | 65 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_ |
| OLD | NEW |