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

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

Issue 20609004: [Downloads] Some UMA for downloads resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 RecordDownloadContentDisposition(info->content_disposition); 164 RecordDownloadContentDisposition(info->content_disposition);
165 165
166 info->request_handle = 166 info->request_handle =
167 DownloadRequestHandle(AsWeakPtr(), global_id_.child_id, 167 DownloadRequestHandle(AsWeakPtr(), global_id_.child_id,
168 render_view_id_, global_id_.request_id); 168 render_view_id_, global_id_.request_id);
169 169
170 // Get the last modified time and etag. 170 // Get the last modified time and etag.
171 const net::HttpResponseHeaders* headers = request_->response_headers(); 171 const net::HttpResponseHeaders* headers = request_->response_headers();
172 if (headers) { 172 if (headers) {
173 std::string last_modified_hdr; 173 std::string last_modified_hdr;
174 std::string etag;
175 if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr)) 174 if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr))
176 info->last_modified = last_modified_hdr; 175 info->last_modified = last_modified_hdr;
177 if (headers->EnumerateHeader(NULL, "ETag", &etag)) 176 if (headers->EnumerateHeader(NULL, "ETag", &etag_))
178 info->etag = etag; 177 info->etag = etag_;
179 178
180 int status = headers->response_code(); 179 int status = headers->response_code();
181 if (2 == status / 100 && status != net::HTTP_PARTIAL_CONTENT) { 180 if (2 == status / 100 && status != net::HTTP_PARTIAL_CONTENT) {
182 // Success & not range response; if we asked for a range, we didn't 181 // Success & not range response; if we asked for a range, we didn't
183 // get it--reset the file pointers to reflect that. 182 // get it--reset the file pointers to reflect that.
184 save_info_->offset = 0; 183 save_info_->offset = 0;
185 save_info_->hash_state = ""; 184 save_info_->hash_state = "";
186 } 185 }
187 } 186 }
188 187
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 default: // All other errors. 365 default: // All other errors.
367 // Redirection and informational codes should have been handled earlier 366 // Redirection and informational codes should have been handled earlier
368 // in the stack. 367 // in the stack.
369 DCHECK_NE(3, response_code / 100); 368 DCHECK_NE(3, response_code / 100);
370 DCHECK_NE(1, response_code / 100); 369 DCHECK_NE(1, response_code / 100);
371 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED; 370 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED;
372 break; 371 break;
373 } 372 }
374 } 373 }
375 374
376 RecordAcceptsRanges(accept_ranges_, bytes_read_); 375 RecordAcceptsRanges(accept_ranges_, bytes_read_, etag_);
377 RecordNetworkBlockage( 376 RecordNetworkBlockage(
378 base::TimeTicks::Now() - download_start_time_, total_pause_time_); 377 base::TimeTicks::Now() - download_start_time_, total_pause_time_);
379 378
380 CallStartedCB(NULL, error_code); 379 CallStartedCB(NULL, error_code);
381 380
382 // Send the info down the stream. Conditional is in case we get 381 // Send the info down the stream. Conditional is in case we get
383 // OnResponseCompleted without OnResponseStarted. 382 // OnResponseCompleted without OnResponseStarted.
384 if (stream_writer_) 383 if (stream_writer_)
385 stream_writer_->Close(reason); 384 stream_writer_->Close(reason);
386 385
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 481
483 // Remove output stream callback if a stream exists. 482 // Remove output stream callback if a stream exists.
484 if (stream_writer_) 483 if (stream_writer_)
485 stream_writer_->RegisterCallback(base::Closure()); 484 stream_writer_->RegisterCallback(base::Closure());
486 485
487 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", 486 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration",
488 base::TimeTicks::Now() - download_start_time_); 487 base::TimeTicks::Now() - download_start_time_);
489 } 488 }
490 489
491 } // namespace content 490 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_resource_handler.h ('k') | content/browser/download/download_stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698