OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/download/download_item.h" | 5 #include "chrome/browser/download/download_item.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 525 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
526 NewRunnableFunction(&DeleteDownloadedFile, full_path_)); | 526 NewRunnableFunction(&DeleteDownloadedFile, full_path_)); |
527 Remove(); | 527 Remove(); |
528 // We have now been deleted. | 528 // We have now been deleted. |
529 } | 529 } |
530 | 530 |
531 void DownloadItem::Remove() { | 531 void DownloadItem::Remove() { |
532 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 532 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
533 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 533 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
534 | 534 |
535 download_manager_->AssertQueueStateConsistent(this); | 535 // TODO(haraken): The following AssertQueueStateConsistent() fails |
536 // if this Remove() is called after download_manager_->StartDownload() | |
537 // but before download_manager_->ContinueDownloadWithPath(). | |
538 // In that case, download->state_ is IN_PROGRESS but the download id | |
539 // is not yet registered to download_manager_->in_progress_. | |
540 // This violates 'CHECK(ContainsKey(in_progress_, download->id()) == | |
541 // (download->state() == DownloadItem::IN_PROGRESS));' | |
542 // in AssertQueueStateConsistent(). | |
543 // | |
544 // download_manager_->AssertQueueStateConsistent(this); | |
545 | |
haraken1
2011/06/22 18:01:58
In fact, DownloadManagerTest.StartDownload fails a
Randy Smith (Not in Mondays)
2011/06/23 20:24:42
Based on your description, it sounds as if if we c
haraken1
2011/06/24 01:57:25
I reverted this code back to the original, since I
| |
536 Cancel(true); | 546 Cancel(true); |
537 download_manager_->AssertQueueStateConsistent(this); | 547 |
548 // TODO(haraken): The following AssertQueueStateConsistent() fails | |
549 // if this Remove() is called after download_manager_->StartDownload() | |
550 // but before download_manager_->ContinueDownloadWithPath(). | |
551 // In that case, since the download id is not yet registered to | |
552 // download_manager_->in_progress_, download_manager_->DownloadCancelled() | |
553 // called inside the above Cancel() returns immediately without | |
554 // clearing download_manager_->active_downloads_. Then, this violates | |
555 // 'CHECK(ContainsKey(active_downloads_, download->id()) == | |
556 // (download->state() == DownloadItem::IN_PROGRESS));' | |
557 // in AssertQueueStateConsistent(). | |
558 // | |
559 // download_manager_->AssertQueueStateConsistent(this); | |
538 | 560 |
539 state_ = REMOVING; | 561 state_ = REMOVING; |
540 download_manager_->RemoveDownload(db_handle_); | 562 download_manager_->RemoveDownload(db_handle_); |
541 // We have now been deleted. | 563 // We have now been deleted. |
542 } | 564 } |
543 | 565 |
544 bool DownloadItem::TimeRemaining(base::TimeDelta* remaining) const { | 566 bool DownloadItem::TimeRemaining(base::TimeDelta* remaining) const { |
545 if (total_bytes_ <= 0) | 567 if (total_bytes_ <= 0) |
546 return false; // We never received the content_length for this download. | 568 return false; // We never received the content_length for this download. |
547 | 569 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 state_info_.target_name.value().c_str(), | 856 state_info_.target_name.value().c_str(), |
835 full_path().value().c_str()); | 857 full_path().value().c_str()); |
836 } else { | 858 } else { |
837 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); | 859 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); |
838 } | 860 } |
839 | 861 |
840 description += " }"; | 862 description += " }"; |
841 | 863 |
842 return description; | 864 return description; |
843 } | 865 } |
OLD | NEW |