Commit 98db6a59 authored by Min Qin's avatar Min Qin Committed by Commit Bot

move DownloadItemImpl and DownloadItemImplDelegate to components/download

Just move the files and resolve all the includes, no functional change.

BUG=803135

Change-Id: Ib5a9d7958639526da697ba6556b0d9433d544cee
Reviewed-on: https://chromium-review.googlesource.com/991076Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547786}
parent 0917c680
...@@ -7,7 +7,7 @@ if (is_android) { ...@@ -7,7 +7,7 @@ if (is_android) {
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
} }
static_library("in_progress") { source_set("in_progress") {
sources = [ sources = [
"download_entry.cc", "download_entry.cc",
"download_entry.h", "download_entry.h",
...@@ -21,7 +21,6 @@ static_library("in_progress") { ...@@ -21,7 +21,6 @@ static_library("in_progress") {
deps = [ deps = [
"//base", "//base",
"//components/download/downloader/in_progress/proto", "//components/download/downloader/in_progress/proto",
"//components/download/public/common:public",
"//net", "//net",
"//services/metrics/public/cpp:metrics_cpp", "//services/metrics/public/cpp:metrics_cpp",
] ]
......
...@@ -18,6 +18,8 @@ source_set("internal") { ...@@ -18,6 +18,8 @@ source_set("internal") {
"download_file_impl.cc", "download_file_impl.cc",
"download_interrupt_reasons_impl.cc", "download_interrupt_reasons_impl.cc",
"download_interrupt_reasons_utils.cc", "download_interrupt_reasons_utils.cc",
"download_item_impl.cc",
"download_item_impl_delegate.cc",
"download_job.cc", "download_job.cc",
"download_job_factory.cc", "download_job_factory.cc",
"download_job_impl.cc", "download_job_impl.cc",
...@@ -42,6 +44,7 @@ source_set("internal") { ...@@ -42,6 +44,7 @@ source_set("internal") {
deps = [ deps = [
"//base", "//base",
"//components/download/downloader/in_progress",
"//components/download/public/common:interfaces", "//components/download/public/common:interfaces",
"//components/download/quarantine", "//components/download/quarantine",
"//mojo/public/c/system", "//mojo/public/c/system",
......
include_rules = [ include_rules = [
"-content", "-content",
"+components/download/downloader/in_progress",
"+components/download/public/common", "+components/download/public/common",
"+components/download/quarantine", "+components/download/quarantine",
"+components/ukm/test_ukm_recorder.h", "+components/ukm/test_ukm_recorder.h",
......
...@@ -2,19 +2,18 @@ ...@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/download/download_item_impl_delegate.h" #include "components/download/public/common/download_item_impl_delegate.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/download/downloader/in_progress/download_entry.h" #include "components/download/downloader/in_progress/download_entry.h"
#include "components/download/public/common/download_danger_type.h" #include "components/download/public/common/download_danger_type.h"
#include "content/browser/download/download_item_impl.h" #include "components/download/public/common/download_item_impl.h"
namespace content { namespace download {
// Infrastructure in DownloadItemImplDelegate to assert invariant that // Infrastructure in DownloadItemImplDelegate to assert invariant that
// delegate always outlives all attached DownloadItemImpls. // delegate always outlives all attached DownloadItemImpls.
DownloadItemImplDelegate::DownloadItemImplDelegate() DownloadItemImplDelegate::DownloadItemImplDelegate() : count_(0) {}
: count_(0) {}
DownloadItemImplDelegate::~DownloadItemImplDelegate() { DownloadItemImplDelegate::~DownloadItemImplDelegate() {
DCHECK_EQ(0, count_); DCHECK_EQ(0, count_);
...@@ -30,13 +29,13 @@ void DownloadItemImplDelegate::Detach() { ...@@ -30,13 +29,13 @@ void DownloadItemImplDelegate::Detach() {
} }
void DownloadItemImplDelegate::DetermineDownloadTarget( void DownloadItemImplDelegate::DetermineDownloadTarget(
DownloadItemImpl* download, const DownloadTargetCallback& callback) { DownloadItemImpl* download,
const DownloadTargetCallback& callback) {
// TODO(rdsmith/asanka): Do something useful if forced file path is null. // TODO(rdsmith/asanka): Do something useful if forced file path is null.
base::FilePath target_path(download->GetForcedFilePath()); base::FilePath target_path(download->GetForcedFilePath());
callback.Run(target_path, callback.Run(target_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DownloadItem::TARGET_DISPOSITION_OVERWRITE, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, target_path,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, target_path, DOWNLOAD_INTERRUPT_REASON_NONE);
download::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
bool DownloadItemImplDelegate::ShouldCompleteDownload( bool DownloadItemImplDelegate::ShouldCompleteDownload(
...@@ -46,7 +45,8 @@ bool DownloadItemImplDelegate::ShouldCompleteDownload( ...@@ -46,7 +45,8 @@ bool DownloadItemImplDelegate::ShouldCompleteDownload(
} }
bool DownloadItemImplDelegate::ShouldOpenDownload( bool DownloadItemImplDelegate::ShouldOpenDownload(
DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback) { DownloadItemImpl* download,
const ShouldOpenDownloadCallback& callback) {
return false; return false;
} }
...@@ -64,7 +64,7 @@ std::string DownloadItemImplDelegate::GetApplicationClientIdForFileScanning() ...@@ -64,7 +64,7 @@ std::string DownloadItemImplDelegate::GetApplicationClientIdForFileScanning()
} }
void DownloadItemImplDelegate::ResumeInterruptedDownload( void DownloadItemImplDelegate::ResumeInterruptedDownload(
std::unique_ptr<download::DownloadUrlParameters> params, std::unique_ptr<DownloadUrlParameters> params,
uint32_t id, uint32_t id,
const GURL& site_url) {} const GURL& site_url) {}
...@@ -88,9 +88,9 @@ void DownloadItemImplDelegate::AssertStateConsistent( ...@@ -88,9 +88,9 @@ void DownloadItemImplDelegate::AssertStateConsistent(
void DownloadItemImplDelegate::DownloadInterrupted(DownloadItemImpl* download) { void DownloadItemImplDelegate::DownloadInterrupted(DownloadItemImpl* download) {
} }
base::Optional<download::DownloadEntry> base::Optional<DownloadEntry> DownloadItemImplDelegate::GetInProgressEntry(
DownloadItemImplDelegate::GetInProgressEntry(DownloadItemImpl* download) { DownloadItemImpl* download) {
return base::Optional<download::DownloadEntry>(); return base::Optional<DownloadEntry>();
} }
bool DownloadItemImplDelegate::IsOffTheRecord() const { bool DownloadItemImplDelegate::IsOffTheRecord() const {
...@@ -99,4 +99,4 @@ bool DownloadItemImplDelegate::IsOffTheRecord() const { ...@@ -99,4 +99,4 @@ bool DownloadItemImplDelegate::IsOffTheRecord() const {
void DownloadItemImplDelegate::ReportBytesWasted(DownloadItemImpl* download) {} void DownloadItemImplDelegate::ReportBytesWasted(DownloadItemImpl* download) {}
} // namespace content } // namespace download
...@@ -30,6 +30,8 @@ component("public") { ...@@ -30,6 +30,8 @@ component("public") {
"download_interrupt_reasons.h", "download_interrupt_reasons.h",
"download_interrupt_reasons_utils.h", "download_interrupt_reasons_utils.h",
"download_item.h", "download_item.h",
"download_item_impl.h",
"download_item_impl_delegate.h",
"download_job.h", "download_job.h",
"download_job_factory.h", "download_job_factory.h",
"download_job_impl.h", "download_job_impl.h",
...@@ -65,6 +67,7 @@ component("public") { ...@@ -65,6 +67,7 @@ component("public") {
deps = [ deps = [
"//base", "//base",
"//components/download/downloader/in_progress",
"//components/download/internal/common:internal", "//components/download/internal/common:internal",
"//crypto", "//crypto",
"//net", "//net",
...@@ -74,8 +77,10 @@ component("public") { ...@@ -74,8 +77,10 @@ component("public") {
"//ui/base", "//ui/base",
] ]
allow_circular_includes_from = allow_circular_includes_from = [
[ "//components/download/internal/common:internal" ] "//components/download/internal/common:internal",
"//components/download/downloader/in_progress",
]
} }
if (is_android) { if (is_android) {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ #ifndef COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ #define COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
#include <stdint.h> #include <stdint.h>
...@@ -11,23 +11,19 @@ ...@@ -11,23 +11,19 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_item.h" #include "components/download/public/common/download_item.h"
#include "components/download/public/common/download_url_parameters.h" #include "components/download/public/common/download_url_parameters.h"
#include "content/common/content_export.h"
#include "content/public/browser/download_manager_delegate.h"
namespace download { namespace download {
struct DownloadEntry; struct DownloadEntry;
}
namespace content {
class DownloadItemImpl; class DownloadItemImpl;
// Delegate for operations that a DownloadItemImpl can't do for itself. // Delegate for operations that a DownloadItemImpl can't do for itself.
// The base implementation of this class does nothing (returning false // The base implementation of this class does nothing (returning false
// on predicates) so interfaces not of interest to a derived class may // on predicates) so interfaces not of interest to a derived class may
// be left unimplemented. // be left unimplemented.
class CONTENT_EXPORT DownloadItemImplDelegate { class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImplDelegate {
public: public:
// The boolean argument indicates whether or not the download was // The boolean argument indicates whether or not the download was
// actually opened. // actually opened.
...@@ -40,22 +36,27 @@ class CONTENT_EXPORT DownloadItemImplDelegate { ...@@ -40,22 +36,27 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
void Attach(); void Attach();
void Detach(); void Detach();
using DownloadTargetCallback =
base::Callback<void(const base::FilePath& target_path,
DownloadItem::TargetDisposition disposition,
DownloadDangerType danger_type,
const base::FilePath& intermediate_path,
DownloadInterruptReason interrupt_reason)>;
// Request determination of the download target from the delegate. // Request determination of the download target from the delegate.
virtual void DetermineDownloadTarget( virtual void DetermineDownloadTarget(DownloadItemImpl* download,
DownloadItemImpl* download, const DownloadTargetCallback& callback); const DownloadTargetCallback& callback);
// Allows the delegate to delay completion of the download. This function // Allows the delegate to delay completion of the download. This function
// will either return true (if the download may complete now) or will return // will either return true (if the download may complete now) or will return
// false and call the provided callback at some future point. This function // false and call the provided callback at some future point. This function
// may be called repeatedly. // may be called repeatedly.
virtual bool ShouldCompleteDownload( virtual bool ShouldCompleteDownload(DownloadItemImpl* download,
DownloadItemImpl* download, const base::Closure& complete_callback);
const base::Closure& complete_callback);
// Allows the delegate to override the opening of a download. If it returns // Allows the delegate to override the opening of a download. If it returns
// true then it's reponsible for opening the item. // true then it's reponsible for opening the item.
virtual bool ShouldOpenDownload( virtual bool ShouldOpenDownload(DownloadItemImpl* download,
DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback); const ShouldOpenDownloadCallback& callback);
// Tests if a file type should be opened automatically. // Tests if a file type should be opened automatically.
virtual bool ShouldOpenFileBasedOnExtension(const base::FilePath& path); virtual bool ShouldOpenFileBasedOnExtension(const base::FilePath& path);
...@@ -76,7 +77,7 @@ class CONTENT_EXPORT DownloadItemImplDelegate { ...@@ -76,7 +77,7 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
// Called when an interrupted download is resumed. // Called when an interrupted download is resumed.
virtual void ResumeInterruptedDownload( virtual void ResumeInterruptedDownload(
std::unique_ptr<download::DownloadUrlParameters> params, std::unique_ptr<DownloadUrlParameters> params,
uint32_t id, uint32_t id,
const GURL& site_url); const GURL& site_url);
...@@ -94,7 +95,7 @@ class CONTENT_EXPORT DownloadItemImplDelegate { ...@@ -94,7 +95,7 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
virtual void ShowDownloadInShell(DownloadItemImpl* download); virtual void ShowDownloadInShell(DownloadItemImpl* download);
// Handle any delegate portions of a state change operation on the // Handle any delegate portions of a state change operation on the
// download::DownloadItem. // DownloadItem.
virtual void DownloadRemoved(DownloadItemImpl* download); virtual void DownloadRemoved(DownloadItemImpl* download);
// Assert consistent state for delgate object at various transitions. // Assert consistent state for delgate object at various transitions.
...@@ -104,7 +105,7 @@ class CONTENT_EXPORT DownloadItemImplDelegate { ...@@ -104,7 +105,7 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
virtual void DownloadInterrupted(DownloadItemImpl* download); virtual void DownloadInterrupted(DownloadItemImpl* download);
// Get the in progress entry for the download item. // Get the in progress entry for the download item.
virtual base::Optional<download::DownloadEntry> GetInProgressEntry( virtual base::Optional<DownloadEntry> GetInProgressEntry(
DownloadItemImpl* download); DownloadItemImpl* download);
// Whether the download is off the record. // Whether the download is off the record.
...@@ -120,6 +121,6 @@ class CONTENT_EXPORT DownloadItemImplDelegate { ...@@ -120,6 +121,6 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate);
}; };
} // namespace content } // namespace download
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ #endif // COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
...@@ -695,10 +695,6 @@ jumbo_source_set("browser") { ...@@ -695,10 +695,6 @@ jumbo_source_set("browser") {
"download/byte_stream_input_stream.cc", "download/byte_stream_input_stream.cc",
"download/byte_stream_input_stream.h", "download/byte_stream_input_stream.h",
"download/download_item_factory.h", "download/download_item_factory.h",
"download/download_item_impl.cc",
"download/download_item_impl.h",
"download/download_item_impl_delegate.cc",
"download/download_item_impl_delegate.h",
"download/download_item_utils.cc", "download/download_item_utils.cc",
"download/download_manager_impl.cc", "download/download_manager_impl.cc",
"download/download_manager_impl.h", "download/download_manager_impl.h",
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "components/download/public/common/download_file_impl.h" #include "components/download/public/common/download_file_impl.h"
#include "components/download/public/common/download_task_runner.h" #include "components/download/public/common/download_task_runner.h"
#include "components/download/public/common/parallel_download_utils.h" #include "components/download/public/common/parallel_download_utils.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_manager_impl.h" #include "content/browser/download/download_manager_impl.h"
#include "content/browser/download/download_resource_handler.h" #include "content/browser/download/download_resource_handler.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
......
...@@ -25,20 +25,19 @@ class FilePath; ...@@ -25,20 +25,19 @@ class FilePath;
namespace download { namespace download {
struct DownloadCreateInfo; struct DownloadCreateInfo;
class DownloadItemImpl;
class DownloadItemImplDelegate;
class DownloadRequestHandleInterface; class DownloadRequestHandleInterface;
} // namespace download } // namespace download
namespace content { namespace content {
class DownloadItemImpl;
class DownloadItemImplDelegate;
class DownloadItemFactory { class DownloadItemFactory {
public: public:
virtual ~DownloadItemFactory() {} virtual ~DownloadItemFactory() {}
virtual DownloadItemImpl* CreatePersistedItem( virtual download::DownloadItemImpl* CreatePersistedItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
const std::string& guid, const std::string& guid,
uint32_t download_id, uint32_t download_id,
const base::FilePath& current_path, const base::FilePath& current_path,
...@@ -66,13 +65,13 @@ public: ...@@ -66,13 +65,13 @@ public:
const std::vector<download::DownloadItem::ReceivedSlice>& const std::vector<download::DownloadItem::ReceivedSlice>&
received_slices) = 0; received_slices) = 0;
virtual DownloadItemImpl* CreateActiveItem( virtual download::DownloadItemImpl* CreateActiveItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
uint32_t download_id, uint32_t download_id,
const download::DownloadCreateInfo& info) = 0; const download::DownloadCreateInfo& info) = 0;
virtual DownloadItemImpl* CreateSavePageItem( virtual download::DownloadItemImpl* CreateSavePageItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
uint32_t download_id, uint32_t download_id,
const base::FilePath& path, const base::FilePath& path,
const GURL& url, const GURL& url,
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/sequenced_task_runner_helpers.h" #include "base/sequenced_task_runner_helpers.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "components/download/public/common/download_item_impl_delegate.h"
#include "components/download/public/common/download_url_parameters.h" #include "components/download/public/common/download_url_parameters.h"
#include "components/download/public/common/url_download_handler.h" #include "components/download/public/common/url_download_handler.h"
#include "content/browser/download/download_item_impl_delegate.h"
#include "content/browser/loader/navigation_url_loader.h" #include "content/browser/loader/navigation_url_loader.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -34,12 +34,12 @@ ...@@ -34,12 +34,12 @@
namespace download { namespace download {
class DownloadFileFactory; class DownloadFileFactory;
class DownloadItemImpl;
class DownloadRequestHandleInterface; class DownloadRequestHandleInterface;
} }
namespace content { namespace content {
class DownloadItemFactory; class DownloadItemFactory;
class DownloadItemImpl;
class ResourceContext; class ResourceContext;
class StoragePartitionImpl; class StoragePartitionImpl;
class URLLoaderFactoryGetter; class URLLoaderFactoryGetter;
...@@ -47,9 +47,10 @@ class URLLoaderFactoryGetter; ...@@ -47,9 +47,10 @@ class URLLoaderFactoryGetter;
class CONTENT_EXPORT DownloadManagerImpl class CONTENT_EXPORT DownloadManagerImpl
: public DownloadManager, : public DownloadManager,
public download::UrlDownloadHandler::Delegate, public download::UrlDownloadHandler::Delegate,
private DownloadItemImplDelegate { private download::DownloadItemImplDelegate {
public: public:
using DownloadItemImplCreated = base::Callback<void(DownloadItemImpl*)>; using DownloadItemImplCreated =
base::Callback<void(download::DownloadItemImpl*)>;
// Caller guarantees that |net_log| will remain valid // Caller guarantees that |net_log| will remain valid
// for the lifetime of DownloadManagerImpl (until Shutdown() is called). // for the lifetime of DownloadManagerImpl (until Shutdown() is called).
...@@ -172,8 +173,9 @@ class CONTENT_EXPORT DownloadManagerImpl ...@@ -172,8 +173,9 @@ class CONTENT_EXPORT DownloadManagerImpl
private: private:
using DownloadSet = std::set<download::DownloadItem*>; using DownloadSet = std::set<download::DownloadItem*>;
using DownloadGuidMap = std::unordered_map<std::string, DownloadItemImpl*>; using DownloadGuidMap =
using DownloadItemImplVector = std::vector<DownloadItemImpl*>; std::unordered_map<std::string, download::DownloadItemImpl*>;
using DownloadItemImplVector = std::vector<download::DownloadItemImpl*>;
// For testing. // For testing.
friend class DownloadManagerTest; friend class DownloadManagerTest;
...@@ -204,8 +206,9 @@ class CONTENT_EXPORT DownloadManagerImpl ...@@ -204,8 +206,9 @@ class CONTENT_EXPORT DownloadManagerImpl
// Create a new active item based on the info. Separate from // Create a new active item based on the info. Separate from
// StartDownload() for testing. // StartDownload() for testing.
DownloadItemImpl* CreateActiveItem(uint32_t id, download::DownloadItemImpl* CreateActiveItem(
const download::DownloadCreateInfo& info); uint32_t id,
const download::DownloadCreateInfo& info);
// Get next download id. |callback| is called on the UI thread and may // Get next download id. |callback| is called on the UI thread and may
// be called synchronously. // be called synchronously.
...@@ -218,28 +221,29 @@ class CONTENT_EXPORT DownloadManagerImpl ...@@ -218,28 +221,29 @@ class CONTENT_EXPORT DownloadManagerImpl
// Overridden from DownloadItemImplDelegate // Overridden from DownloadItemImplDelegate
// (Note that |GetBrowserContext| are present in both interfaces.) // (Note that |GetBrowserContext| are present in both interfaces.)
void DetermineDownloadTarget(DownloadItemImpl* item, void DetermineDownloadTarget(download::DownloadItemImpl* item,
const DownloadTargetCallback& callback) override; const DownloadTargetCallback& callback) override;
bool ShouldCompleteDownload(DownloadItemImpl* item, bool ShouldCompleteDownload(download::DownloadItemImpl* item,
const base::Closure& complete_callback) override; const base::Closure& complete_callback) override;
bool ShouldOpenFileBasedOnExtension(const base::FilePath& path) override; bool ShouldOpenFileBasedOnExtension(const base::FilePath& path) override;
bool ShouldOpenDownload(DownloadItemImpl* item, bool ShouldOpenDownload(download::DownloadItemImpl* item,
const ShouldOpenDownloadCallback& callback) override; const ShouldOpenDownloadCallback& callback) override;
void CheckForFileRemoval(DownloadItemImpl* download_item) override; void CheckForFileRemoval(download::DownloadItemImpl* download_item) override;
std::string GetApplicationClientIdForFileScanning() const override; std::string GetApplicationClientIdForFileScanning() const override;
void ResumeInterruptedDownload( void ResumeInterruptedDownload(
std::unique_ptr<download::DownloadUrlParameters> params, std::unique_ptr<download::DownloadUrlParameters> params,
uint32_t id, uint32_t id,
const GURL& site_url) override; const GURL& site_url) override;
void OpenDownload(DownloadItemImpl* download) override; void OpenDownload(download::DownloadItemImpl* download) override;
bool IsMostRecentDownloadItemAtFilePath(DownloadItemImpl* download) override; bool IsMostRecentDownloadItemAtFilePath(
void ShowDownloadInShell(DownloadItemImpl* download) override; download::DownloadItemImpl* download) override;
void DownloadRemoved(DownloadItemImpl* download) override; void ShowDownloadInShell(download::DownloadItemImpl* download) override;
void DownloadInterrupted(DownloadItemImpl* download) override; void DownloadRemoved(download::DownloadItemImpl* download) override;
void DownloadInterrupted(download::DownloadItemImpl* download) override;
base::Optional<download::DownloadEntry> GetInProgressEntry( base::Optional<download::DownloadEntry> GetInProgressEntry(
DownloadItemImpl* download) override; download::DownloadItemImpl* download) override;
bool IsOffTheRecord() const override; bool IsOffTheRecord() const override;
void ReportBytesWasted(DownloadItemImpl* download) override; void ReportBytesWasted(download::DownloadItemImpl* download) override;
// Helper method to start or resume a download. // Helper method to start or resume a download.
void BeginDownloadInternal( void BeginDownloadInternal(
...@@ -289,7 +293,8 @@ class CONTENT_EXPORT DownloadManagerImpl ...@@ -289,7 +293,8 @@ class CONTENT_EXPORT DownloadManagerImpl
// "save page as" downloads. // "save page as" downloads.
// TODO(asanka): Remove this container in favor of downloads_by_guid_ as a // TODO(asanka): Remove this container in favor of downloads_by_guid_ as a
// part of http://crbug.com/593020. // part of http://crbug.com/593020.
std::unordered_map<uint32_t, std::unique_ptr<DownloadItemImpl>> downloads_; std::unordered_map<uint32_t, std::unique_ptr<download::DownloadItemImpl>>
downloads_;
// Same as the above, but maps from GUID to download item. Note that the // Same as the above, but maps from GUID to download item. Note that the
// container is case sensitive. Hence the key needs to be normalized to // container is case sensitive. Hence the key needs to be normalized to
......
...@@ -28,13 +28,13 @@ ...@@ -28,13 +28,13 @@
#include "components/download/public/common/download_file_factory.h" #include "components/download/public/common/download_file_factory.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_item.h" #include "components/download/public/common/download_item.h"
#include "components/download/public/common/download_item_impl.h"
#include "components/download/public/common/download_item_impl_delegate.h"
#include "components/download/public/common/download_request_handle_interface.h" #include "components/download/public/common/download_request_handle_interface.h"
#include "components/download/public/common/mock_download_file.h" #include "components/download/public/common/mock_download_file.h"
#include "content/browser/byte_stream.h" #include "content/browser/byte_stream.h"
#include "content/browser/download/byte_stream_input_stream.h" #include "content/browser/download/byte_stream_input_stream.h"
#include "content/browser/download/download_item_factory.h" #include "content/browser/download/download_item_factory.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_item_impl_delegate.h"
#include "content/browser/download/mock_download_item_impl.h" #include "content/browser/download/mock_download_item_impl.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/download_manager_delegate.h" #include "content/public/browser/download_manager_delegate.h"
...@@ -123,8 +123,8 @@ class MockDownloadItemFactory ...@@ -123,8 +123,8 @@ class MockDownloadItemFactory
void SetHasObserverCalls(bool observer_calls); void SetHasObserverCalls(bool observer_calls);
// Overridden methods from DownloadItemFactory. // Overridden methods from DownloadItemFactory.
DownloadItemImpl* CreatePersistedItem( download::DownloadItemImpl* CreatePersistedItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
const std::string& guid, const std::string& guid,
uint32_t download_id, uint32_t download_id,
const base::FilePath& current_path, const base::FilePath& current_path,
...@@ -151,12 +151,12 @@ class MockDownloadItemFactory ...@@ -151,12 +151,12 @@ class MockDownloadItemFactory
bool transient, bool transient,
const std::vector<download::DownloadItem::ReceivedSlice>& received_slices) const std::vector<download::DownloadItem::ReceivedSlice>& received_slices)
override; override;
DownloadItemImpl* CreateActiveItem( download::DownloadItemImpl* CreateActiveItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
uint32_t download_id, uint32_t download_id,
const download::DownloadCreateInfo& info) override; const download::DownloadCreateInfo& info) override;
DownloadItemImpl* CreateSavePageItem( download::DownloadItemImpl* CreateSavePageItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
uint32_t download_id, uint32_t download_id,
const base::FilePath& path, const base::FilePath& path,
const GURL& url, const GURL& url,
...@@ -166,7 +166,7 @@ class MockDownloadItemFactory ...@@ -166,7 +166,7 @@ class MockDownloadItemFactory
private: private:
std::map<uint32_t, MockDownloadItemImpl*> items_; std::map<uint32_t, MockDownloadItemImpl*> items_;
DownloadItemImplDelegate item_delegate_; download::DownloadItemImplDelegate item_delegate_;
bool has_observer_calls_; bool has_observer_calls_;
DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory); DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory);
...@@ -203,8 +203,8 @@ void MockDownloadItemFactory::SetHasObserverCalls(bool has_observer_calls) { ...@@ -203,8 +203,8 @@ void MockDownloadItemFactory::SetHasObserverCalls(bool has_observer_calls) {
has_observer_calls_ = has_observer_calls; has_observer_calls_ = has_observer_calls;
} }
DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( download::DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
const std::string& guid, const std::string& guid,
uint32_t download_id, uint32_t download_id,
const base::FilePath& current_path, const base::FilePath& current_path,
...@@ -240,8 +240,8 @@ DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( ...@@ -240,8 +240,8 @@ DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem(
return result; return result;
} }
DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem( download::DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
uint32_t download_id, uint32_t download_id,
const download::DownloadCreateInfo& info) { const download::DownloadCreateInfo& info) {
DCHECK(items_.find(download_id) == items_.end()); DCHECK(items_.find(download_id) == items_.end());
...@@ -267,8 +267,8 @@ DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem( ...@@ -267,8 +267,8 @@ DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem(
return result; return result;
} }
DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem( download::DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem(
DownloadItemImplDelegate* delegate, download::DownloadItemImplDelegate* delegate,
uint32_t download_id, uint32_t download_id,
const base::FilePath& path, const base::FilePath& path,
const GURL& url, const GURL& url,
...@@ -446,7 +446,7 @@ class DownloadManagerTest : public testing::Test { ...@@ -446,7 +446,7 @@ class DownloadManagerTest : public testing::Test {
interrupt_reason_ = interrupt_reason; interrupt_reason_ = interrupt_reason;
} }
void DetermineDownloadTarget(DownloadItemImpl* item) { void DetermineDownloadTarget(download::DownloadItemImpl* item) {
download_manager_->DetermineDownloadTarget( download_manager_->DetermineDownloadTarget(
item, base::Bind( item, base::Bind(
&DownloadManagerTest::DownloadTargetDeterminedCallback, &DownloadManagerTest::DownloadTargetDeterminedCallback,
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "components/download/public/common/download_item.h"
#include "components/download/public/common/download_url_parameters.h" #include "components/download/public/common/download_url_parameters.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_request_core.h" #include "content/browser/download/download_request_core.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
......
...@@ -99,21 +99,4 @@ std::unique_ptr<net::URLRequest> CreateURLRequestOnIOThread( ...@@ -99,21 +99,4 @@ std::unique_ptr<net::URLRequest> CreateURLRequestOnIOThread(
return request; return request;
} }
base::Optional<download::DownloadEntry> GetInProgressEntry(
const std::string& guid,
BrowserContext* browser_context) {
base::Optional<download::DownloadEntry> entry;
if (!browser_context || guid.empty())
return entry;
auto* manager_delegate = browser_context->GetDownloadManagerDelegate();
if (manager_delegate) {
download::InProgressCache* in_progress_cache =
manager_delegate->GetInProgressCache();
if (in_progress_cache)
entry = in_progress_cache->RetrieveEntry(guid);
}
return entry;
}
} // namespace content } // namespace content
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "content/common/content_export.h" #include "content/common/content_export.h"
namespace download { namespace download {
struct DownloadEntry;
class DownloadUrlParameters; class DownloadUrlParameters;
} // namespace download } // namespace download
...@@ -25,18 +24,12 @@ class BlobStorageContext; ...@@ -25,18 +24,12 @@ class BlobStorageContext;
namespace content { namespace content {
class BrowserContext;
class ResourceContext; class ResourceContext;
// Create a URLRequest from |params|. // Create a URLRequest from |params|.
std::unique_ptr<net::URLRequest> CONTENT_EXPORT std::unique_ptr<net::URLRequest> CONTENT_EXPORT
CreateURLRequestOnIOThread(download::DownloadUrlParameters* params); CreateURLRequestOnIOThread(download::DownloadUrlParameters* params);
// Get the entry based on |guid| from in progress cache.
CONTENT_EXPORT base::Optional<download::DownloadEntry> GetInProgressEntry(
const std::string& guid,
BrowserContext* browser_context);
storage::BlobStorageContext* BlobStorageContextGetter( storage::BlobStorageContext* BlobStorageContextGetter(
ResourceContext* resource_context); ResourceContext* resource_context);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_manager_impl.h" #include "content/browser/download/download_manager_impl.h"
#include "content/browser/download/drag_download_file.h" #include "content/browser/download/drag_download_file.h"
#include "content/browser/download/drag_download_util.h" #include "content/browser/download/drag_download_util.h"
......
...@@ -6,33 +6,35 @@ ...@@ -6,33 +6,35 @@
namespace content { namespace content {
MockDownloadItemImpl::MockDownloadItemImpl(DownloadItemImplDelegate* delegate) MockDownloadItemImpl::MockDownloadItemImpl(
: DownloadItemImpl(delegate, download::DownloadItemImplDelegate* delegate)
std::string("7d122682-55b5-4a47-a253-36cadc3e5bee"), : download::DownloadItemImpl(
download::DownloadItem::kInvalidId, delegate,
base::FilePath(), std::string("7d122682-55b5-4a47-a253-36cadc3e5bee"),
base::FilePath(), download::DownloadItem::kInvalidId,
std::vector<GURL>(), base::FilePath(),
GURL(), base::FilePath(),
GURL(), std::vector<GURL>(),
GURL(), GURL(),
GURL(), GURL(),
"application/octet-stream", GURL(),
"application/octet-stream", GURL(),
base::Time(), "application/octet-stream",
base::Time(), "application/octet-stream",
std::string(), base::Time(),
std::string(), base::Time(),
0, std::string(),
0, std::string(),
std::string(), 0,
download::DownloadItem::COMPLETE, 0,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, std::string(),
download::DOWNLOAD_INTERRUPT_REASON_NONE, download::DownloadItem::COMPLETE,
false, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
base::Time(), download::DOWNLOAD_INTERRUPT_REASON_NONE,
true, false,
download::DownloadItem::ReceivedSlices()) {} base::Time(),
true,
download::DownloadItem::ReceivedSlices()) {}
MockDownloadItemImpl::~MockDownloadItemImpl() = default; MockDownloadItemImpl::~MockDownloadItemImpl() = default;
......
...@@ -12,18 +12,18 @@ ...@@ -12,18 +12,18 @@
#include "base/macros.h" #include "base/macros.h"
#include "components/download/public/common/download_create_info.h" #include "components/download/public/common/download_create_info.h"
#include "components/download/public/common/download_file.h" #include "components/download/public/common/download_file.h"
#include "components/download/public/common/download_item_impl.h"
#include "components/download/public/common/download_request_handle_interface.h" #include "components/download/public/common/download_request_handle_interface.h"
#include "content/browser/download/download_item_impl.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
namespace content { namespace content {
class DownloadManager; class DownloadManager;
class MockDownloadItemImpl : public DownloadItemImpl { class MockDownloadItemImpl : public download::DownloadItemImpl {
public: public:
// Use history constructor for minimal base object. // Use history constructor for minimal base object.
explicit MockDownloadItemImpl(DownloadItemImplDelegate* delegate); explicit MockDownloadItemImpl(download::DownloadItemImplDelegate* delegate);
~MockDownloadItemImpl() override; ~MockDownloadItemImpl() override;
MOCK_METHOD5(OnDownloadTargetDetermined, MOCK_METHOD5(OnDownloadTargetDetermined,
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/download/public/common/download_item_impl.h"
#include "components/download/public/common/download_request_handle_interface.h" #include "components/download/public/common/download_request_handle_interface.h"
#include "components/download/public/common/download_stats.h" #include "components/download/public/common/download_stats.h"
#include "components/download/public/common/download_task_runner.h" #include "components/download/public/common/download_task_runner.h"
...@@ -31,7 +32,6 @@ ...@@ -31,7 +32,6 @@
#include "components/filename_generation/filename_generation.h" #include "components/filename_generation/filename_generation.h"
#include "components/url_formatter/url_formatter.h" #include "components/url_formatter/url_formatter.h"
#include "content/browser/bad_message.h" #include "content/browser/bad_message.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_manager_impl.h" #include "content/browser/download/download_manager_impl.h"
#include "content/browser/download/save_file.h" #include "content/browser/download/save_file.h"
#include "content/browser/download/save_file_manager.h" #include "content/browser/download/save_file_manager.h"
...@@ -297,7 +297,7 @@ bool SavePackage::Init( ...@@ -297,7 +297,7 @@ bool SavePackage::Init(
void SavePackage::InitWithDownloadItem( void SavePackage::InitWithDownloadItem(
const SavePackageDownloadCreatedCallback& download_created_callback, const SavePackageDownloadCreatedCallback& download_created_callback,
DownloadItemImpl* item) { download::DownloadItemImpl* item) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(item); DCHECK(item);
download_ = item; download_ = item;
......
...@@ -34,8 +34,11 @@ ...@@ -34,8 +34,11 @@
class GURL; class GURL;
namespace content { namespace download {
class DownloadItemImpl; class DownloadItemImpl;
}
namespace content {
class DownloadManagerImpl; class DownloadManagerImpl;
class FrameTreeNode; class FrameTreeNode;
class RenderFrameHostImpl; class RenderFrameHostImpl;
...@@ -156,7 +159,7 @@ class CONTENT_EXPORT SavePackage ...@@ -156,7 +159,7 @@ class CONTENT_EXPORT SavePackage
void InitWithDownloadItem( void InitWithDownloadItem(
const SavePackageDownloadCreatedCallback& download_created_callback, const SavePackageDownloadCreatedCallback& download_created_callback,
DownloadItemImpl* item); download::DownloadItemImpl* item);
// Callback for WebContents::GenerateMHTML(). // Callback for WebContents::GenerateMHTML().
void OnMHTMLGenerated(int64_t size); void OnMHTMLGenerated(int64_t size);
...@@ -369,7 +372,7 @@ class CONTENT_EXPORT SavePackage ...@@ -369,7 +372,7 @@ class CONTENT_EXPORT SavePackage
// DownloadManager owns the download::DownloadItem and handles history and UI. // DownloadManager owns the download::DownloadItem and handles history and UI.
DownloadManagerImpl* download_manager_ = nullptr; DownloadManagerImpl* download_manager_ = nullptr;
DownloadItemImpl* download_ = nullptr; download::DownloadItemImpl* download_ = nullptr;
// The URL of the page the user wants to save. // The URL of the page the user wants to save.
const GURL page_url_; const GURL page_url_;
......
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