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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rearranged structures for greater consistency. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/browser/download/download_resource_handler.h" 5 #include "content/browser/download/download_resource_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ResourceDispatcherHost::InfoForRequest(request_); 93 ResourceDispatcherHost::InfoForRequest(request_);
94 94
95 // Deleted in DownloadManager. 95 // Deleted in DownloadManager.
96 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(), 96 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(),
97 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, 97 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS,
98 download_id_, request_info->has_user_gesture(), 98 download_id_, request_info->has_user_gesture(),
99 request_info->transition_type()); 99 request_info->transition_type());
100 info->url_chain = request_->url_chain(); 100 info->url_chain = request_->url_chain();
101 info->referrer_url = GURL(request_->referrer()); 101 info->referrer_url = GURL(request_->referrer());
102 info->start_time = base::Time::Now(); 102 info->start_time = base::Time::Now();
103 info->received_bytes = 0; 103 info->received_bytes = save_info_.offset;
104 info->total_bytes = content_length_; 104 info->total_bytes = content_length_;
105 info->state = DownloadItem::IN_PROGRESS; 105 info->state = DownloadItem::IN_PROGRESS;
106 info->download_id = download_id_; 106 info->download_id = download_id_;
107 info->has_user_gesture = request_info->has_user_gesture(); 107 info->has_user_gesture = request_info->has_user_gesture();
108 info->content_disposition = content_disposition_; 108 info->content_disposition = content_disposition_;
109 info->mime_type = response->response_head.mime_type; 109 info->mime_type = response->response_head.mime_type;
110 download_stats::RecordDownloadMimeType(info->mime_type); 110 download_stats::RecordDownloadMimeType(info->mime_type);
111 111
112 DownloadRequestHandle request_handle(rdh_, global_id_.child_id, 112 DownloadRequestHandle request_handle(rdh_, global_id_.child_id,
113 render_view_id_, global_id_.request_id); 113 render_view_id_, global_id_.request_id);
114 114
115 // TODO(ahendrickson) -- Get the last modified time and etag, so we can 115 // Get the last modified time and etag.
116 // resume downloading. 116 const net::HttpResponseHeaders* headers = request_->response_headers();
117 if (headers) {
118 std::string last_modified_hdr;
119 std::string etag;
120 if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr))
121 info->last_modified = last_modified_hdr;
122 if (headers->EnumerateHeader(NULL, "ETag", &etag))
123 info->etag = etag;
124 }
117 125
118 CallStartedCB(net::OK); 126 CallStartedCB(net::OK);
119 127
120 std::string content_type_header; 128 std::string content_type_header;
121 if (!response->response_head.headers || 129 if (!response->response_head.headers ||
122 !response->response_head.headers->GetMimeType(&content_type_header)) 130 !response->response_head.headers->GetMimeType(&content_type_header))
123 content_type_header = ""; 131 content_type_header = "";
124 info->original_mime_type = content_type_header; 132 info->original_mime_type = content_type_header;
125 133
126 info->prompt_user_for_save_location = 134 info->prompt_user_for_save_location =
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 " render_view_id_ = " "%d" 316 " render_view_id_ = " "%d"
309 " save_info_.file_path = \"%" PRFilePath "\"" 317 " save_info_.file_path = \"%" PRFilePath "\""
310 " }", 318 " }",
311 request_->url().spec().c_str(), 319 request_->url().spec().c_str(),
312 download_id_.local(), 320 download_id_.local(),
313 global_id_.child_id, 321 global_id_.child_id,
314 global_id_.request_id, 322 global_id_.request_id,
315 render_view_id_, 323 render_view_id_,
316 save_info_.file_path.value().c_str()); 324 save_info_.file_path.value().c_str());
317 } 325 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698