Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: content/public/browser/download_save_info.h

Issue 2660783002: Range request support for parallel download in DownloadRequestCore. (Closed)
Patch Set: Strong validator for all range request. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 10 #include <memory>
11 11
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "crypto/secure_hash.h" 16 #include "crypto/secure_hash.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 // Holds the information about how to save a download file. 20 // Holds the information about how to save a download file.
21 // In the case of download continuation, |file_path| is set to the current file 21 // In the case of download continuation, |file_path| is set to the current file
22 // name, |offset| is set to the point where we left off, and |hash_state| will 22 // name, |offset| is set to the point where we left off, and |hash_state| will
23 // hold the state of the hash algorithm where we left off. 23 // hold the state of the hash algorithm where we left off.
24 struct CONTENT_EXPORT DownloadSaveInfo { 24 struct CONTENT_EXPORT DownloadSaveInfo {
25 // The default value for |length|.
26 static const int kLengthUnknown;
David Trainor- moved to gerrit 2017/02/01 07:14:36 I don't feel strongly, but would a name that more
xingliu 2017/02/01 20:25:46 Changed to kLengthFullContent;
27
25 DownloadSaveInfo(); 28 DownloadSaveInfo();
26 ~DownloadSaveInfo(); 29 ~DownloadSaveInfo();
27 DownloadSaveInfo(DownloadSaveInfo&& that); 30 DownloadSaveInfo(DownloadSaveInfo&& that);
28 31
29 // If non-empty, contains the full target path of the download that has been 32 // If non-empty, contains the full target path of the download that has been
30 // determined prior to download initiation. This is considered to be a trusted 33 // determined prior to download initiation. This is considered to be a trusted
31 // path. 34 // path.
32 base::FilePath file_path; 35 base::FilePath file_path;
33 36
34 // If non-empty, contains an untrusted filename suggestion. This can't contain 37 // If non-empty, contains an untrusted filename suggestion. This can't contain
35 // a path (only a filename), and is only effective if |file_path| is empty. 38 // a path (only a filename), and is only effective if |file_path| is empty.
36 base::string16 suggested_name; 39 base::string16 suggested_name;
37 40
38 // If valid, contains the source data stream for the file contents. 41 // If valid, contains the source data stream for the file contents.
39 base::File file; 42 base::File file;
40 43
41 // The file offset at which to start the download. May be 0. 44 // The file offset at which to start the download. May be 0.
42 int64_t offset; 45 int64_t offset;
43 46
47 // The length of the bytes from |offset|. Set to |kLengthUnknown| by default.
48 // Ask to retrieve segment of the download file when length is greater than 0.
David Trainor- moved to gerrit 2017/02/01 07:14:36 Nit, just curious about whether or not 0 is a vali
xingliu 2017/02/01 20:25:46 Yes, this is something weird, changed the const to
49 // Request the whole file when length is |kLengthUnknown|.
50 int64_t length;
51
44 // The state of the hash. If specified, this hash state must indicate the 52 // The state of the hash. If specified, this hash state must indicate the
45 // state of the partial file for the first |offset| bytes. 53 // state of the partial file for the first |offset| bytes.
46 std::unique_ptr<crypto::SecureHash> hash_state; 54 std::unique_ptr<crypto::SecureHash> hash_state;
47 55
48 // SHA-256 hash of the first |offset| bytes of the file. Only used if |offset| 56 // SHA-256 hash of the first |offset| bytes of the file. Only used if |offset|
49 // is non-zero and either |file_path| or |file| specifies the file which 57 // is non-zero and either |file_path| or |file| specifies the file which
50 // contains the |offset| number of bytes. Can be empty, in which case no 58 // contains the |offset| number of bytes. Can be empty, in which case no
51 // verification is done on the existing file. 59 // verification is done on the existing file.
52 std::string hash_of_partial_file; 60 std::string hash_of_partial_file;
53 61
54 // If |prompt_for_save_location| is true, and |file_path| is empty, then 62 // If |prompt_for_save_location| is true, and |file_path| is empty, then
55 // the user will be prompted for a location to save the download. Otherwise, 63 // the user will be prompted for a location to save the download. Otherwise,
56 // the location will be determined automatically using |file_path| as a 64 // the location will be determined automatically using |file_path| as a
57 // basis if |file_path| is not empty. 65 // basis if |file_path| is not empty.
58 // |prompt_for_save_location| defaults to false. 66 // |prompt_for_save_location| defaults to false.
59 bool prompt_for_save_location; 67 bool prompt_for_save_location;
60 68
61 private: 69 private:
62 DISALLOW_COPY_AND_ASSIGN(DownloadSaveInfo); 70 DISALLOW_COPY_AND_ASSIGN(DownloadSaveInfo);
63 }; 71 };
64 72
65 } // namespace content 73 } // namespace content
66 74
67 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_ 75 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_SAVE_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698