| 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 88%
|
| copy from content/browser/download/download_item.cc
|
| copy to content/browser/download/download_item_impl.cc
|
| index b993a6db2208649688763c126f80a510ae92d826..5b4e074acf594e86432d3db48cb8f509948959a3 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,11 +116,9 @@ DownloadItem::DangerType GetDangerType(bool dangerous_file,
|
| // 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;
|
|
|
| // Constructor for reading from the history service.
|
| -DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| +DownloadItemImpl::DownloadItemImpl(DownloadManager* download_manager,
|
| const DownloadPersistentStoreInfo& info)
|
| : download_id_(download_manager->GetNextId()),
|
| full_path_(info.path),
|
| @@ -153,7 +151,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| }
|
|
|
| // Constructing for a regular download:
|
| -DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| +DownloadItemImpl::DownloadItemImpl(DownloadManager* download_manager,
|
| const DownloadCreateInfo& info,
|
| DownloadRequestHandleInterface* request_handle,
|
| bool is_otr)
|
| @@ -194,7 +192,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| }
|
|
|
| // Constructing for the "Save Page As..." feature:
|
| -DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| +DownloadItemImpl::DownloadItemImpl(DownloadManager* download_manager,
|
| const FilePath& path,
|
| const GURL& url,
|
| bool is_otr,
|
| @@ -225,7 +223,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));
|
|
|
| @@ -233,41 +231,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));
|
|
|
| @@ -297,14 +295,14 @@ void DownloadItem::OpenDownload() {
|
| content::GetContentClient()->browser()->OpenItem(full_path());
|
| }
|
|
|
| -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());
|
| }
|
|
|
| -void DownloadItem::DangerousDownloadValidated() {
|
| +void DownloadItemImpl::DangerousDownloadValidated() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| DCHECK_EQ(DANGEROUS, safety_state());
|
|
|
| @@ -318,7 +316,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));
|
|
|
| @@ -333,7 +331,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));
|
|
|
| @@ -346,7 +344,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));
|
|
|
| @@ -368,7 +366,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));
|
|
|
| @@ -377,12 +375,12 @@ void DownloadItem::MarkAsComplete() {
|
| TransitionTo(COMPLETE);
|
| }
|
|
|
| -void DownloadItem::DelayedDownloadOpened() {
|
| +void DownloadItemImpl::DelayedDownloadOpened() {
|
| auto_opened_ = true;
|
| Completed();
|
| }
|
|
|
| -void DownloadItem::OnAllDataSaved(int64 size) {
|
| +void DownloadItemImpl::OnAllDataSaved(int64 size) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -391,12 +389,12 @@ void DownloadItem::OnAllDataSaved(int64 size) {
|
| UpdateSize(size);
|
| }
|
|
|
| -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));
|
|
|
| @@ -424,7 +422,7 @@ void DownloadItem::Completed() {
|
| }
|
| }
|
|
|
| -void DownloadItem::TransitionTo(DownloadState new_state) {
|
| +void DownloadItemImpl::TransitionTo(DownloadState new_state) {
|
| if (state_ == new_state)
|
| return;
|
|
|
| @@ -432,7 +430,7 @@ void DownloadItem::TransitionTo(DownloadState new_state) {
|
| UpdateObservers();
|
| }
|
|
|
| -void DownloadItem::UpdateSafetyState() {
|
| +void DownloadItemImpl::UpdateSafetyState() {
|
| SafetyState updated_value(
|
| GetSafetyState(state_info_.is_dangerous_file,
|
| state_info_.is_dangerous_url));
|
| @@ -442,7 +440,7 @@ void DownloadItem::UpdateSafetyState() {
|
| }
|
| }
|
|
|
| -void DownloadItem::UpdateTarget() {
|
| +void DownloadItemImpl::UpdateTarget() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -450,7 +448,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));
|
|
|
| @@ -465,7 +463,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));
|
|
|
| @@ -488,7 +486,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));
|
|
|
| @@ -501,7 +499,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.
|
|
|
| @@ -514,7 +512,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_;
|
| @@ -522,7 +520,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)
|
| @@ -531,12 +529,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));
|
|
|
| @@ -547,7 +545,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));
|
|
|
| @@ -560,7 +558,7 @@ 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));
|
|
|
| @@ -585,7 +583,7 @@ void DownloadItem::OnDownloadCompleting(DownloadFileManager* file_manager) {
|
| file_manager, global_id()));
|
| }
|
|
|
| -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));
|
|
|
| @@ -604,7 +602,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;
|
|
|
| @@ -632,7 +630,7 @@ bool DownloadItem::MatchesQuery(const string16& query) const {
|
| 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));
|
|
|
| @@ -643,16 +641,16 @@ void DownloadItem::SetFileCheckResults(const DownloadStateInfo& state) {
|
| UpdateSafetyState();
|
| }
|
|
|
| -DownloadItem::DangerType DownloadItem::GetDangerType() const {
|
| +DownloadItem::DangerType DownloadItemImpl::GetDangerType() const {
|
| return ::GetDangerType(state_info_.is_dangerous_file,
|
| state_info_.is_dangerous_url);
|
| }
|
|
|
| -bool DownloadItem::IsDangerous() const {
|
| +bool DownloadItemImpl::IsDangerous() const {
|
| return GetDangerType() != DownloadItem::NOT_DANGEROUS;
|
| }
|
|
|
| -void DownloadItem::MarkFileDangerous() {
|
| +void DownloadItemImpl::MarkFileDangerous() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -660,7 +658,7 @@ void DownloadItem::MarkFileDangerous() {
|
| UpdateSafetyState();
|
| }
|
|
|
| -void DownloadItem::MarkUrlDangerous() {
|
| +void DownloadItemImpl::MarkUrlDangerous() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -668,7 +666,7 @@ void DownloadItem::MarkUrlDangerous() {
|
| UpdateSafetyState();
|
| }
|
|
|
| -DownloadPersistentStoreInfo DownloadItem::GetPersistentStoreInfo() const {
|
| +DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
|
| return DownloadPersistentStoreInfo(full_path(),
|
| GetURL(),
|
| referrer_url(),
|
| @@ -681,17 +679,17 @@ DownloadPersistentStoreInfo DownloadItem::GetPersistentStoreInfo() const {
|
| opened());
|
| }
|
|
|
| -TabContents* DownloadItem::GetTabContents() const {
|
| +TabContents* DownloadItemImpl::GetTabContents() const {
|
| if (request_handle_.get())
|
| return request_handle_->GetTabContents();
|
| 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);
|
| @@ -700,12 +698,12 @@ 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();
|
|
|
| @@ -714,7 +712,7 @@ void DownloadItem::OffThreadCancel(DownloadFileManager* file_manager) {
|
| file_manager, global_id()));
|
| }
|
|
|
| -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));
|
|
|
| @@ -727,33 +725,33 @@ 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",
|
|
|