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_URL_PARAMETERS_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ |
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 // Suggested filename for the download. The suggestion can be overridden by | 149 // Suggested filename for the download. The suggestion can be overridden by |
150 // either a Content-Disposition response header or a |file_path|. | 150 // either a Content-Disposition response header or a |file_path|. |
151 void set_suggested_name(const base::string16& suggested_name) { | 151 void set_suggested_name(const base::string16& suggested_name) { |
152 save_info_.suggested_name = suggested_name; | 152 save_info_.suggested_name = suggested_name; |
153 } | 153 } |
154 | 154 |
155 // If |offset| is non-zero, then a byte range request will be issued to fetch | 155 // If |offset| is non-zero, then a byte range request will be issued to fetch |
156 // the range of bytes starting at |offset| through to the end of thedownload. | 156 // the range of bytes starting at |offset| through to the end of thedownload. |
157 void set_offset(int64_t offset) { save_info_.offset = offset; } | 157 void set_offset(int64_t offset) { save_info_.offset = offset; } |
158 void set_hash_state(const std::string& hash_state) { | 158 |
159 save_info_.hash_state = hash_state; | 159 // If |offset| is non-zero, then |hash_of_partial_file| contains the raw |
| 160 // SHA-256 hash of the first |offset| bytes of the target file. Only |
| 161 // meaningful if a partial file exists and is identified by either the |
| 162 // |file_path()| or |file()|. |
| 163 void set_hash_of_partial_file(const std::string& hash_of_partial_file) { |
| 164 save_info_.hash_of_partial_file = hash_of_partial_file; |
| 165 } |
| 166 |
| 167 // If |offset| is non-zero, then |hash_state| indicates the SHA-256 hash state |
| 168 // of the first |offset| bytes of the target file. In this case, the prefix |
| 169 // hash will be ignored since the |hash_state| is assumed to be correct if |
| 170 // provided. |
| 171 void set_hash_state(scoped_ptr<crypto::SecureHash> hash_state) { |
| 172 save_info_.hash_state = std::move(hash_state); |
160 } | 173 } |
161 | 174 |
162 // If |prompt| is true, then the user will be prompted for a filename. Ignored | 175 // If |prompt| is true, then the user will be prompted for a filename. Ignored |
163 // if |file_path| is non-empty. | 176 // if |file_path| is non-empty. |
164 void set_prompt(bool prompt) { save_info_.prompt_for_save_location = prompt; } | 177 void set_prompt(bool prompt) { save_info_.prompt_for_save_location = prompt; } |
165 void set_file(base::File file) { save_info_.file = std::move(file); } | 178 void set_file(base::File file) { save_info_.file = std::move(file); } |
166 void set_do_not_prompt_for_login(bool do_not_prompt) { | 179 void set_do_not_prompt_for_login(bool do_not_prompt) { |
167 do_not_prompt_for_login_ = do_not_prompt; | 180 do_not_prompt_for_login_ = do_not_prompt; |
168 } | 181 } |
169 | 182 |
(...skipping 14 matching lines...) Expand all Loading... |
184 int render_frame_host_routing_id() const { | 197 int render_frame_host_routing_id() const { |
185 return render_frame_host_routing_id_; | 198 return render_frame_host_routing_id_; |
186 } | 199 } |
187 const RequestHeadersType& request_headers() const { return request_headers_; } | 200 const RequestHeadersType& request_headers() const { return request_headers_; } |
188 ResourceContext* resource_context() const { return resource_context_; } | 201 ResourceContext* resource_context() const { return resource_context_; } |
189 const base::FilePath& file_path() const { return save_info_.file_path; } | 202 const base::FilePath& file_path() const { return save_info_.file_path; } |
190 const base::string16& suggested_name() const { | 203 const base::string16& suggested_name() const { |
191 return save_info_.suggested_name; | 204 return save_info_.suggested_name; |
192 } | 205 } |
193 int64_t offset() const { return save_info_.offset; } | 206 int64_t offset() const { return save_info_.offset; } |
194 const std::string& hash_state() const { return save_info_.hash_state; } | 207 const std::string& hash_of_partial_file() const { |
| 208 return save_info_.hash_of_partial_file; |
| 209 } |
195 bool prompt() const { return save_info_.prompt_for_save_location; } | 210 bool prompt() const { return save_info_.prompt_for_save_location; } |
196 const GURL& url() const { return url_; } | 211 const GURL& url() const { return url_; } |
197 bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; } | 212 bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; } |
198 | 213 |
199 // Note that this is state changing--the DownloadUrlParameters object | 214 // STATE CHANGING: All save_info_ sub-objects will be in an indeterminate |
200 // will not have a file attached to it after this call. | 215 // state following this call. |
201 base::File GetFile() { return std::move(save_info_.file); } | 216 DownloadSaveInfo GetSaveInfo() { return std::move(save_info_); } |
202 | 217 |
203 private: | 218 private: |
204 OnStartedCallback callback_; | 219 OnStartedCallback callback_; |
205 bool content_initiated_; | 220 bool content_initiated_; |
206 RequestHeadersType request_headers_; | 221 RequestHeadersType request_headers_; |
207 std::string last_modified_; | 222 std::string last_modified_; |
208 std::string etag_; | 223 std::string etag_; |
209 std::string method_; | 224 std::string method_; |
210 std::string post_body_; | 225 std::string post_body_; |
211 int64_t post_id_; | 226 int64_t post_id_; |
212 bool prefer_cache_; | 227 bool prefer_cache_; |
213 Referrer referrer_; | 228 Referrer referrer_; |
214 std::string referrer_encoding_; | 229 std::string referrer_encoding_; |
215 int render_process_host_id_; | 230 int render_process_host_id_; |
216 int render_view_host_routing_id_; | 231 int render_view_host_routing_id_; |
217 int render_frame_host_routing_id_; | 232 int render_frame_host_routing_id_; |
218 ResourceContext* resource_context_; | 233 ResourceContext* resource_context_; |
219 DownloadSaveInfo save_info_; | 234 DownloadSaveInfo save_info_; |
220 GURL url_; | 235 GURL url_; |
221 bool do_not_prompt_for_login_; | 236 bool do_not_prompt_for_login_; |
222 | 237 |
223 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); | 238 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); |
224 }; | 239 }; |
225 | 240 |
226 } // namespace content | 241 } // namespace content |
227 | 242 |
228 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ | 243 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ |
OLD | NEW |