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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (status.status() == net::URLRequestStatus::CANCELED && | 376 if (status.status() == net::URLRequestStatus::CANCELED && |
377 status.error() == net::ERR_ABORTED) { | 377 status.error() == net::ERR_ABORTED) { |
378 // CANCELED + ERR_ABORTED == something outside of the network | 378 // CANCELED + ERR_ABORTED == something outside of the network |
379 // stack cancelled the request. There aren't that many things that | 379 // stack cancelled the request. There aren't that many things that |
380 // could do this to a download request (whose lifetime is separated from | 380 // could do this to a download request (whose lifetime is separated from |
381 // the tab from which it came). We map this to USER_CANCELLED as the | 381 // the tab from which it came). We map this to USER_CANCELLED as the |
382 // case we know about (system suspend because of laptop close) corresponds | 382 // case we know about (system suspend because of laptop close) corresponds |
383 // to a user action. | 383 // to a user action. |
384 // TODO(ahendrickson) -- Find a better set of codes to use here, as | 384 // TODO(ahendrickson) -- Find a better set of codes to use here, as |
385 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. | 385 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. |
386 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; | 386 if (net::IsCertStatusError(request()->ssl_info().cert_status)) |
| 387 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM; |
| 388 else |
| 389 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; |
387 } | 390 } |
388 | 391 |
389 if (status.is_success() && | 392 if (status.is_success() && |
390 reason == DOWNLOAD_INTERRUPT_REASON_NONE && | 393 reason == DOWNLOAD_INTERRUPT_REASON_NONE && |
391 request()->response_headers()) { | 394 request()->response_headers()) { |
392 // Handle server's response codes. | 395 // Handle server's response codes. |
393 switch(response_code) { | 396 switch(response_code) { |
394 case -1: // Non-HTTP request. | 397 case -1: // Non-HTTP request. |
395 case net::HTTP_OK: | 398 case net::HTTP_OK: |
396 case net::HTTP_CREATED: | 399 case net::HTTP_CREATED: |
(...skipping 10 matching lines...) Expand all Loading... |
407 case net::HTTP_PRECONDITION_FAILED: | 410 case net::HTTP_PRECONDITION_FAILED: |
408 // Failed our 'If-Unmodified-Since' or 'If-Match'; see | 411 // Failed our 'If-Unmodified-Since' or 'If-Match'; see |
409 // download_manager_impl.cc BeginDownload() | 412 // download_manager_impl.cc BeginDownload() |
410 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_PRECONDITION; | 413 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_PRECONDITION; |
411 break; | 414 break; |
412 case net::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE: | 415 case net::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE: |
413 // Retry by downloading from the start automatically: | 416 // Retry by downloading from the start automatically: |
414 // If we haven't received data when we get this error, we won't. | 417 // If we haven't received data when we get this error, we won't. |
415 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE; | 418 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE; |
416 break; | 419 break; |
| 420 case net::HTTP_UNAUTHORIZED: |
| 421 // Server didn't authorize this request. |
| 422 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED; |
| 423 break; |
417 default: // All other errors. | 424 default: // All other errors. |
418 // Redirection and informational codes should have been handled earlier | 425 // Redirection and informational codes should have been handled earlier |
419 // in the stack. | 426 // in the stack. |
420 DCHECK_NE(3, response_code / 100); | 427 DCHECK_NE(3, response_code / 100); |
421 DCHECK_NE(1, response_code / 100); | 428 DCHECK_NE(1, response_code / 100); |
422 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED; | 429 reason = DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED; |
423 break; | 430 break; |
424 } | 431 } |
425 } | 432 } |
426 | 433 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // tab_info_ must be destroyed on UI thread, since | 535 // tab_info_ must be destroyed on UI thread, since |
529 // InitializeDownloadTabInfoOnUIThread might still be using it. | 536 // InitializeDownloadTabInfoOnUIThread might still be using it. |
530 if (tab_info_) | 537 if (tab_info_) |
531 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, tab_info_); | 538 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, tab_info_); |
532 | 539 |
533 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 540 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", |
534 base::TimeTicks::Now() - download_start_time_); | 541 base::TimeTicks::Now() - download_start_time_); |
535 } | 542 } |
536 | 543 |
537 } // namespace content | 544 } // namespace content |
OLD | NEW |