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

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: Merged with trunk 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/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 global_id_(render_process_host_id, request_id), 44 global_id_(render_process_host_id, request_id),
45 render_view_id_(render_view_id), 45 render_view_id_(render_view_id),
46 content_length_(0), 46 content_length_(0),
47 download_file_manager_(download_file_manager), 47 download_file_manager_(download_file_manager),
48 request_(request), 48 request_(request),
49 save_as_(save_as), 49 save_as_(save_as),
50 started_cb_(started_cb), 50 started_cb_(started_cb),
51 save_info_(save_info), 51 save_info_(save_info),
52 buffer_(new content::DownloadBuffer), 52 buffer_(new content::DownloadBuffer),
53 rdh_(rdh), 53 rdh_(rdh),
54 is_paused_(false) { 54 is_paused_(false),
55 was_interrupted_(false),
56 interrupted_bytes_(0) {
55 DCHECK(dl_id.IsValid()); 57 DCHECK(dl_id.IsValid());
56 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); 58 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT);
57 } 59 }
58 60
59 bool DownloadResourceHandler::OnUploadProgress(int request_id, 61 bool DownloadResourceHandler::OnUploadProgress(int request_id,
60 uint64 position, 62 uint64 position,
61 uint64 size) { 63 uint64 size) {
62 return true; 64 return true;
63 } 65 }
64 66
(...skipping 22 matching lines...) Expand all
87 ResourceDispatcherHost::InfoForRequest(request_); 89 ResourceDispatcherHost::InfoForRequest(request_);
88 90
89 // Deleted in DownloadManager. 91 // Deleted in DownloadManager.
90 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(), 92 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(),
91 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, 93 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS,
92 download_id_.local(), request_info->has_user_gesture(), 94 download_id_.local(), request_info->has_user_gesture(),
93 request_info->transition_type()); 95 request_info->transition_type());
94 info->url_chain = request_->url_chain(); 96 info->url_chain = request_->url_chain();
95 info->referrer_url = GURL(request_->referrer()); 97 info->referrer_url = GURL(request_->referrer());
96 info->start_time = base::Time::Now(); 98 info->start_time = base::Time::Now();
97 info->received_bytes = 0; 99 info->received_bytes = was_interrupted_ ? interrupted_bytes_ : 0;
98 info->total_bytes = content_length_; 100 info->total_bytes = content_length_;
99 info->state = DownloadItem::IN_PROGRESS; 101 info->state = DownloadItem::IN_PROGRESS;
100 info->download_id = download_id_.local(); 102 info->download_id = download_id_.local();
101 info->has_user_gesture = request_info->has_user_gesture(); 103 info->has_user_gesture = request_info->has_user_gesture();
102 info->content_disposition = content_disposition_; 104 info->content_disposition = content_disposition_;
103 info->mime_type = response->response_head.mime_type; 105 info->mime_type = response->response_head.mime_type;
104 download_stats::RecordDownloadMimeType(info->mime_type); 106 download_stats::RecordDownloadMimeType(info->mime_type);
107 info->continued_download = was_interrupted_;
105 108
106 DownloadRequestHandle request_handle(rdh_, global_id_.child_id, 109 DownloadRequestHandle request_handle(rdh_, global_id_.child_id,
107 render_view_id_, global_id_.request_id); 110 render_view_id_, global_id_.request_id);
108 111
109 // TODO(ahendrickson) -- Get the last modified time and etag, so we can 112 // If we're starting a new download, get the last modified time and etag.
Randy Smith (Not in Mondays) 2011/10/31 18:46:43 Why don't we get these all the time? Why conditio
ahendrickson 2011/11/13 21:15:20 Done.
110 // resume downloading. 113 if (was_interrupted_) {
114 const net::HttpResponseHeaders* headers = request_->response_headers();
115 if (headers) {
116 std::string last_modified_hdr;
117 std::string etag;
118 if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr))
119 info->last_modified = last_modified_hdr;
120 if (headers->EnumerateHeader(NULL, "ETag", &etag))
121 info->etag = etag;
122 }
123 }
111 124
112 CallStartedCB(net::OK); 125 CallStartedCB(net::OK);
113 126
114 std::string content_type_header; 127 std::string content_type_header;
115 if (!response->response_head.headers || 128 if (!response->response_head.headers ||
116 !response->response_head.headers->GetMimeType(&content_type_header)) 129 !response->response_head.headers->GetMimeType(&content_type_header))
117 content_type_header = ""; 130 content_type_header = "";
118 info->original_mime_type = content_type_header; 131 info->original_mime_type = content_type_header;
119 132
120 info->prompt_user_for_save_location = 133 info->prompt_user_for_save_location =
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 " render_view_id_ = " "%d" 306 " render_view_id_ = " "%d"
294 " save_info_.file_path = \"%" PRFilePath "\"" 307 " save_info_.file_path = \"%" PRFilePath "\""
295 " }", 308 " }",
296 request_->url().spec().c_str(), 309 request_->url().spec().c_str(),
297 download_id_.local(), 310 download_id_.local(),
298 global_id_.child_id, 311 global_id_.child_id,
299 global_id_.request_id, 312 global_id_.request_id,
300 render_view_id_, 313 render_view_id_,
301 save_info_.file_path.value().c_str()); 314 save_info_.file_path.value().c_str());
302 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698