Commit da69d9a6 authored by Joy Ming's avatar Joy Ming Committed by Commit Bot

In_progress_cache : Initial draft

Details:
1- Stores info into proto format and writes to a file.
2- The cache is instantiated & owned by ChromeDownloadManagerDelegate.
3- The entry is created when download starts and will be deleted as
soon as the download completes.

This is continued from this CL by shaktisahu@:
https://chromium-review.googlesource.com/c/chromium/src/+/731403.

Bug: 778425
Change-Id: I6bd3f6df2648ac7b812c464b572492fb670d32bb
Reviewed-on: https://chromium-review.googlesource.com/753537
Commit-Queue: Joy Ming <jming@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516024}
parent 49956613
......@@ -1599,6 +1599,7 @@ split_static_library("browser") {
"//components/dom_distiller/content/browser",
"//components/domain_reliability",
"//components/download/content/factory",
"//components/download/downloader/in_progress",
"//components/download/public",
"//components/error_page/common",
"//components/favicon/content",
......
......@@ -47,6 +47,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/safe_browsing/file_type_policies.h"
#include "chrome/grit/generated_resources.h"
#include "components/download/downloader/in_progress/in_progress_cache.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
......@@ -215,11 +216,16 @@ ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile)
: profile_(profile),
next_download_id_(content::DownloadItem::kInvalidId),
download_prefs_(new DownloadPrefs(profile)),
check_for_file_existence_task_runner_(
base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN})),
weak_ptr_factory_(this) {}
disk_access_task_runner_(base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN})),
weak_ptr_factory_(this) {
DCHECK(!profile_->GetPath().empty());
base::FilePath metadata_cache_file =
profile_->GetPath().Append(chrome::kDownloadMetadataStoreFilename);
download_metadata_cache_.reset(new download::InProgressCache(
metadata_cache_file, disk_access_task_runner_));
}
ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
// If a DownloadManager was set for this, Shutdown() must be called.
......@@ -496,6 +502,12 @@ void ChromeDownloadManagerDelegate::ChooseSavePath(
callback);
}
download::InProgressCache* ChromeDownloadManagerDelegate::GetInProgressCache() {
// TODO(crbug.com/778425): Make sure the cache is initialized.
DCHECK(download_metadata_cache_ != nullptr);
return download_metadata_cache_.get();
}
void ChromeDownloadManagerDelegate::SanitizeSavePackageResourceName(
base::FilePath* filename) {
safe_browsing::FileTypePolicies* file_type_policies =
......@@ -594,7 +606,7 @@ void ChromeDownloadManagerDelegate::CheckForFileExistence(
}
#endif
base::PostTaskAndReplyWithResult(
check_for_file_existence_task_runner_.get(), FROM_HERE,
disk_access_task_runner_.get(), FROM_HERE,
base::BindOnce(&base::PathExists, download->GetTargetFilePath()),
std::move(callback));
}
......
......@@ -82,6 +82,7 @@ class ChromeDownloadManagerDelegate
const base::FilePath::StringType& default_extension,
bool can_save_as_complete,
const content::SavePackagePathPickedCallback& callback) override;
download::InProgressCache* GetInProgressCache() override;
void SanitizeSavePackageResourceName(base::FilePath* filename) override;
void OpenDownload(content::DownloadItem* download) override;
void ShowDownloadInShell(content::DownloadItem* download) override;
......@@ -176,6 +177,8 @@ class ChromeDownloadManagerDelegate
Profile* profile_;
std::unique_ptr<download::InProgressCache> download_metadata_cache_;
// Incremented by one for each download, the first available download id is
// assigned from history database or 1 when history database fails to
// intialize.
......@@ -186,11 +189,10 @@ class ChromeDownloadManagerDelegate
IdCallbackVector id_callbacks_;
std::unique_ptr<DownloadPrefs> download_prefs_;
// SequencedTaskRunner to check for file existence. A sequence is used so that
// a large download history doesn't cause a large number of concurrent disk
// operations.
const scoped_refptr<base::SequencedTaskRunner>
check_for_file_existence_task_runner_;
// SequencedTaskRunner to check for file existence and read/write metadata
// cache. A sequence is used so that a large download history doesn't cause a
// large number of concurrent disk operations.
const scoped_refptr<base::SequencedTaskRunner> disk_access_task_runner_;
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Maps from pending extension installations to DownloadItem IDs.
......
......@@ -139,6 +139,8 @@ const base::FilePath::CharType kCRLSetFilename[] =
FPL("Certificate Revocation Lists");
const base::FilePath::CharType kCustomDictionaryFileName[] =
FPL("Custom Dictionary.txt");
const base::FilePath::CharType kDownloadMetadataStoreFilename[] =
FPL("in_progress_download_metadata_store");
const base::FilePath::CharType kDownloadServiceStorageDirname[] =
FPL("Download Service");
const base::FilePath::CharType kExtensionActivityLogFilename[] =
......
......@@ -47,6 +47,7 @@ extern const base::FilePath::CharType kChannelIDFilename[];
extern const base::FilePath::CharType kCookieFilename[];
extern const base::FilePath::CharType kCRLSetFilename[];
extern const base::FilePath::CharType kCustomDictionaryFileName[];
extern const base::FilePath::CharType kDownloadMetadataStoreFilename[];
extern const base::FilePath::CharType kDownloadServiceStorageDirname[];
extern const base::FilePath::CharType kExtensionActivityLogFilename[];
extern const base::FilePath::CharType kExtensionsCookieFilename[];
......
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
static_library("in_progress") {
sources = [
"download_entry.cc",
"download_entry.h",
"in_progress_cache.cc",
"in_progress_cache.h",
"in_progress_conversions.cc",
"in_progress_conversions.h",
]
deps = [
"//base",
"//components/download/downloader/in_progress/proto",
]
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/download/downloader/in_progress/download_entry.h"
namespace download {
DownloadEntry::DownloadEntry() = default;
DownloadEntry::DownloadEntry(const DownloadEntry& other) = default;
DownloadEntry::DownloadEntry(const std::string& guid,
const std::string& request_origin)
: guid(guid), request_origin(request_origin){};
DownloadEntry::~DownloadEntry() = default;
} // namespace download
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DOWNLOAD_IN_PROGRESS_DOWNLOAD_ENTRY_H_
#define COMPONENTS_DOWNLOAD_IN_PROGRESS_DOWNLOAD_ENTRY_H_
#include <string>
namespace download {
// Contains various in-progress information related to a download.
struct DownloadEntry {
public:
DownloadEntry();
DownloadEntry(const DownloadEntry& other);
DownloadEntry(const std::string& guid, const std::string& request_origin);
~DownloadEntry();
// A unique GUID that represents this download.
std::string guid;
// Represents the origin information for this download. Used by offline pages.
std::string request_origin;
};
} // namespace download
#endif // COMPONENTS_DOWNLOAD_IN_PROGRESS_DOWNLOAD_ENTRY_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/download/downloader/in_progress/in_progress_cache.h"
namespace download {
InProgressCache::InProgressCache(
const base::FilePath& cache_file_path,
const scoped_refptr<base::SequencedTaskRunner>& task_runner) {}
InProgressCache::~InProgressCache() = default;
void InProgressCache::AddOrReplaceEntry(const DownloadEntry& entry) {
// TODO(jming): Implementation.
}
DownloadEntry* InProgressCache::RetrieveEntry(const std::string& guid) {
// TODO(jming): Implementation.
return nullptr;
}
void InProgressCache::RemoveEntry(const std::string& guid) {
// TODO(jming): Implementation.
}
} // namespace download
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DOWNLOAD_IN_PROGRESS_CACHE_H_
#define COMPONENTS_DOWNLOAD_IN_PROGRESS_CACHE_H_
#include <string>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/sequenced_task_runner.h"
#include "components/download/downloader/in_progress/download_entry.h"
#include "components/download/downloader/in_progress/proto/download_entry.pb.h"
namespace download {
// InProgressCache provides a write-through cache that persists
// information related to an in-progress download such as request origin, retry
// count, resumption parameters etc to the disk. The entries are written to disk
// right away for now (might not be in the case in the long run).
class InProgressCache {
public:
InProgressCache(const base::FilePath& cache_file_path,
const scoped_refptr<base::SequencedTaskRunner>& task_runner);
~InProgressCache();
// Adds or updates an existing entry.
void AddOrReplaceEntry(const DownloadEntry& entry);
// Retrieves an existing entry.
DownloadEntry* RetrieveEntry(const std::string& guid);
// Removes an entry.
void RemoveEntry(const std::string& guid);
private:
DISALLOW_COPY_AND_ASSIGN(InProgressCache);
};
} // namespace download
#endif // COMPONENTS_DOWNLOAD_IN_PROGRESS_CACHE_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/download/downloader/in_progress/in_progress_conversions.h"
#include <utility>
// TODO(jming): Write unit tests for conversion methods.
namespace download {
DownloadEntry InProgressConversions::DownloadEntryFromProto(
const metadata_pb::DownloadEntry& proto) {
DownloadEntry entry;
entry.guid = proto.guid();
entry.request_origin = proto.request_origin();
return entry;
}
metadata_pb::DownloadEntry InProgressConversions::DownloadEntryToProto(
const DownloadEntry& entry) {
metadata_pb::DownloadEntry proto;
proto.set_guid(entry.guid);
proto.set_request_origin(entry.request_origin);
return proto;
}
std::vector<DownloadEntry> InProgressConversions::DownloadEntriesFromProto(
const metadata_pb::DownloadEntries& proto) {
std::vector<DownloadEntry> entries;
for (int i = 0; i < proto.entries_size(); i++)
entries.push_back(DownloadEntryFromProto(proto.entries(i)));
return entries;
}
metadata_pb::DownloadEntries InProgressConversions::DownloadEntriesToProto(
const std::vector<DownloadEntry>& entries) {
metadata_pb::DownloadEntries proto;
for (size_t i = 0; i < entries.size(); i++) {
metadata_pb::DownloadEntry* proto_entry = proto.add_entries();
*proto_entry = DownloadEntryToProto(entries[i]);
}
return proto;
}
} // namespace download
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DOWNLOAD_IN_PROGRESS_IN_PROGRESS_CONVERSIONS_H_
#define COMPONENTS_DOWNLOAD_IN_PROGRESS_IN_PROGRESS_CONVERSIONS_H_
#include "base/macros.h"
#include "components/download/downloader/in_progress/download_entry.h"
#include "components/download/downloader/in_progress/proto/download_entry.pb.h"
namespace download {
class InProgressConversions {
public:
static DownloadEntry DownloadEntryFromProto(
const metadata_pb::DownloadEntry& proto);
static metadata_pb::DownloadEntry DownloadEntryToProto(
const DownloadEntry& entry);
static std::vector<DownloadEntry> DownloadEntriesFromProto(
const metadata_pb::DownloadEntries& proto);
static metadata_pb::DownloadEntries DownloadEntriesToProto(
const std::vector<DownloadEntry>& entries);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(InProgressConversions);
};
} // namespace download
#endif // COMPONENTS_DOWNLOAD_IN_PROGRESS_IN_PROGRESS_CONVERSIONS_H_
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/protobuf/proto_library.gni")
proto_library("proto") {
visibility = [ "//components/download/downloader/in_progress:*" ]
sources = [
"download_entry.proto",
]
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package metadata_pb;
// Stores various in-progress metadata related to a download.
message DownloadEntry {
optional string guid = 1;
optional string request_origin = 2;
}
// Contains a list of entries.
message DownloadEntries {
repeated DownloadEntry entries = 1;
}
......@@ -40,6 +40,7 @@ source_set("browser") {
"//cc/paint",
"//components/discardable_memory/common",
"//components/discardable_memory/service",
"//components/download/downloader/in_progress",
"//components/filesystem:lib",
"//components/leveldb:lib",
"//components/link_header_util",
......
......@@ -3,6 +3,7 @@ include_rules = [
# See comment in content/DEPS for which components are allowed.
"+components/discardable_memory/common",
"+components/discardable_memory/service",
"+components/download/downloader/in_progress",
"+components/filesystem",
"+components/leveldb",
"+components/link_header_util",
......
......@@ -37,6 +37,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner_util.h"
#include "components/download/downloader/in_progress/in_progress_cache.h"
#include "content/browser/download/download_create_info.h"
#include "content/browser/download/download_file.h"
#include "content/browser/download/download_interrupt_reasons_impl.h"
......@@ -2282,6 +2283,16 @@ void DownloadItemImpl::ResumeInterruptedDownload(
download_params->set_hash_state(std::move(hash_state_));
download_params->set_fetch_error_body(fetch_error_body_);
auto* manager_delegate = GetBrowserContext()->GetDownloadManagerDelegate();
if (manager_delegate) {
download::InProgressCache* in_progress_cache =
manager_delegate->GetInProgressCache();
download::DownloadEntry* entry =
in_progress_cache->RetrieveEntry(GetGuid());
if (entry)
download_params->set_request_origin(entry->request_origin);
}
// Note that resumed downloads disallow redirects. Hence the referrer URL
// (which is the contents of the Referer header for the last download request)
// will only be sent to the URL returned by GetURL().
......
......@@ -22,6 +22,8 @@
#include "base/supports_user_data.h"
#include "base/synchronization/lock.h"
#include "build/build_config.h"
#include "components/download/downloader/in_progress/download_entry.h"
#include "components/download/downloader/in_progress/in_progress_cache.h"
#include "content/browser/byte_stream.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/download/download_create_info.h"
......@@ -279,6 +281,53 @@ base::FilePath GetTemporaryDownloadDirectory() {
} // namespace
// Responsible for persisting the in-progress metadata associated with a
// download.
class InProgressDownloadObserver : public DownloadItem::Observer {
public:
explicit InProgressDownloadObserver(
download::InProgressCache* in_progress_cache);
~InProgressDownloadObserver() override;
private:
// DownloadItem::Observer
void OnDownloadUpdated(DownloadItem* download) override;
void OnDownloadRemoved(DownloadItem* download) override;
// The persistent cache to store in-progress metadata.
download::InProgressCache* in_progress_cache_;
DISALLOW_COPY_AND_ASSIGN(InProgressDownloadObserver);
};
InProgressDownloadObserver::InProgressDownloadObserver(
download::InProgressCache* in_progress_cache)
: in_progress_cache_(in_progress_cache) {}
InProgressDownloadObserver::~InProgressDownloadObserver() = default;
void InProgressDownloadObserver::OnDownloadUpdated(DownloadItem* download) {
// TODO(crbug.com/778425): Properly handle fail/resume/retry for downloads
// that are in the INTERRUPTED state for a long time.
switch (download->GetState()) {
case DownloadItem::DownloadState::COMPLETE:
case DownloadItem::DownloadState::CANCELLED:
if (in_progress_cache_)
in_progress_cache_->RemoveEntry(download->GetGuid());
break;
case DownloadItem::DownloadState::IN_PROGRESS:
// TODO(crbug.com/778425): After RetrieveEntry has been implemented, do a
// check to make sure the entry exists in the cache.
break;
default:
break;
}
}
void InProgressDownloadObserver::OnDownloadRemoved(DownloadItem* download) {
in_progress_cache_->RemoveEntry(download->GetGuid());
}
DownloadManagerImpl::DownloadManagerImpl(BrowserContext* browser_context)
: item_factory_(new DownloadItemFactoryImpl()),
file_factory_(new DownloadFileFactory()),
......@@ -473,6 +522,16 @@ void DownloadManagerImpl::StartDownloadWithId(
}
#endif
if (delegate_) {
if (!in_progress_download_observer_) {
in_progress_download_observer_.reset(
new InProgressDownloadObserver(delegate_->GetInProgressCache()));
}
// May already observe this item, remove observer first.
download->RemoveObserver(in_progress_download_observer_.get());
download->AddObserver(in_progress_download_observer_.get());
}
std::unique_ptr<DownloadFile> download_file;
if (info->result == DOWNLOAD_INTERRUPT_REASON_NONE) {
......@@ -623,6 +682,7 @@ DownloadInterruptReason DownloadManagerImpl::BeginDownloadRequest(
int render_view_route_id,
int render_frame_route_id,
bool do_not_prompt_for_login) {
LOG(ERROR) << "BeginDownloadRequest";
if (ResourceDispatcherHostImpl::Get()->is_shutdown())
return DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN;
......@@ -860,6 +920,13 @@ void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
void DownloadManagerImpl::BeginDownloadInternal(
std::unique_ptr<content::DownloadUrlParameters> params,
uint32_t id) {
download::InProgressCache* in_progress_cache =
GetBrowserContext()->GetDownloadManagerDelegate()->GetInProgressCache();
if (in_progress_cache) {
in_progress_cache->AddOrReplaceEntry(download::DownloadEntry(
params.get()->guid(), params.get()->request_origin()));
}
if (base::FeatureList::IsEnabled(features::kNetworkService)) {
std::unique_ptr<ResourceRequest> request = CreateResourceRequest(
params.get());
......
......@@ -241,6 +241,9 @@ class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager,
// Observers that want to be notified of changes to the set of downloads.
base::ObserverList<Observer> observers_;
// Stores information about in-progress download items.
std::unique_ptr<DownloadItem::Observer> in_progress_download_observer_;
// The current active browser context.
BrowserContext* browser_context_;
......
......@@ -126,6 +126,10 @@ class MockDownloadItemFactory
// we don't keep dangling pointers.
void RemoveItem(int id);
// Sets |has_observer_calls_| to reflect whether we expect to add/remove
// observers during the CreateActiveItem.
void SetHasObserverCalls(bool observer_calls);
// Overridden methods from DownloadItemFactory.
DownloadItemImpl* CreatePersistedItem(
DownloadItemImplDelegate* delegate,
......@@ -168,11 +172,13 @@ class MockDownloadItemFactory
private:
std::map<uint32_t, MockDownloadItemImpl*> items_;
DownloadItemImplDelegate item_delegate_;
bool has_observer_calls_;
DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory);
};
MockDownloadItemFactory::MockDownloadItemFactory() {}
MockDownloadItemFactory::MockDownloadItemFactory()
: has_observer_calls_(false) {}
MockDownloadItemFactory::~MockDownloadItemFactory() {}
......@@ -198,6 +204,10 @@ void MockDownloadItemFactory::RemoveItem(int id) {
items_.erase(id);
}
void MockDownloadItemFactory::SetHasObserverCalls(bool has_observer_calls) {
has_observer_calls_ = has_observer_calls;
}
DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem(
DownloadItemImplDelegate* delegate,
const std::string& guid,
......@@ -253,6 +263,12 @@ DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem(
// the download.
EXPECT_CALL(*result, MockStart(_, _));
// In the StartDownload case, expect the remove/add observer calls.
if (has_observer_calls_) {
EXPECT_CALL(*result, RemoveObserver(_));
EXPECT_CALL(*result, AddObserver(_));
}
return result;
}
......@@ -501,6 +517,10 @@ class DownloadManagerTest : public testing::Test {
base::Unretained(this)));
}
void SetHasObserverCalls(bool has_observer_calls) {
mock_download_item_factory_->SetHasObserverCalls(has_observer_calls);
}
protected:
// Key test variable; we'll keep it available to sub-classes.
std::unique_ptr<DownloadManagerImpl> download_manager_;
......@@ -529,6 +549,8 @@ class DownloadManagerTest : public testing::Test {
// Confirm the appropriate invocations occur when you start a download.
TEST_F(DownloadManagerTest, StartDownload) {
SetHasObserverCalls(true);
std::unique_ptr<DownloadCreateInfo> info(new DownloadCreateInfo);
std::unique_ptr<ByteStreamReader> stream(new MockByteStreamReader);
uint32_t local_id(5); // Random value
......@@ -558,6 +580,8 @@ TEST_F(DownloadManagerTest, StartDownload) {
download_manager_->StartDownload(std::move(info), std::move(input_stream),
DownloadUrlParameters::OnStartedCallback());
EXPECT_TRUE(download_manager_->GetDownload(local_id));
SetHasObserverCalls(false);
}
// Confirm that calling DetermineDownloadTarget behaves properly if the delegate
......
......@@ -110,7 +110,6 @@ class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
// down.
virtual void OnDownloadDestroyed(DownloadItem* download) {}
protected:
virtual ~Observer() {}
};
......
......@@ -38,6 +38,10 @@ bool DownloadManagerDelegate::GenerateFileHash() {
return false;
}
download::InProgressCache* DownloadManagerDelegate::GetInProgressCache() {
return nullptr;
}
std::string
DownloadManagerDelegate::ApplicationClientIdForFileScanning() const {
return std::string();
......
......@@ -16,6 +16,10 @@
#include "content/public/browser/download_item.h"
#include "content/public/browser/save_page_type.h"
namespace download {
class InProgressCache;
} // namespace download
namespace content {
class BrowserContext;
......@@ -123,6 +127,9 @@ class CONTENT_EXPORT DownloadManagerDelegate {
base::FilePath* download_save_dir,
bool* skip_dir_check) {}
// Returns the metadata cache for in-progress downloads.
virtual download::InProgressCache* GetInProgressCache();
// Asks the user for the path to save a page. The delegate calls the callback
// to give the answer.
virtual void ChooseSavePath(
......@@ -163,7 +170,6 @@ class CONTENT_EXPORT DownloadManagerDelegate {
// This GUID is only used on Windows.
virtual std::string ApplicationClientIdForFileScanning() const;
protected:
virtual ~DownloadManagerDelegate();
};
......
......@@ -238,6 +238,12 @@ class CONTENT_EXPORT DownloadUrlParameters {
blob_data_handle_ = std::move(blob_data_handle);
}
// For downloads originating from custom tabs, this records the origin
// of the custom tab.
void set_request_origin(const std::string& origin) {
request_origin_ = origin;
}
const OnStartedCallback& callback() const { return callback_; }
bool content_initiated() const { return content_initiated_; }
const std::string& last_modified() const { return last_modified_; }
......@@ -250,6 +256,7 @@ class CONTENT_EXPORT DownloadUrlParameters {
const Referrer& referrer() const { return referrer_; }
const std::string& referrer_encoding() const { return referrer_encoding_; }
const base::Optional<url::Origin>& initiator() const { return initiator_; }
const std::string& request_origin() const { return request_origin_; }
// These will be -1 if the request is not associated with a frame. See
// the constructors for more.
......@@ -320,6 +327,7 @@ class CONTENT_EXPORT DownloadUrlParameters {
std::string guid_;
std::unique_ptr<storage::BlobDataHandle> blob_data_handle_;
const net::NetworkTrafficAnnotationTag traffic_annotation_;
std::string request_origin_;
DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters);
};
......
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