| OLD | NEW |
| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 373 } |
| 374 | 374 |
| 375 RecordAcceptsRanges(accept_ranges_, bytes_read_); | 375 RecordAcceptsRanges(accept_ranges_, bytes_read_); |
| 376 RecordNetworkBlockage( | 376 RecordNetworkBlockage( |
| 377 base::TimeTicks::Now() - download_start_time_, total_pause_time_); | 377 base::TimeTicks::Now() - download_start_time_, total_pause_time_); |
| 378 | 378 |
| 379 CallStartedCB(NULL, error_code); | 379 CallStartedCB(NULL, error_code); |
| 380 | 380 |
| 381 // 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 |
| 382 // OnResponseCompleted without OnResponseStarted. | 382 // OnResponseCompleted without OnResponseStarted. |
| 383 if (stream_writer_.get()) | 383 if (stream_writer_) |
| 384 stream_writer_->Close(reason); | 384 stream_writer_->Close(reason); |
| 385 | 385 |
| 386 // If the error mapped to something unknown, record it so that | 386 // If the error mapped to something unknown, record it so that |
| 387 // we can drill down. | 387 // we can drill down. |
| 388 if (reason == DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED) { | 388 if (reason == DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED) { |
| 389 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.MapErrorNetworkFailed", | 389 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.MapErrorNetworkFailed", |
| 390 std::abs(status.error()), | 390 std::abs(status.error()), |
| 391 net::GetAllErrorCodesForUma()); | 391 net::GetAllErrorCodesForUma()); |
| 392 } | 392 } |
| 393 | 393 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 473 |
| 474 DownloadResourceHandler::~DownloadResourceHandler() { | 474 DownloadResourceHandler::~DownloadResourceHandler() { |
| 475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 476 | 476 |
| 477 // This won't do anything if the callback was called before. | 477 // This won't do anything if the callback was called before. |
| 478 // If it goes through, it will likely be because OnWillStart() returned | 478 // If it goes through, it will likely be because OnWillStart() returned |
| 479 // false somewhere in the chain of resource handlers. | 479 // false somewhere in the chain of resource handlers. |
| 480 CallStartedCB(NULL, net::ERR_ACCESS_DENIED); | 480 CallStartedCB(NULL, net::ERR_ACCESS_DENIED); |
| 481 | 481 |
| 482 // Remove output stream callback if a stream exists. | 482 // Remove output stream callback if a stream exists. |
| 483 if (stream_writer_.get()) | 483 if (stream_writer_) |
| 484 stream_writer_->RegisterCallback(base::Closure()); | 484 stream_writer_->RegisterCallback(base::Closure()); |
| 485 | 485 |
| 486 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 486 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", |
| 487 base::TimeTicks::Now() - download_start_time_); | 487 base::TimeTicks::Now() - download_start_time_); |
| 488 } | 488 } |
| 489 | 489 |
| 490 } // namespace content | 490 } // namespace content |
| OLD | NEW |