| Index: content/browser/download/download_item_impl.cc
|
| diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item_impl.cc
|
| similarity index 72%
|
| copy from content/browser/download/download_item.cc
|
| copy to content/browser/download/download_item_impl.cc
|
| index 3318a0769a6f2459d9971b7e6377d0a55e04db13..0a76e98db11d58d0c47ac5b96ad8f7b8342da56c 100644
|
| --- a/content/browser/download/download_item.cc
|
| +++ b/content/browser/download/download_item_impl.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/browser/download/download_item.h"
|
| +#include "content/browser/download/download_item_impl.h"
|
|
|
| #include <vector>
|
|
|
| @@ -116,21 +116,16 @@ class NullDownloadRequestHandle : public DownloadRequestHandleInterface {
|
| }
|
| };
|
|
|
| -
|
| } // namespace
|
|
|
| // Our download table ID starts at 1, so we use 0 to represent a download that
|
| // has started, but has not yet had its data persisted in the table. We use fake
|
| // database handles in incognito mode starting at -1 and progressively getting
|
| // more negative.
|
| -// static
|
| -const int DownloadItem::kUninitializedHandle = 0;
|
| -
|
| -const char DownloadItem::kEmptyFileHash[] = "";
|
|
|
| // Constructor for reading from the history service.
|
| -DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| - const DownloadPersistentStoreInfo& info)
|
| +DownloadItemImpl::DownloadItemImpl(DownloadManager* download_manager,
|
| + const DownloadPersistentStoreInfo& info)
|
| : download_id_(download_manager->GetNextId()),
|
| full_path_(info.path),
|
| url_chain_(1, info.url),
|
| @@ -162,10 +157,11 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| }
|
|
|
| // Constructing for a regular download:
|
| -DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| - const DownloadCreateInfo& info,
|
| - DownloadRequestHandleInterface* request_handle,
|
| - bool is_otr)
|
| +DownloadItemImpl::DownloadItemImpl(
|
| + DownloadManager* download_manager,
|
| + const DownloadCreateInfo& info,
|
| + DownloadRequestHandleInterface* request_handle,
|
| + bool is_otr)
|
| : state_info_(info.original_name, info.save_info.file_path,
|
| info.has_user_gesture, info.transition_type,
|
| info.prompt_user_for_save_location, info.path_uniquifier,
|
| @@ -203,11 +199,11 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| }
|
|
|
| // Constructing for the "Save Page As..." feature:
|
| -DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| - const FilePath& path,
|
| - const GURL& url,
|
| - bool is_otr,
|
| - DownloadId download_id)
|
| +DownloadItemImpl::DownloadItemImpl(DownloadManager* download_manager,
|
| + const FilePath& path,
|
| + const GURL& url,
|
| + bool is_otr,
|
| + DownloadId download_id)
|
| : request_handle_(new NullDownloadRequestHandle()),
|
| download_id_(download_id),
|
| full_path_(path),
|
| @@ -235,7 +231,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| Init(true /* actively downloading */);
|
| }
|
|
|
| -DownloadItem::~DownloadItem() {
|
| +DownloadItemImpl::~DownloadItemImpl() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -243,41 +239,41 @@ DownloadItem::~DownloadItem() {
|
| download_manager_->AssertQueueStateConsistent(this);
|
| }
|
|
|
| -void DownloadItem::AddObserver(Observer* observer) {
|
| +void DownloadItemImpl::AddObserver(Observer* observer) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| observers_.AddObserver(observer);
|
| }
|
|
|
| -void DownloadItem::RemoveObserver(Observer* observer) {
|
| +void DownloadItemImpl::RemoveObserver(Observer* observer) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| observers_.RemoveObserver(observer);
|
| }
|
|
|
| -void DownloadItem::UpdateObservers() {
|
| +void DownloadItemImpl::UpdateObservers() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this));
|
| }
|
|
|
| -bool DownloadItem::CanShowInFolder() {
|
| +bool DownloadItemImpl::CanShowInFolder() {
|
| return !IsCancelled() && !file_externally_removed_;
|
| }
|
|
|
| -bool DownloadItem::CanOpenDownload() {
|
| +bool DownloadItemImpl::CanOpenDownload() {
|
| return !file_externally_removed_;
|
| }
|
|
|
| -bool DownloadItem::ShouldOpenFileBasedOnExtension() {
|
| +bool DownloadItemImpl::ShouldOpenFileBasedOnExtension() {
|
| return download_manager_->delegate()->ShouldOpenFileBasedOnExtension(
|
| GetUserVerifiedFilePath());
|
| }
|
|
|
| -void DownloadItem::OpenDownload() {
|
| +void DownloadItemImpl::OpenDownload() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -294,7 +290,7 @@ void DownloadItem::OpenDownload() {
|
| // program that opens the file. So instead we spawn a check to update
|
| // the UI if the file has been deleted in parallel with the open.
|
| download_manager_->CheckForFileRemoval(this);
|
| - download_stats::RecordOpen(end_time(), !opened());
|
| + download_stats::RecordOpen(GetEndTime(), !GetOpened());
|
| opened_ = true;
|
| FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this));
|
| download_manager_->MarkDownloadOpened(this);
|
| @@ -304,19 +300,19 @@ void DownloadItem::OpenDownload() {
|
| if (!open_enabled_)
|
| return;
|
|
|
| - content::GetContentClient()->browser()->OpenItem(full_path());
|
| + content::GetContentClient()->browser()->OpenItem(GetFullPath());
|
| }
|
|
|
| -void DownloadItem::ShowDownloadInShell() {
|
| +void DownloadItemImpl::ShowDownloadInShell() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| - content::GetContentClient()->browser()->ShowItemInFolder(full_path());
|
| + content::GetContentClient()->browser()->ShowItemInFolder(GetFullPath());
|
| }
|
|
|
| -void DownloadItem::DangerousDownloadValidated() {
|
| +void DownloadItemImpl::DangerousDownloadValidated() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - DCHECK_EQ(DANGEROUS, safety_state());
|
| + DCHECK_EQ(DANGEROUS, GetSafetyState());
|
|
|
| UMA_HISTOGRAM_ENUMERATION("Download.DangerousDownloadValidated",
|
| GetDangerType(),
|
| @@ -328,7 +324,7 @@ void DownloadItem::DangerousDownloadValidated() {
|
| download_manager_->MaybeCompleteDownload(this);
|
| }
|
|
|
| -void DownloadItem::UpdateSize(int64 bytes_so_far) {
|
| +void DownloadItemImpl::UpdateSize(int64 bytes_so_far) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -343,7 +339,7 @@ void DownloadItem::UpdateSize(int64 bytes_so_far) {
|
| // Updates from the download thread may have been posted while this download
|
| // was being cancelled in the UI thread, so we'll accept them unless we're
|
| // complete.
|
| -void DownloadItem::Update(int64 bytes_so_far) {
|
| +void DownloadItemImpl::Update(int64 bytes_so_far) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -356,7 +352,7 @@ void DownloadItem::Update(int64 bytes_so_far) {
|
| }
|
|
|
| // Triggered by a user action.
|
| -void DownloadItem::Cancel(bool user_cancel) {
|
| +void DownloadItemImpl::Cancel(bool user_cancel) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -378,7 +374,7 @@ void DownloadItem::Cancel(bool user_cancel) {
|
| download_manager_->DownloadCancelledInternal(this);
|
| }
|
|
|
| -void DownloadItem::MarkAsComplete() {
|
| +void DownloadItemImpl::MarkAsComplete() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -387,12 +383,13 @@ void DownloadItem::MarkAsComplete() {
|
| TransitionTo(COMPLETE);
|
| }
|
|
|
| -void DownloadItem::DelayedDownloadOpened() {
|
| +void DownloadItemImpl::DelayedDownloadOpened() {
|
| auto_opened_ = true;
|
| Completed();
|
| }
|
|
|
| -void DownloadItem::OnAllDataSaved(int64 size, const std::string& final_hash) {
|
| +void DownloadItemImpl::OnAllDataSaved(
|
| + int64 size, const std::string& final_hash) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -402,12 +399,12 @@ void DownloadItem::OnAllDataSaved(int64 size, const std::string& final_hash) {
|
| hash_ = final_hash;
|
| }
|
|
|
| -void DownloadItem::OnDownloadedFileRemoved() {
|
| +void DownloadItemImpl::OnDownloadedFileRemoved() {
|
| file_externally_removed_ = true;
|
| UpdateObservers();
|
| }
|
|
|
| -void DownloadItem::Completed() {
|
| +void DownloadItemImpl::Completed() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -416,18 +413,18 @@ void DownloadItem::Completed() {
|
| DCHECK(all_data_saved_);
|
| end_time_ = base::Time::Now();
|
| TransitionTo(COMPLETE);
|
| - download_manager_->DownloadCompleted(id());
|
| + download_manager_->DownloadCompleted(GetId());
|
| download_stats::RecordDownloadCompleted(start_tick_, received_bytes_);
|
|
|
| if (auto_opened_) {
|
| // If it was already handled by the delegate, do nothing.
|
| - } else if (open_when_complete() ||
|
| + } else if (GetOpenWhenComplete() ||
|
| ShouldOpenFileBasedOnExtension() ||
|
| - is_temporary()) {
|
| + IsTemporary()) {
|
| // If the download is temporary, like in drag-and-drop, do not open it but
|
| // we still need to set it auto-opened so that it can be removed from the
|
| // download shelf.
|
| - if (!is_temporary())
|
| + if (!IsTemporary())
|
| OpenDownload();
|
|
|
| auto_opened_ = true;
|
| @@ -435,7 +432,7 @@ void DownloadItem::Completed() {
|
| }
|
| }
|
|
|
| -void DownloadItem::TransitionTo(DownloadState new_state) {
|
| +void DownloadItemImpl::TransitionTo(DownloadState new_state) {
|
| if (state_ == new_state)
|
| return;
|
|
|
| @@ -443,16 +440,16 @@ void DownloadItem::TransitionTo(DownloadState new_state) {
|
| UpdateObservers();
|
| }
|
|
|
| -void DownloadItem::UpdateSafetyState() {
|
| +void DownloadItemImpl::UpdateSafetyState() {
|
| SafetyState updated_value = state_info_.IsDangerous() ?
|
| - DownloadItem::DANGEROUS : DownloadItem::SAFE;
|
| + DownloadItem::DANGEROUS : DownloadItem::SAFE;
|
| if (updated_value != safety_state_) {
|
| safety_state_ = updated_value;
|
| UpdateObservers();
|
| }
|
| }
|
|
|
| -void DownloadItem::UpdateTarget() {
|
| +void DownloadItemImpl::UpdateTarget() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -460,7 +457,7 @@ void DownloadItem::UpdateTarget() {
|
| state_info_.target_name = full_path_.BaseName();
|
| }
|
|
|
| -void DownloadItem::Interrupted(int64 size, InterruptReason reason) {
|
| +void DownloadItemImpl::Interrupted(int64 size, InterruptReason reason) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -475,7 +472,7 @@ void DownloadItem::Interrupted(int64 size, InterruptReason reason) {
|
| TransitionTo(INTERRUPTED);
|
| }
|
|
|
| -void DownloadItem::Delete(DeleteReason reason) {
|
| +void DownloadItemImpl::Delete(DeleteReason reason) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -498,7 +495,7 @@ void DownloadItem::Delete(DeleteReason reason) {
|
| // We have now been deleted.
|
| }
|
|
|
| -void DownloadItem::Remove() {
|
| +void DownloadItemImpl::Remove() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -511,7 +508,7 @@ void DownloadItem::Remove() {
|
| // We have now been deleted.
|
| }
|
|
|
| -bool DownloadItem::TimeRemaining(base::TimeDelta* remaining) const {
|
| +bool DownloadItemImpl::TimeRemaining(base::TimeDelta* remaining) const {
|
| if (total_bytes_ <= 0)
|
| return false; // We never received the content_length for this download.
|
|
|
| @@ -524,7 +521,7 @@ bool DownloadItem::TimeRemaining(base::TimeDelta* remaining) const {
|
| return true;
|
| }
|
|
|
| -int64 DownloadItem::CurrentSpeed() const {
|
| +int64 DownloadItemImpl::CurrentSpeed() const {
|
| if (is_paused_)
|
| return 0;
|
| base::TimeDelta diff = base::TimeTicks::Now() - start_tick_;
|
| @@ -532,7 +529,7 @@ int64 DownloadItem::CurrentSpeed() const {
|
| return diff_ms == 0 ? 0 : received_bytes_ * 1000 / diff_ms;
|
| }
|
|
|
| -int DownloadItem::PercentComplete() const {
|
| +int DownloadItemImpl::PercentComplete() const {
|
| // If the delegate is delaying completion of the download, then we have no
|
| // idea how long it will take.
|
| if (delegate_delayed_complete_ || total_bytes_ <= 0)
|
| @@ -541,12 +538,12 @@ int DownloadItem::PercentComplete() const {
|
| return static_cast<int>(received_bytes_ * 100.0 / total_bytes_);
|
| }
|
|
|
| -void DownloadItem::OnPathDetermined(const FilePath& path) {
|
| +void DownloadItemImpl::OnPathDetermined(const FilePath& path) {
|
| full_path_ = path;
|
| UpdateTarget();
|
| }
|
|
|
| -void DownloadItem::Rename(const FilePath& full_path) {
|
| +void DownloadItemImpl::Rename(const FilePath& full_path) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -557,7 +554,7 @@ void DownloadItem::Rename(const FilePath& full_path) {
|
| full_path_ = full_path;
|
| }
|
|
|
| -void DownloadItem::TogglePause() {
|
| +void DownloadItemImpl::TogglePause() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -570,21 +567,21 @@ void DownloadItem::TogglePause() {
|
| UpdateObservers();
|
| }
|
|
|
| -void DownloadItem::OnDownloadCompleting(DownloadFileManager* file_manager) {
|
| +void DownloadItemImpl::OnDownloadCompleting(DownloadFileManager* file_manager) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| VLOG(20) << __FUNCTION__ << "()"
|
| << " needs rename = " << NeedsRename()
|
| << " " << DebugString(true);
|
| - DCHECK_NE(DANGEROUS, safety_state());
|
| + DCHECK_NE(DANGEROUS, GetSafetyState());
|
| DCHECK(file_manager);
|
|
|
| if (NeedsRename()) {
|
| BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&DownloadFileManager::RenameCompletingDownloadFile,
|
| - file_manager, global_id(),
|
| - GetTargetFilePath(), safety_state() == SAFE));
|
| + file_manager, GetGlobalId(),
|
| + GetTargetFilePath(), GetSafetyState() == SAFE));
|
| return;
|
| }
|
|
|
| @@ -592,10 +589,10 @@ void DownloadItem::OnDownloadCompleting(DownloadFileManager* file_manager) {
|
|
|
| BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&DownloadFileManager::CompleteDownload,
|
| - file_manager, global_id()));
|
| + file_manager, GetGlobalId()));
|
| }
|
|
|
| -void DownloadItem::OnDownloadRenamedToFinalName(const FilePath& full_path) {
|
| +void DownloadItemImpl::OnDownloadRenamedToFinalName(const FilePath& full_path) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -614,7 +611,7 @@ void DownloadItem::OnDownloadRenamedToFinalName(const FilePath& full_path) {
|
| }
|
| }
|
|
|
| -bool DownloadItem::MatchesQuery(const string16& query) const {
|
| +bool DownloadItemImpl::MatchesQuery(const string16& query) const {
|
| if (query.empty())
|
| return true;
|
|
|
| @@ -639,11 +636,11 @@ bool DownloadItem::MatchesQuery(const string16& query) const {
|
| if (base::i18n::StringSearchIgnoringCaseAndAccents(query, url_formatted))
|
| return true;
|
|
|
| - string16 path(full_path().LossyDisplayName());
|
| + string16 path(GetFullPath().LossyDisplayName());
|
| return base::i18n::StringSearchIgnoringCaseAndAccents(query, path);
|
| }
|
|
|
| -void DownloadItem::SetFileCheckResults(const DownloadStateInfo& state) {
|
| +void DownloadItemImpl::SetFileCheckResults(const DownloadStateInfo& state) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -654,49 +651,49 @@ void DownloadItem::SetFileCheckResults(const DownloadStateInfo& state) {
|
| UpdateSafetyState();
|
| }
|
|
|
| -DownloadStateInfo::DangerType DownloadItem::GetDangerType() const {
|
| +DownloadStateInfo::DangerType DownloadItemImpl::GetDangerType() const {
|
| return state_info_.danger;
|
| }
|
|
|
| -bool DownloadItem::IsDangerous() const {
|
| +bool DownloadItemImpl::IsDangerous() const {
|
| return state_info_.IsDangerous();
|
| }
|
|
|
| -void DownloadItem::MarkFileDangerous() {
|
| +void DownloadItemImpl::MarkFileDangerous() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| state_info_.danger = DownloadStateInfo::DANGEROUS_FILE;
|
| UpdateSafetyState();
|
| }
|
|
|
| -void DownloadItem::MarkUrlDangerous() {
|
| +void DownloadItemImpl::MarkUrlDangerous() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| state_info_.danger = DownloadStateInfo::DANGEROUS_URL;
|
| UpdateSafetyState();
|
| }
|
|
|
| -void DownloadItem::MarkContentDangerous() {
|
| +void DownloadItemImpl::MarkContentDangerous() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| state_info_.danger = DownloadStateInfo::DANGEROUS_CONTENT;
|
| UpdateSafetyState();
|
| }
|
|
|
| -DownloadPersistentStoreInfo DownloadItem::GetPersistentStoreInfo() const {
|
| - return DownloadPersistentStoreInfo(full_path(),
|
| +DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
|
| + return DownloadPersistentStoreInfo(GetFullPath(),
|
| GetURL(),
|
| - referrer_url(),
|
| - start_time(),
|
| - end_time(),
|
| - received_bytes(),
|
| - total_bytes(),
|
| - state(),
|
| - db_handle(),
|
| - opened());
|
| + GetReferrerUrl(),
|
| + GetStartTime(),
|
| + GetEndTime(),
|
| + GetReceivedBytes(),
|
| + GetTotalBytes(),
|
| + GetState(),
|
| + GetDbHandle(),
|
| + GetOpened());
|
| }
|
|
|
| -TabContents* DownloadItem::GetTabContents() const {
|
| +TabContents* DownloadItemImpl::GetTabContents() const {
|
| // TODO(rdsmith): Remove null check after removing GetTabContents() from
|
| // paths that might be used by DownloadItems created from history import.
|
| // Currently such items have null request_handle_s, where other items
|
| @@ -706,11 +703,11 @@ TabContents* DownloadItem::GetTabContents() const {
|
| return NULL;
|
| }
|
|
|
| -FilePath DownloadItem::GetTargetFilePath() const {
|
| +FilePath DownloadItemImpl::GetTargetFilePath() const {
|
| return full_path_.DirName().Append(state_info_.target_name);
|
| }
|
|
|
| -FilePath DownloadItem::GetFileNameToReportUser() const {
|
| +FilePath DownloadItemImpl::GetFileNameToReportUser() const {
|
| if (state_info_.path_uniquifier > 0) {
|
| FilePath name(state_info_.target_name);
|
| DownloadFile::AppendNumberToPath(&name, state_info_.path_uniquifier);
|
| @@ -719,21 +716,21 @@ FilePath DownloadItem::GetFileNameToReportUser() const {
|
| return state_info_.target_name;
|
| }
|
|
|
| -FilePath DownloadItem::GetUserVerifiedFilePath() const {
|
| +FilePath DownloadItemImpl::GetUserVerifiedFilePath() const {
|
| return (safety_state_ == DownloadItem::SAFE) ?
|
| GetTargetFilePath() : full_path_;
|
| }
|
|
|
| -void DownloadItem::OffThreadCancel(DownloadFileManager* file_manager) {
|
| +void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| request_handle_->CancelRequest();
|
|
|
| BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&DownloadFileManager::CancelDownload,
|
| - file_manager, global_id()));
|
| + file_manager, GetGlobalId()));
|
| }
|
|
|
| -void DownloadItem::Init(bool active) {
|
| +void DownloadItemImpl::Init(bool active) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -746,38 +743,38 @@ void DownloadItem::Init(bool active) {
|
|
|
| // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to
|
| // |IsPartialDownload()|, when resuming interrupted downloads is implemented.
|
| -bool DownloadItem::IsPartialDownload() const {
|
| +bool DownloadItemImpl::IsPartialDownload() const {
|
| return (state_ == IN_PROGRESS);
|
| }
|
|
|
| -bool DownloadItem::IsInProgress() const {
|
| +bool DownloadItemImpl::IsInProgress() const {
|
| return (state_ == IN_PROGRESS);
|
| }
|
|
|
| -bool DownloadItem::IsCancelled() const {
|
| +bool DownloadItemImpl::IsCancelled() const {
|
| return (state_ == CANCELLED) ||
|
| (state_ == INTERRUPTED);
|
| }
|
|
|
| -bool DownloadItem::IsInterrupted() const {
|
| +bool DownloadItemImpl::IsInterrupted() const {
|
| return (state_ == INTERRUPTED);
|
| }
|
|
|
| -bool DownloadItem::IsComplete() const {
|
| +bool DownloadItemImpl::IsComplete() const {
|
| return (state_ == COMPLETE);
|
| }
|
|
|
| -const GURL& DownloadItem::GetURL() const {
|
| +const GURL& DownloadItemImpl::GetURL() const {
|
| return url_chain_.empty() ?
|
| GURL::EmptyGURL() : url_chain_.back();
|
| }
|
|
|
| -std::string DownloadItem::DebugString(bool verbose) const {
|
| +std::string DownloadItemImpl::DebugString(bool verbose) const {
|
| std::string description =
|
| base::StringPrintf("{ id = %d"
|
| " state = %s",
|
| download_id_.local(),
|
| - DebugDownloadStateString(state()));
|
| + DebugDownloadStateString(GetState()));
|
|
|
| // Construct a string of the URL chain.
|
| std::string url_list("<none>");
|
| @@ -804,15 +801,15 @@ std::string DownloadItem::DebugString(bool verbose) const {
|
| " url_chain = \n\t\"%s\"\n\t"
|
| " target_name = \"%" PRFilePath "\""
|
| " full_path = \"%" PRFilePath "\"",
|
| - db_handle(),
|
| - total_bytes(),
|
| - received_bytes(),
|
| - is_paused() ? 'T' : 'F',
|
| - is_otr() ? 'T' : 'F',
|
| - DebugSafetyStateString(safety_state()),
|
| + GetDbHandle(),
|
| + GetTotalBytes(),
|
| + GetReceivedBytes(),
|
| + IsPaused() ? 'T' : 'F',
|
| + IsOtr() ? 'T' : 'F',
|
| + DebugSafetyStateString(GetSafetyState()),
|
| url_list.c_str(),
|
| state_info_.target_name.value().c_str(),
|
| - full_path().value().c_str());
|
| + GetFullPath().value().c_str());
|
| } else {
|
| description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
|
| }
|
| @@ -821,3 +818,82 @@ std::string DownloadItem::DebugString(bool verbose) const {
|
|
|
| return description;
|
| }
|
| +
|
| +bool DownloadItemImpl::AllDataSaved() const { return all_data_saved_; }
|
| +DownloadItem::DownloadState DownloadItemImpl::GetState() const {
|
| + return state_;
|
| +}
|
| +const FilePath& DownloadItemImpl::GetFullPath() const { return full_path_; }
|
| +void DownloadItemImpl::SetPathUniquifier(int uniquifier) {
|
| + state_info_.path_uniquifier = uniquifier;
|
| +}
|
| +const std::vector<GURL>& DownloadItemImpl::GetUrlChain() const {
|
| + return url_chain_;
|
| +}
|
| +const GURL& DownloadItemImpl::GetOriginalUrl() const {
|
| + return url_chain_.front();
|
| +}
|
| +const GURL& DownloadItemImpl::GetReferrerUrl() const { return referrer_url_; }
|
| +std::string DownloadItemImpl::GetSuggestedFilename() const {
|
| + return suggested_filename_;
|
| +}
|
| +std::string DownloadItemImpl::GetContentDisposition() const {
|
| + return content_disposition_;
|
| +}
|
| +std::string DownloadItemImpl::GetMimeType() const { return mime_type_; }
|
| +std::string DownloadItemImpl::GetOriginalMimeType() const {
|
| + return original_mime_type_;
|
| +}
|
| +std::string DownloadItemImpl::GetReferrerCharset() const {
|
| + return referrer_charset_;
|
| +}
|
| +int64 DownloadItemImpl::GetTotalBytes() const { return total_bytes_; }
|
| +void DownloadItemImpl::SetTotalBytes(int64 total_bytes) {
|
| + total_bytes_ = total_bytes;
|
| +}
|
| +const std::string& DownloadItemImpl::GetHash() const { return hash_; }
|
| +int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; }
|
| +int32 DownloadItemImpl::GetId() const { return download_id_.local(); }
|
| +DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; }
|
| +base::Time DownloadItemImpl::GetStartTime() const { return start_time_; }
|
| +base::Time DownloadItemImpl::GetEndTime() const { return end_time_; }
|
| +void DownloadItemImpl::SetDbHandle(int64 handle) { db_handle_ = handle; }
|
| +int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; }
|
| +DownloadManager* DownloadItemImpl::GetDownloadManager() {
|
| + return download_manager_;
|
| +}
|
| +bool DownloadItemImpl::IsPaused() const { return is_paused_; }
|
| +bool DownloadItemImpl::GetOpenWhenComplete() const {
|
| + return open_when_complete_;
|
| +}
|
| +void DownloadItemImpl::SetOpenWhenComplete(bool open) {
|
| + open_when_complete_ = open;
|
| +}
|
| +bool DownloadItemImpl::GetFileExternallyRemoved() const {
|
| + return file_externally_removed_;
|
| +}
|
| +DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const {
|
| + return safety_state_;
|
| +}
|
| +bool DownloadItemImpl::IsOtr() const { return is_otr_; }
|
| +bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; }
|
| +const FilePath& DownloadItemImpl::GetTargetName() const {
|
| + return state_info_.target_name;
|
| +}
|
| +bool DownloadItemImpl::PromptUserForSaveLocation() const {
|
| + return state_info_.prompt_user_for_save_location;
|
| +}
|
| +const FilePath& DownloadItemImpl::GetSuggestedPath() const {
|
| + return state_info_.suggested_path;
|
| +}
|
| +bool DownloadItemImpl::IsTemporary() const { return is_temporary_; }
|
| +void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; }
|
| +bool DownloadItemImpl::GetOpened() const { return opened_; }
|
| +InterruptReason DownloadItemImpl::GetLastReason() const {
|
| + return last_reason_;
|
| +}
|
| +DownloadStateInfo DownloadItemImpl::GetStateInfo() const { return state_info_; }
|
| +bool DownloadItemImpl::NeedsRename() const {
|
| + return state_info_.target_name != full_path_.BaseName();
|
| +}
|
| +void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; }
|
|
|