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

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 2809953002: Make the download's response headers available in the DownloadItem (Closed)
Patch Set: comment Created 3 years, 8 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 // File method ordering: Methods in this file are in the same order as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "content/browser/web_contents/web_contents_impl.h" 50 #include "content/browser/web_contents/web_contents_impl.h"
51 #include "content/public/browser/browser_context.h" 51 #include "content/public/browser/browser_context.h"
52 #include "content/public/browser/browser_thread.h" 52 #include "content/public/browser/browser_thread.h"
53 #include "content/public/browser/content_browser_client.h" 53 #include "content/public/browser/content_browser_client.h"
54 #include "content/public/browser/download_danger_type.h" 54 #include "content/public/browser/download_danger_type.h"
55 #include "content/public/browser/download_interrupt_reasons.h" 55 #include "content/public/browser/download_interrupt_reasons.h"
56 #include "content/public/browser/download_url_parameters.h" 56 #include "content/public/browser/download_url_parameters.h"
57 #include "content/public/browser/storage_partition.h" 57 #include "content/public/browser/storage_partition.h"
58 #include "content/public/common/content_features.h" 58 #include "content/public/common/content_features.h"
59 #include "content/public/common/referrer.h" 59 #include "content/public/common/referrer.h"
60 #include "net/http/http_response_headers.h"
60 #include "net/log/net_log.h" 61 #include "net/log/net_log.h"
61 #include "net/log/net_log_event_type.h" 62 #include "net/log/net_log_event_type.h"
62 #include "net/log/net_log_parameters_callback.h" 63 #include "net/log/net_log_parameters_callback.h"
63 #include "net/log/net_log_source.h" 64 #include "net/log/net_log_source.h"
64 65
65 namespace content { 66 namespace content {
66 67
67 namespace { 68 namespace {
68 69
69 bool DeleteDownloadedFile(const base::FilePath& path) { 70 bool DeleteDownloadedFile(const base::FilePath& path) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 url_chain_(info.url_chain), 211 url_chain_(info.url_chain),
211 referrer_url_(info.referrer_url), 212 referrer_url_(info.referrer_url),
212 site_url_(info.site_url), 213 site_url_(info.site_url),
213 tab_url_(info.tab_url), 214 tab_url_(info.tab_url),
214 tab_referrer_url_(info.tab_referrer_url), 215 tab_referrer_url_(info.tab_referrer_url),
215 suggested_filename_(base::UTF16ToUTF8(info.save_info->suggested_name)), 216 suggested_filename_(base::UTF16ToUTF8(info.save_info->suggested_name)),
216 forced_file_path_(info.save_info->file_path), 217 forced_file_path_(info.save_info->file_path),
217 transition_type_(info.transition_type ? info.transition_type.value() 218 transition_type_(info.transition_type ? info.transition_type.value()
218 : ui::PAGE_TRANSITION_LINK), 219 : ui::PAGE_TRANSITION_LINK),
219 has_user_gesture_(info.has_user_gesture), 220 has_user_gesture_(info.has_user_gesture),
221 response_headers_(info.response_headers),
220 content_disposition_(info.content_disposition), 222 content_disposition_(info.content_disposition),
221 mime_type_(info.mime_type), 223 mime_type_(info.mime_type),
222 original_mime_type_(info.original_mime_type), 224 original_mime_type_(info.original_mime_type),
223 remote_address_(info.remote_address), 225 remote_address_(info.remote_address),
224 total_bytes_(info.total_bytes), 226 total_bytes_(info.total_bytes),
225 last_reason_(info.result), 227 last_reason_(info.result),
226 start_tick_(base::TimeTicks::Now()), 228 start_tick_(base::TimeTicks::Now()),
227 state_(INITIAL_INTERNAL), 229 state_(INITIAL_INTERNAL),
228 start_time_(info.start_time), 230 start_time_(info.start_time),
229 delegate_(delegate), 231 delegate_(delegate),
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 600 }
599 601
600 const GURL& DownloadItemImpl::GetTabReferrerUrl() const { 602 const GURL& DownloadItemImpl::GetTabReferrerUrl() const {
601 return tab_referrer_url_; 603 return tab_referrer_url_;
602 } 604 }
603 605
604 std::string DownloadItemImpl::GetSuggestedFilename() const { 606 std::string DownloadItemImpl::GetSuggestedFilename() const {
605 return suggested_filename_; 607 return suggested_filename_;
606 } 608 }
607 609
610 const scoped_refptr<const net::HttpResponseHeaders>&
611 DownloadItemImpl::GetResponseHeaders() const {
612 return response_headers_;
613 }
614
608 std::string DownloadItemImpl::GetContentDisposition() const { 615 std::string DownloadItemImpl::GetContentDisposition() const {
609 return content_disposition_; 616 return content_disposition_;
610 } 617 }
611 618
612 std::string DownloadItemImpl::GetMimeType() const { 619 std::string DownloadItemImpl::GetMimeType() const {
613 return mime_type_; 620 return mime_type_;
614 } 621 }
615 622
616 std::string DownloadItemImpl::GetOriginalMimeType() const { 623 std::string DownloadItemImpl::GetOriginalMimeType() const {
617 return original_mime_type_; 624 return original_mime_type_;
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 origin_state |= ORIGIN_STATE_ON_RESUMPTION_VALIDATORS_CHANGED; 1043 origin_state |= ORIGIN_STATE_ON_RESUMPTION_VALIDATORS_CHANGED;
1037 } 1044 }
1038 if (content_disposition_ != new_create_info.content_disposition) 1045 if (content_disposition_ != new_create_info.content_disposition)
1039 origin_state |= ORIGIN_STATE_ON_RESUMPTION_CONTENT_DISPOSITION_CHANGED; 1046 origin_state |= ORIGIN_STATE_ON_RESUMPTION_CONTENT_DISPOSITION_CHANGED;
1040 RecordOriginStateOnResumption(is_partial, origin_state); 1047 RecordOriginStateOnResumption(is_partial, origin_state);
1041 1048
1042 url_chain_.insert( 1049 url_chain_.insert(
1043 url_chain_.end(), chain_iter, new_create_info.url_chain.end()); 1050 url_chain_.end(), chain_iter, new_create_info.url_chain.end());
1044 etag_ = new_create_info.etag; 1051 etag_ = new_create_info.etag;
1045 last_modified_time_ = new_create_info.last_modified; 1052 last_modified_time_ = new_create_info.last_modified;
1053 response_headers_ = new_create_info.response_headers;
1046 content_disposition_ = new_create_info.content_disposition; 1054 content_disposition_ = new_create_info.content_disposition;
1047 // It is possible that the previous download attempt failed right before the 1055 // It is possible that the previous download attempt failed right before the
1048 // response is received. Need to reset the MIME type. 1056 // response is received. Need to reset the MIME type.
1049 mime_type_ = new_create_info.mime_type; 1057 mime_type_ = new_create_info.mime_type;
1050 1058
1051 // Don't update observers. This method is expected to be called just before a 1059 // Don't update observers. This method is expected to be called just before a
1052 // DownloadFile is created and Start() is called. The observers will be 1060 // DownloadFile is created and Start() is called. The observers will be
1053 // notified when the download transitions to the IN_PROGRESS state. 1061 // notified when the download transitions to the IN_PROGRESS state.
1054 } 1062 }
1055 1063
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 case RESUME_MODE_USER_CONTINUE: 2254 case RESUME_MODE_USER_CONTINUE:
2247 return "USER_CONTINUE"; 2255 return "USER_CONTINUE";
2248 case RESUME_MODE_USER_RESTART: 2256 case RESUME_MODE_USER_RESTART:
2249 return "USER_RESTART"; 2257 return "USER_RESTART";
2250 } 2258 }
2251 NOTREACHED() << "Unknown resume mode " << mode; 2259 NOTREACHED() << "Unknown resume mode " << mode;
2252 return "unknown"; 2260 return "unknown";
2253 } 2261 }
2254 2262
2255 } // namespace content 2263 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698