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

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/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 global_id_(render_process_host_id, request_id), 46 global_id_(render_process_host_id, request_id),
47 render_view_id_(render_view_id), 47 render_view_id_(render_view_id),
48 content_length_(0), 48 content_length_(0),
49 download_file_manager_(download_file_manager), 49 download_file_manager_(download_file_manager),
50 request_(request), 50 request_(request),
51 save_as_(save_as), 51 save_as_(save_as),
52 started_cb_(started_cb), 52 started_cb_(started_cb),
53 save_info_(save_info), 53 save_info_(save_info),
54 buffer_(new content::DownloadBuffer), 54 buffer_(new content::DownloadBuffer),
55 rdh_(rdh), 55 rdh_(rdh),
56 is_paused_(false) { 56 is_paused_(false),
57 start_offset_(0) {
57 DCHECK(dl_id.IsValid()); 58 DCHECK(dl_id.IsValid());
58 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); 59 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT);
59 } 60 }
60 61
61 bool DownloadResourceHandler::OnUploadProgress(int request_id, 62 bool DownloadResourceHandler::OnUploadProgress(int request_id,
62 uint64 position, 63 uint64 position,
63 uint64 size) { 64 uint64 size) {
64 return true; 65 return true;
65 } 66 }
66 67
(...skipping 26 matching lines...) Expand all
93 ResourceDispatcherHost::InfoForRequest(request_); 94 ResourceDispatcherHost::InfoForRequest(request_);
94 95
95 // Deleted in DownloadManager. 96 // Deleted in DownloadManager.
96 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(), 97 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(),
97 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, 98 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS,
98 download_id_, request_info->has_user_gesture(), 99 download_id_, request_info->has_user_gesture(),
99 request_info->transition_type()); 100 request_info->transition_type());
100 info->url_chain = request_->url_chain(); 101 info->url_chain = request_->url_chain();
101 info->referrer_url = GURL(request_->referrer()); 102 info->referrer_url = GURL(request_->referrer());
102 info->start_time = base::Time::Now(); 103 info->start_time = base::Time::Now();
103 info->received_bytes = 0; 104 info->received_bytes = start_offset_;
104 info->total_bytes = content_length_; 105 info->total_bytes = content_length_;
105 info->state = DownloadItem::IN_PROGRESS; 106 info->state = DownloadItem::IN_PROGRESS;
106 info->download_id = download_id_; 107 info->download_id = download_id_;
107 info->has_user_gesture = request_info->has_user_gesture(); 108 info->has_user_gesture = request_info->has_user_gesture();
108 info->content_disposition = content_disposition_; 109 info->content_disposition = content_disposition_;
109 info->mime_type = response->response_head.mime_type; 110 info->mime_type = response->response_head.mime_type;
110 download_stats::RecordDownloadMimeType(info->mime_type); 111 download_stats::RecordDownloadMimeType(info->mime_type);
112 info->continued_download = (start_offset_ > 0);
111 113
112 DownloadRequestHandle request_handle(rdh_, global_id_.child_id, 114 DownloadRequestHandle request_handle(rdh_, global_id_.child_id,
113 render_view_id_, global_id_.request_id); 115 render_view_id_, global_id_.request_id);
114 116
115 // TODO(ahendrickson) -- Get the last modified time and etag, so we can 117 // Get the last modified time and etag.
116 // resume downloading. 118 const net::HttpResponseHeaders* headers = request_->response_headers();
119 if (headers) {
120 std::string last_modified_hdr;
121 std::string etag;
122 if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr))
123 info->last_modified = last_modified_hdr;
124 if (headers->EnumerateHeader(NULL, "ETag", &etag))
125 info->etag = etag;
126 }
117 127
118 CallStartedCB(net::OK); 128 CallStartedCB(net::OK);
119 129
120 std::string content_type_header; 130 std::string content_type_header;
121 if (!response->response_head.headers || 131 if (!response->response_head.headers ||
122 !response->response_head.headers->GetMimeType(&content_type_header)) 132 !response->response_head.headers->GetMimeType(&content_type_header))
123 content_type_header = ""; 133 content_type_header = "";
124 info->original_mime_type = content_type_header; 134 info->original_mime_type = content_type_header;
125 135
126 info->prompt_user_for_save_location = 136 info->prompt_user_for_save_location =
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 " render_view_id_ = " "%d" 318 " render_view_id_ = " "%d"
309 " save_info_.file_path = \"%" PRFilePath "\"" 319 " save_info_.file_path = \"%" PRFilePath "\""
310 " }", 320 " }",
311 request_->url().spec().c_str(), 321 request_->url().spec().c_str(),
312 download_id_.local(), 322 download_id_.local(),
313 global_id_.child_id, 323 global_id_.child_id,
314 global_id_.request_id, 324 global_id_.request_id,
315 render_view_id_, 325 render_view_id_,
316 save_info_.file_path.value().c_str()); 326 save_info_.file_path.value().c_str());
317 } 327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698