Chromium Code Reviews| 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 |prefix_hash| indicates the SHA-256 hash of |
| 160 // the first |offset| bytes of the target file that is expected by the caller. | |
| 161 void set_prefix_hash(const std::string& prefix_hash) { | |
| 162 save_info_.prefix_hash = prefix_hash; | |
| 163 } | |
| 164 | |
| 165 // If |offset| is non-zero, then |hash_state| indicates the SHA-256 hash state | |
| 166 // of the first |offset| bytes of teh target file. In this case, the prefix | |
|
svaldez
2016/03/09 19:27:34
*the
asanka
2016/03/10 16:48:08
Done.
| |
| 167 // hash will be ignored since the |hash_state| is assumed to be correct if | |
| 168 // provided. | |
| 169 void set_hash_state(scoped_ptr<crypto::SecureHash> hash_state) { | |
| 170 save_info_.hash_state = std::move(hash_state); | |
| 160 } | 171 } |
| 161 | 172 |
| 162 // If |prompt| is true, then the user will be prompted for a filename. Ignored | 173 // If |prompt| is true, then the user will be prompted for a filename. Ignored |
| 163 // if |file_path| is non-empty. | 174 // if |file_path| is non-empty. |
| 164 void set_prompt(bool prompt) { save_info_.prompt_for_save_location = prompt; } | 175 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); } | 176 void set_file(base::File file) { save_info_.file = std::move(file); } |
| 166 void set_do_not_prompt_for_login(bool do_not_prompt) { | 177 void set_do_not_prompt_for_login(bool do_not_prompt) { |
| 167 do_not_prompt_for_login_ = do_not_prompt; | 178 do_not_prompt_for_login_ = do_not_prompt; |
| 168 } | 179 } |
| 169 | 180 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 184 int render_frame_host_routing_id() const { | 195 int render_frame_host_routing_id() const { |
| 185 return render_frame_host_routing_id_; | 196 return render_frame_host_routing_id_; |
| 186 } | 197 } |
| 187 const RequestHeadersType& request_headers() const { return request_headers_; } | 198 const RequestHeadersType& request_headers() const { return request_headers_; } |
| 188 ResourceContext* resource_context() const { return resource_context_; } | 199 ResourceContext* resource_context() const { return resource_context_; } |
| 189 const base::FilePath& file_path() const { return save_info_.file_path; } | 200 const base::FilePath& file_path() const { return save_info_.file_path; } |
| 190 const base::string16& suggested_name() const { | 201 const base::string16& suggested_name() const { |
| 191 return save_info_.suggested_name; | 202 return save_info_.suggested_name; |
| 192 } | 203 } |
| 193 int64_t offset() const { return save_info_.offset; } | 204 int64_t offset() const { return save_info_.offset; } |
| 194 const std::string& hash_state() const { return save_info_.hash_state; } | 205 const std::string& prefix_hash() const { return save_info_.prefix_hash; } |
| 195 bool prompt() const { return save_info_.prompt_for_save_location; } | 206 bool prompt() const { return save_info_.prompt_for_save_location; } |
| 196 const GURL& url() const { return url_; } | 207 const GURL& url() const { return url_; } |
| 197 bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; } | 208 bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; } |
| 198 | 209 |
| 199 // Note that this is state changing--the DownloadUrlParameters object | 210 // STATE CHANGING: All save_info_ sub-objects will be in an indeterminate |
| 200 // will not have a file attached to it after this call. | 211 // state following this call. |
| 201 base::File GetFile() { return std::move(save_info_.file); } | 212 DownloadSaveInfo GetSaveInfo() { return std::move(save_info_); } |
| 202 | 213 |
| 203 private: | 214 private: |
| 204 OnStartedCallback callback_; | 215 OnStartedCallback callback_; |
| 205 bool content_initiated_; | 216 bool content_initiated_; |
| 206 RequestHeadersType request_headers_; | 217 RequestHeadersType request_headers_; |
| 207 std::string last_modified_; | 218 std::string last_modified_; |
| 208 std::string etag_; | 219 std::string etag_; |
| 209 std::string method_; | 220 std::string method_; |
| 210 std::string post_body_; | 221 std::string post_body_; |
| 211 int64_t post_id_; | 222 int64_t post_id_; |
| 212 bool prefer_cache_; | 223 bool prefer_cache_; |
| 213 Referrer referrer_; | 224 Referrer referrer_; |
| 214 std::string referrer_encoding_; | 225 std::string referrer_encoding_; |
| 215 int render_process_host_id_; | 226 int render_process_host_id_; |
| 216 int render_view_host_routing_id_; | 227 int render_view_host_routing_id_; |
| 217 int render_frame_host_routing_id_; | 228 int render_frame_host_routing_id_; |
| 218 ResourceContext* resource_context_; | 229 ResourceContext* resource_context_; |
| 219 DownloadSaveInfo save_info_; | 230 DownloadSaveInfo save_info_; |
| 220 GURL url_; | 231 GURL url_; |
| 221 bool do_not_prompt_for_login_; | 232 bool do_not_prompt_for_login_; |
| 222 | 233 |
| 223 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); | 234 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); |
| 224 }; | 235 }; |
| 225 | 236 |
| 226 } // namespace content | 237 } // namespace content |
| 227 | 238 |
| 228 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ | 239 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ |
| OLD | NEW |