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

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

Issue 67883007: [Downloads] Don't store or use validators unless they are strong. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « no previous file | net/tools/testserver/testserver.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 RecordDownloadContentDisposition(info->content_disposition); 161 RecordDownloadContentDisposition(info->content_disposition);
162 162
163 info->request_handle = 163 info->request_handle =
164 DownloadRequestHandle(AsWeakPtr(), request_info->GetChildID(), 164 DownloadRequestHandle(AsWeakPtr(), request_info->GetChildID(),
165 request_info->GetRouteID(), 165 request_info->GetRouteID(),
166 request_info->GetRequestID()); 166 request_info->GetRequestID());
167 167
168 // Get the last modified time and etag. 168 // Get the last modified time and etag.
169 const net::HttpResponseHeaders* headers = request()->response_headers(); 169 const net::HttpResponseHeaders* headers = request()->response_headers();
170 if (headers) { 170 if (headers) {
171 // TODO(asanka): Only store these if headers->HasStrongValidators() is true. 171 if (headers->HasStrongValidators()) {
172 // See RFC 2616 section 13.3.3. 172 // If we don't have strong validators as per RFC 2616 section 13.3.3, then
173 if (!headers->EnumerateHeader(NULL, "Last-Modified", &info->last_modified)) 173 // we neither store nor use them for range requests.
174 info->last_modified.clear(); 174 if (!headers->EnumerateHeader(NULL, "Last-Modified",
175 if (!headers->EnumerateHeader(NULL, "ETag", &info->etag)) 175 &info->last_modified))
176 info->etag.clear(); 176 info->last_modified.clear();
177 if (!headers->EnumerateHeader(NULL, "ETag", &info->etag))
178 info->etag.clear();
179 }
177 180
178 int status = headers->response_code(); 181 int status = headers->response_code();
179 if (2 == status / 100 && status != net::HTTP_PARTIAL_CONTENT) { 182 if (2 == status / 100 && status != net::HTTP_PARTIAL_CONTENT) {
180 // Success & not range response; if we asked for a range, we didn't 183 // Success & not range response; if we asked for a range, we didn't
181 // get it--reset the file pointers to reflect that. 184 // get it--reset the file pointers to reflect that.
182 info->save_info->offset = 0; 185 info->save_info->offset = 0;
183 info->save_info->hash_state = ""; 186 info->save_info->hash_state = "";
184 } 187 }
185 188
186 if (!headers->GetMimeType(&info->original_mime_type)) 189 if (!headers->GetMimeType(&info->original_mime_type))
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 467
465 // Remove output stream callback if a stream exists. 468 // Remove output stream callback if a stream exists.
466 if (stream_writer_) 469 if (stream_writer_)
467 stream_writer_->RegisterCallback(base::Closure()); 470 stream_writer_->RegisterCallback(base::Closure());
468 471
469 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", 472 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration",
470 base::TimeTicks::Now() - download_start_time_); 473 base::TimeTicks::Now() - download_start_time_);
471 } 474 }
472 475
473 } // namespace content 476 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | net/tools/testserver/testserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698