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

Unified Diff: content/browser/download/download_item_impl.cc

Issue 16994004: Remove DownloadItem::Is*() in favor of DI::GetState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@di-getstate-2
Patch Set: Rebased to fix new test, applied suggestions from bauerb and benjhayden Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index 8d4014461f5155b0536251cf036697634510dd83..9b6b51637677c663957783b67abac46f46355138 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -476,7 +476,7 @@ bool DownloadItemImpl::IsTemporary() const {
}
bool DownloadItemImpl::CanResume() const {
- if (IsInProgress() && IsPaused())
+ if ((GetState() == IN_PROGRESS) && IsPaused())
return true;
if (state_ != INTERRUPTED_INTERNAL)
@@ -516,22 +516,6 @@ bool DownloadItemImpl::IsDone() const {
return true;
}
-bool DownloadItemImpl::IsInProgress() const {
- return InternalToExternalState(state_) == IN_PROGRESS;
-}
-
-bool DownloadItemImpl::IsCancelled() const {
- return InternalToExternalState(state_) == CANCELLED;
-}
-
-bool DownloadItemImpl::IsInterrupted() const {
- return InternalToExternalState(state_) == INTERRUPTED;
-}
-
-bool DownloadItemImpl::IsComplete() const {
- return InternalToExternalState(state_) == COMPLETE;
-}
-
const GURL& DownloadItemImpl::GetURL() const {
return url_chain_.empty() ? GURL::EmptyGURL() : url_chain_.back();
}
@@ -703,7 +687,8 @@ bool DownloadItemImpl::CanOpenDownload() {
// We can open the file or mark it for opening on completion if the download
// is expected to complete successfully. Exclude temporary downloads, since
// they aren't owned by the download system.
- return (!IsDone() || IsComplete()) && !IsTemporary() &&
+ const bool is_complete = GetState() == DownloadItem::COMPLETE;
+ return (!IsDone() || is_complete) && !IsTemporary() &&
!file_externally_removed_;
}
@@ -944,7 +929,7 @@ void DownloadItemImpl::DestinationUpdate(int64 bytes_so_far,
VLOG(20) << __FUNCTION__ << " so_far=" << bytes_so_far
<< " per_sec=" << bytes_per_sec << " download=" << DebugString(true);
- if (!IsInProgress()) {
+ if (GetState() != IN_PROGRESS) {
// Ignore if we're no longer in-progress. This can happen if we race a
// Cancel on the UI thread with an update on the FILE thread.
//
@@ -986,7 +971,7 @@ void DownloadItemImpl::DestinationError(DownloadInterruptReason reason) {
void DownloadItemImpl::DestinationCompleted(const std::string& final_hash) {
VLOG(20) << __FUNCTION__ << " download=" << DebugString(true);
- if (!IsInProgress())
+ if (GetState() != IN_PROGRESS)
return;
OnAllDataSaved(final_hash);
MaybeCompleteDownload();
@@ -1041,7 +1026,7 @@ void DownloadItemImpl::Start(
download_file_ = file.Pass();
request_handle_ = req_handle.Pass();
- if (IsCancelled()) {
+ if (GetState() == CANCELLED) {
// The download was in the process of resuming when it was cancelled. Don't
// proceed.
ReleaseDownloadFile(true);
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698