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 // File method ordering: Methods in this file are in the same order as | 5 // File method ordering: Methods in this file are in the same order as |
6 // in download_item_impl.h, with the following exception: The public | 6 // in download_item_impl.h, with the following exception: The public |
7 // interface Start is placed in chronological order with the other | 7 // interface Start is placed in chronological order with the other |
8 // (private) routines that together define a DownloadItem's state | 8 // (private) routines that together define a DownloadItem's state |
9 // transitions as the download progresses. See "Download progression | 9 // transitions as the download progresses. See "Download progression |
10 // cascade" later in this file. | 10 // cascade" later in this file. |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 " danger = %d" | 800 " danger = %d" |
801 " all_data_saved = %c" | 801 " all_data_saved = %c" |
802 " last_modified = '%s'" | 802 " last_modified = '%s'" |
803 " etag = '%s'" | 803 " etag = '%s'" |
804 " has_download_file = %s" | 804 " has_download_file = %s" |
805 " url_chain = \n\t\"%s\"\n\t" | 805 " url_chain = \n\t\"%s\"\n\t" |
806 " full_path = \"%" PRFilePath "\"\n\t" | 806 " full_path = \"%" PRFilePath "\"\n\t" |
807 " target_path = \"%" PRFilePath "\"", | 807 " target_path = \"%" PRFilePath "\"", |
808 GetTotalBytes(), | 808 GetTotalBytes(), |
809 GetReceivedBytes(), | 809 GetReceivedBytes(), |
810 InterruptReasonDebugString(last_reason_).c_str(), | 810 DownloadInterruptReasonToString(last_reason_).c_str(), |
811 IsPaused() ? 'T' : 'F', | 811 IsPaused() ? 'T' : 'F', |
812 DebugResumeModeString(GetResumeMode()), | 812 DebugResumeModeString(GetResumeMode()), |
813 auto_resume_count_, | 813 auto_resume_count_, |
814 GetDangerType(), | 814 GetDangerType(), |
815 AllDataSaved() ? 'T' : 'F', | 815 AllDataSaved() ? 'T' : 'F', |
816 GetLastModifiedTime().c_str(), | 816 GetLastModifiedTime().c_str(), |
817 GetETag().c_str(), | 817 GetETag().c_str(), |
818 download_file_.get() ? "true" : "false", | 818 download_file_.get() ? "true" : "false", |
819 url_list.c_str(), | 819 url_list.c_str(), |
820 GetFullPath().value().c_str(), | 820 GetFullPath().value().c_str(), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 case DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT: | 861 case DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT: |
862 if (force_user) | 862 if (force_user) |
863 mode = RESUME_MODE_USER_RESTART; | 863 mode = RESUME_MODE_USER_RESTART; |
864 else | 864 else |
865 mode = RESUME_MODE_IMMEDIATE_RESTART; | 865 mode = RESUME_MODE_IMMEDIATE_RESTART; |
866 break; | 866 break; |
867 | 867 |
868 case DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED: | 868 case DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED: |
869 case DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED: | 869 case DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED: |
870 case DOWNLOAD_INTERRUPT_REASON_NETWORK_SERVER_DOWN: | 870 case DOWNLOAD_INTERRUPT_REASON_NETWORK_SERVER_DOWN: |
| 871 case DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST: |
871 case DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED: | 872 case DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED: |
872 case DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN: | 873 case DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN: |
873 case DOWNLOAD_INTERRUPT_REASON_CRASH: | 874 case DOWNLOAD_INTERRUPT_REASON_CRASH: |
874 if (force_restart) | 875 if (force_restart) |
875 mode = RESUME_MODE_USER_RESTART; | 876 mode = RESUME_MODE_USER_RESTART; |
876 else | 877 else |
877 mode = RESUME_MODE_USER_CONTINUE; | 878 mode = RESUME_MODE_USER_CONTINUE; |
878 break; | 879 break; |
879 | 880 |
880 case DOWNLOAD_INTERRUPT_REASON_FILE_FAILED: | 881 case DOWNLOAD_INTERRUPT_REASON_FILE_FAILED: |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 // we still need to set it auto-opened so that it can be removed from the | 1376 // we still need to set it auto-opened so that it can be removed from the |
1376 // download shelf. | 1377 // download shelf. |
1377 if (!IsTemporary()) | 1378 if (!IsTemporary()) |
1378 OpenDownload(); | 1379 OpenDownload(); |
1379 | 1380 |
1380 auto_opened_ = true; | 1381 auto_opened_ = true; |
1381 UpdateObservers(); | 1382 UpdateObservers(); |
1382 } | 1383 } |
1383 } | 1384 } |
1384 | 1385 |
1385 void DownloadItemImpl::OnResumeRequestStarted(DownloadItem* item, | 1386 void DownloadItemImpl::OnResumeRequestStarted( |
1386 net::Error error) { | 1387 DownloadItem* item, |
| 1388 DownloadInterruptReason interrupt_reason) { |
1387 // If |item| is not NULL, then Start() has been called already, and nothing | 1389 // If |item| is not NULL, then Start() has been called already, and nothing |
1388 // more needs to be done here. | 1390 // more needs to be done here. |
1389 if (item) { | 1391 if (item) { |
1390 DCHECK_EQ(net::OK, error); | 1392 DCHECK_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); |
1391 DCHECK_EQ(static_cast<DownloadItem*>(this), item); | 1393 DCHECK_EQ(static_cast<DownloadItem*>(this), item); |
1392 return; | 1394 return; |
1393 } | 1395 } |
1394 // Otherwise, the request failed without passing through | 1396 // Otherwise, the request failed without passing through |
1395 // DownloadResourceHandler::OnResponseStarted. | 1397 // DownloadResourceHandler::OnResponseStarted. |
1396 if (error == net::OK) | 1398 DCHECK_NE(DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); |
1397 error = net::ERR_FAILED; | 1399 Interrupt(interrupt_reason); |
1398 DownloadInterruptReason reason = | |
1399 ConvertNetErrorToInterruptReason(error, DOWNLOAD_INTERRUPT_FROM_NETWORK); | |
1400 DCHECK_NE(DOWNLOAD_INTERRUPT_REASON_NONE, reason); | |
1401 Interrupt(reason); | |
1402 } | 1400 } |
1403 | 1401 |
1404 // **** End of Download progression cascade | 1402 // **** End of Download progression cascade |
1405 | 1403 |
1406 // An error occurred somewhere. | 1404 // An error occurred somewhere. |
1407 void DownloadItemImpl::Interrupt(DownloadInterruptReason reason) { | 1405 void DownloadItemImpl::Interrupt(DownloadInterruptReason reason) { |
1408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1409 | 1407 |
1410 // Somewhat counter-intuitively, it is possible for us to receive an | 1408 // Somewhat counter-intuitively, it is possible for us to receive an |
1411 // interrupt after we've already been interrupted. The generation of | 1409 // interrupt after we've already been interrupted. The generation of |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 case RESUME_MODE_USER_CONTINUE: | 1750 case RESUME_MODE_USER_CONTINUE: |
1753 return "USER_CONTINUE"; | 1751 return "USER_CONTINUE"; |
1754 case RESUME_MODE_USER_RESTART: | 1752 case RESUME_MODE_USER_RESTART: |
1755 return "USER_RESTART"; | 1753 return "USER_RESTART"; |
1756 } | 1754 } |
1757 NOTREACHED() << "Unknown resume mode " << mode; | 1755 NOTREACHED() << "Unknown resume mode " << mode; |
1758 return "unknown"; | 1756 return "unknown"; |
1759 } | 1757 } |
1760 | 1758 |
1761 } // namespace content | 1759 } // namespace content |
OLD | NEW |