Commit 9a428bc0 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download later: Add a method in DownloadItem to get DownloadSchedule.

Add a method in DownloadItem to get DownloadSchedule, this is needed
to plumb the data to download level db.

Bug: 1078454
Change-Id: Ifce1245a45a393d131901cb15257f74337146afb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2234131Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776630}
parent e81bde93
...@@ -1103,6 +1103,11 @@ DownloadItem::DownloadCreationType DownloadItemImpl::GetDownloadCreationType() ...@@ -1103,6 +1103,11 @@ DownloadItem::DownloadCreationType DownloadItemImpl::GetDownloadCreationType()
return download_type_; return download_type_;
} }
const base::Optional<DownloadSchedule>& DownloadItemImpl::GetDownloadSchedule()
const {
return download_schedule_;
}
void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type, void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type,
DownloadInterruptReason reason) { DownloadInterruptReason reason) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "components/download/public/common/download_danger_type.h" #include "components/download/public/common/download_danger_type.h"
#include "components/download/public/common/download_export.h" #include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_interrupt_reasons.h" #include "components/download/public/common/download_interrupt_reasons.h"
#include "components/download/public/common/download_schedule.h"
#include "components/download/public/common/download_source.h" #include "components/download/public/common/download_source.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
#include "url/origin.h" #include "url/origin.h"
...@@ -512,6 +513,10 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItem : public base::SupportsUserData { ...@@ -512,6 +513,10 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItem : public base::SupportsUserData {
// Gets the DownloadCreationType of this item. // Gets the DownloadCreationType of this item.
virtual DownloadCreationType GetDownloadCreationType() const = 0; virtual DownloadCreationType GetDownloadCreationType() const = 0;
// Gets the download schedule to start the time at particular time.
virtual const base::Optional<DownloadSchedule>& GetDownloadSchedule()
const = 0;
// External state transitions/setters ---------------------------------------- // External state transitions/setters ----------------------------------------
// TODO(rdsmith): These should all be removed; the download item should // TODO(rdsmith): These should all be removed; the download item should
......
...@@ -297,6 +297,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl ...@@ -297,6 +297,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
bool IsTransient() const override; bool IsTransient() const override;
bool IsParallelDownload() const override; bool IsParallelDownload() const override;
DownloadCreationType GetDownloadCreationType() const override; DownloadCreationType GetDownloadCreationType() const override;
const base::Optional<DownloadSchedule>& GetDownloadSchedule() const override;
void OnContentCheckCompleted(DownloadDangerType danger_type, void OnContentCheckCompleted(DownloadDangerType danger_type,
DownloadInterruptReason reason) override; DownloadInterruptReason reason) override;
void OnAsyncScanningCompleted(DownloadDangerType danger_type) override; void OnAsyncScanningCompleted(DownloadDangerType danger_type) override;
...@@ -841,6 +842,9 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl ...@@ -841,6 +842,9 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
// The MixedContentStatus if determined. // The MixedContentStatus if determined.
MixedContentStatus mixed_content_status_ = MixedContentStatus::UNKNOWN; MixedContentStatus mixed_content_status_ = MixedContentStatus::UNKNOWN;
// Defines when to start the download. Used by download later feature.
base::Optional<DownloadSchedule> download_schedule_;
THREAD_CHECKER(thread_checker_); THREAD_CHECKER(thread_checker_);
base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_{this}; base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_{this};
......
...@@ -124,6 +124,8 @@ class MockDownloadItem : public DownloadItem { ...@@ -124,6 +124,8 @@ class MockDownloadItem : public DownloadItem {
MOCK_CONST_METHOD0(IsTransient, bool()); MOCK_CONST_METHOD0(IsTransient, bool());
MOCK_CONST_METHOD0(IsParallelDownload, bool()); MOCK_CONST_METHOD0(IsParallelDownload, bool());
MOCK_CONST_METHOD0(GetDownloadCreationType, DownloadCreationType()); MOCK_CONST_METHOD0(GetDownloadCreationType, DownloadCreationType());
MOCK_CONST_METHOD0(GetDownloadSchedule,
const base::Optional<DownloadSchedule>&());
MOCK_METHOD2(OnContentCheckCompleted, MOCK_METHOD2(OnContentCheckCompleted,
void(DownloadDangerType, DownloadInterruptReason)); void(DownloadDangerType, DownloadInterruptReason));
MOCK_METHOD1(SetOpenWhenComplete, void(bool)); MOCK_METHOD1(SetOpenWhenComplete, void(bool));
......
...@@ -197,6 +197,11 @@ FakeDownloadItem::GetDownloadCreationType() const { ...@@ -197,6 +197,11 @@ FakeDownloadItem::GetDownloadCreationType() const {
return download::DownloadItem::DownloadCreationType::TYPE_ACTIVE_DOWNLOAD; return download::DownloadItem::DownloadCreationType::TYPE_ACTIVE_DOWNLOAD;
} }
const base::Optional<download::DownloadSchedule>&
FakeDownloadItem::GetDownloadSchedule() const {
return download_schedule_;
}
void FakeDownloadItem::SetIsDone(bool is_done) { void FakeDownloadItem::SetIsDone(bool is_done) {
is_done_ = is_done; is_done_ = is_done;
} }
......
...@@ -57,6 +57,8 @@ class FakeDownloadItem : public download::DownloadItem { ...@@ -57,6 +57,8 @@ class FakeDownloadItem : public download::DownloadItem {
bool IsTransient() const override; bool IsTransient() const override;
bool IsParallelDownload() const override; bool IsParallelDownload() const override;
DownloadCreationType GetDownloadCreationType() const override; DownloadCreationType GetDownloadCreationType() const override;
const base::Optional<download::DownloadSchedule>& GetDownloadSchedule()
const override;
bool IsDone() const override; bool IsDone() const override;
const std::string& GetETag() const override; const std::string& GetETag() const override;
const std::string& GetLastModifiedTime() const override; const std::string& GetLastModifiedTime() const override;
...@@ -179,6 +181,7 @@ class FakeDownloadItem : public download::DownloadItem { ...@@ -179,6 +181,7 @@ class FakeDownloadItem : public download::DownloadItem {
std::string etag_; std::string etag_;
std::string last_modified_time_; std::string last_modified_time_;
std::string hash_; std::string hash_;
base::Optional<download::DownloadSchedule> download_schedule_;
// The members below are to be returned by methods, which return by reference. // The members below are to be returned by methods, which return by reference.
std::string dummy_string; std::string dummy_string;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment