Commit 08c174f0 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download service: Support asynchronous BlobStorageContextGetter.

In reduced memory mode of Chrome, the browser context will be loaded
asynchronously, so we need to wait until the profile being created and
then retrieve the BlobStorageContextGetter from a Profile.

This CL creates an interface to retrieve the BlobStorageContextGetter
in a callback to download service.

TBR=peter@chromium.org

Bug:959208

Change-Id: I444f9836324428ed285ac67a135e14f6380babc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1591948Reviewed-by: default avatarXi Han <hanxi@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657318}
parent 993cb35c
......@@ -22,9 +22,11 @@
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/transition_manager/full_browser_transition_manager.h"
#include "chrome/common/chrome_constants.h"
#include "components/download/content/factory/download_service_factory_helper.h"
#include "components/download/content/factory/navigation_monitor_factory.h"
#include "components/download/public/background_service/blob_context_getter_factory.h"
#include "components/download/public/background_service/clients.h"
#include "components/download/public/background_service/download_service.h"
#include "components/download/public/background_service/features.h"
......@@ -62,6 +64,37 @@ std::unique_ptr<download::Client> CreatePluginVmImageDownloadClient(
}
#endif
// Called on profile created to retrieve the BlobStorageContextGetter.
void OnProfileCreated(download::BlobContextGetterCallback callback,
Profile* profile) {
auto blob_context_getter =
content::BrowserContext::GetBlobStorageContext(profile);
DCHECK(callback);
std::move(callback).Run(blob_context_getter);
}
// Provides BlobContextGetter from Chrome asynchronously.
class DownloadBlobContextGetterFactory
: public download::BlobContextGetterFactory {
public:
explicit DownloadBlobContextGetterFactory(ProfileKey* profile_key)
: profile_key_(profile_key) {
DCHECK(profile_key_);
}
~DownloadBlobContextGetterFactory() override = default;
private:
// download::BlobContextGetterFactory implementation.
void RetrieveBlobContextGetter(
download::BlobContextGetterCallback callback) override {
FullBrowserTransitionManager::Get()->RegisterCallbackOnProfileCreation(
profile_key_, base::BindOnce(&OnProfileCreated, std::move(callback)));
}
ProfileKey* profile_key_;
DISALLOW_COPY_AND_ASSIGN(DownloadBlobContextGetterFactory);
};
} // namespace
// static
......@@ -122,8 +155,9 @@ KeyedService* DownloadServiceFactory::BuildServiceInstanceFor(
// Build in memory download service for incognito profile.
if (context->IsOffTheRecord() &&
base::FeatureList::IsEnabled(download::kDownloadServiceIncognito)) {
content::BrowserContext::BlobContextGetter blob_context_getter =
content::BrowserContext::GetBlobStorageContext(context);
auto blob_context_getter_factory =
std::make_unique<DownloadBlobContextGetterFactory>(
profile->GetProfileKey());
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO});
......@@ -133,7 +167,8 @@ KeyedService* DownloadServiceFactory::BuildServiceInstanceFor(
return download::BuildInMemoryDownloadService(
profile->GetProfileKey(), std::move(clients),
content::GetNetworkConnectionTracker(), base::FilePath(),
blob_context_getter, io_task_runner, url_loader_factory);
std::move(blob_context_getter_factory), io_task_runner,
url_loader_factory);
} else {
// Build download service for normal profile.
base::FilePath storage_dir;
......
......@@ -135,14 +135,14 @@ DownloadService* BuildInMemoryDownloadService(
std::unique_ptr<DownloadClientMap> clients,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& storage_dir,
BlobTaskProxy::BlobContextGetter blob_context_getter,
BlobContextGetterFactoryPtr blob_context_getter_factory,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
auto config = Configuration::CreateFromFinch();
auto download_factory = std::make_unique<InMemoryDownloadFactory>(
url_loader_factory.get(), blob_context_getter, io_task_runner);
auto driver =
std::make_unique<InMemoryDownloadDriver>(std::move(download_factory));
url_loader_factory.get(), io_task_runner);
auto driver = std::make_unique<InMemoryDownloadDriver>(
std::move(download_factory), std::move(blob_context_getter_factory));
auto store = std::make_unique<NoopStore>();
auto task_scheduler = std::make_unique<EmptyTaskScheduler>();
......
......@@ -11,7 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "components/download/internal/background_service/blob_task_proxy.h"
#include "components/download/public/background_service/blob_context_getter_factory.h"
#include "components/download/public/background_service/clients.h"
class SimpleFactoryKey;
......@@ -55,7 +55,7 @@ DownloadService* BuildInMemoryDownloadService(
std::unique_ptr<DownloadClientMap> clients,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& storage_dir,
BlobTaskProxy::BlobContextGetter blob_context_getter,
BlobContextGetterFactoryPtr blob_context_getter_factory,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
......
......@@ -32,21 +32,19 @@ InMemoryDownloadImpl::InMemoryDownloadImpl(
const net::NetworkTrafficAnnotationTag& traffic_annotation,
Delegate* delegate,
network::mojom::URLLoaderFactory* url_loader_factory,
BlobTaskProxy::BlobContextGetter blob_context_getter,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
: InMemoryDownload(guid),
request_params_(request_params),
request_body_(std::move(request_body)),
traffic_annotation_(traffic_annotation),
url_loader_factory_(url_loader_factory),
blob_task_proxy_(
BlobTaskProxy::Create(blob_context_getter, io_task_runner)),
io_task_runner_(io_task_runner),
delegate_(delegate),
completion_notified_(false),
started_(false),
weak_ptr_factory_(this) {
DCHECK(!guid_.empty());
DCHECK(delegate_);
}
InMemoryDownloadImpl::~InMemoryDownloadImpl() {
......@@ -55,6 +53,17 @@ InMemoryDownloadImpl::~InMemoryDownloadImpl() {
void InMemoryDownloadImpl::Start() {
DCHECK(state_ == State::INITIAL) << "Only call Start() for new download.";
state_ = State::RETRIEVE_BLOB_CONTEXT;
delegate_->RetrieveBlobContextGetter(
base::BindOnce(&InMemoryDownloadImpl::OnRetrievedBlobContextGetter,
weak_ptr_factory_.GetWeakPtr()));
}
void InMemoryDownloadImpl::OnRetrievedBlobContextGetter(
BlobContextGetter blob_context_getter) {
DCHECK(state_ == State::RETRIEVE_BLOB_CONTEXT);
blob_task_proxy_ =
BlobTaskProxy::Create(blob_context_getter, io_task_runner_);
SendRequest();
state_ = State::IN_PROGRESS;
}
......@@ -69,7 +78,7 @@ void InMemoryDownloadImpl::Resume() {
switch (state_) {
case State::INITIAL:
NOTREACHED();
case State::RETRIEVE_BLOB_CONTEXT:
return;
case State::IN_PROGRESS:
// Let the network pipe continue to read data.
......@@ -115,8 +124,7 @@ void InMemoryDownloadImpl::OnDataReceived(base::StringPiece string_piece,
std::move(resume).Run();
// TODO(xingliu): Throttle the update frequency. See https://crbug.com/809674.
if (delegate_)
delegate_->OnDownloadProgress(this);
delegate_->OnDownloadProgress(this);
}
void InMemoryDownloadImpl::OnComplete(bool success) {
......@@ -183,8 +191,7 @@ void InMemoryDownloadImpl::NotifyDelegateDownloadComplete() {
return;
completion_notified_ = true;
if (delegate_)
delegate_->OnDownloadComplete(this);
delegate_->OnDownloadComplete(this);
}
void InMemoryDownloadImpl::SendRequest() {
......@@ -228,14 +235,12 @@ void InMemoryDownloadImpl::OnResponseStarted(
started_ = true;
response_headers_ = response_head.headers;
if (delegate_)
delegate_->OnDownloadStarted(this);
delegate_->OnDownloadStarted(this);
}
void InMemoryDownloadImpl::OnUploadProgress(uint64_t position, uint64_t total) {
bytes_uploaded_ = position;
if (delegate_)
delegate_->OnUploadProgress(this);
delegate_->OnUploadProgress(this);
}
void InMemoryDownloadImpl::Reset() {
......
......@@ -15,6 +15,7 @@
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "components/download/internal/background_service/blob_task_proxy.h"
#include "components/download/public/background_service/blob_context_getter_factory.h"
#include "components/download/public/background_service/download_params.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
......@@ -38,18 +39,23 @@ struct RequestParams;
// Used by download service in Incognito mode, where download files shouldn't
// be persisted to disk.
//
// Life cycle: The object is created before creating the network request.
// Call Start() to send the network request.
// Life cycle: The object is created before sending the network request.
// Call Start() to retrieve the blob storage context and send the network
// request.
class InMemoryDownload {
public:
// Report download progress with in-memory download backend.
class Delegate {
public:
// Report download progress with in-memory download backend.
virtual void OnDownloadStarted(InMemoryDownload* download) = 0;
virtual void OnDownloadProgress(InMemoryDownload* download) = 0;
virtual void OnDownloadComplete(InMemoryDownload* download) = 0;
virtual void OnUploadProgress(InMemoryDownload* download) = 0;
// Retrieves the blob storage context getter.
virtual void RetrieveBlobContextGetter(
BlobContextGetterCallback callback) = 0;
protected:
virtual ~Delegate() = default;
};
......@@ -69,12 +75,15 @@ class InMemoryDownload {
// States of the download.
enum class State {
// The object is created but network request has not been sent.
// The object is just created.
INITIAL,
// Waiting to retrieve BlobStorageContextGetter.
RETRIEVE_BLOB_CONTEXT,
// Download is in progress, including the following procedures.
// 1. Transfer network data.
// 2. Save to blob storage.
// 1. Send the network request and transfer data from network.
// 2. Save the data to blob storage.
IN_PROGRESS,
// The download can fail due to:
......@@ -161,7 +170,6 @@ class InMemoryDownloadImpl : public network::SimpleURLLoaderStreamConsumer,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
Delegate* delegate,
network::mojom::URLLoaderFactory* url_loader_factory,
BlobTaskProxy::BlobContextGetter blob_context_getter,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
~InMemoryDownloadImpl() override;
......@@ -172,6 +180,9 @@ class InMemoryDownloadImpl : public network::SimpleURLLoaderStreamConsumer,
void Pause() override;
void Resume() override;
// Called when the BlobStorageContextGetter is ready to use.
void OnRetrievedBlobContextGetter(BlobContextGetter blob_context_getter);
std::unique_ptr<storage::BlobDataHandle> ResultAsBlob() const override;
size_t EstimateMemoryUsage() const override;
......
......@@ -14,7 +14,7 @@ namespace {
DriverEntry::State ToDriverEntryState(InMemoryDownload::State state) {
switch (state) {
case InMemoryDownload::State::INITIAL:
return DriverEntry::State::IN_PROGRESS;
case InMemoryDownload::State::RETRIEVE_BLOB_CONTEXT:
case InMemoryDownload::State::IN_PROGRESS:
return DriverEntry::State::IN_PROGRESS;
case InMemoryDownload::State::FAILED:
......@@ -55,10 +55,8 @@ DriverEntry CreateDriverEntry(const InMemoryDownload& download) {
InMemoryDownloadFactory::InMemoryDownloadFactory(
network::mojom::URLLoaderFactory* url_loader_factory,
BlobTaskProxy::BlobContextGetter blob_context_getter,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
: url_loader_factory_(url_loader_factory),
blob_context_getter_(blob_context_getter),
io_task_runner_(io_task_runner) {}
InMemoryDownloadFactory::~InMemoryDownloadFactory() = default;
......@@ -72,12 +70,15 @@ std::unique_ptr<InMemoryDownload> InMemoryDownloadFactory::Create(
DCHECK(url_loader_factory_);
return std::make_unique<InMemoryDownloadImpl>(
guid, request_params, std::move(request_body), traffic_annotation,
delegate, url_loader_factory_, blob_context_getter_, io_task_runner_);
delegate, url_loader_factory_, io_task_runner_);
}
InMemoryDownloadDriver::InMemoryDownloadDriver(
std::unique_ptr<InMemoryDownload::Factory> download_factory)
: client_(nullptr), download_factory_(std::move(download_factory)) {}
std::unique_ptr<InMemoryDownload::Factory> download_factory,
BlobContextGetterFactoryPtr blob_context_getter_factory)
: client_(nullptr),
download_factory_(std::move(download_factory)),
blob_context_getter_factory_(std::move(blob_context_getter_factory)) {}
InMemoryDownloadDriver::~InMemoryDownloadDriver() = default;
......@@ -182,6 +183,7 @@ void InMemoryDownloadDriver::OnDownloadComplete(InMemoryDownload* download) {
// OnDownloadSucceeded.
return;
case InMemoryDownload::State::INITIAL:
case InMemoryDownload::State::RETRIEVE_BLOB_CONTEXT:
case InMemoryDownload::State::IN_PROGRESS:
NOTREACHED();
return;
......@@ -194,4 +196,9 @@ void InMemoryDownloadDriver::OnUploadProgress(InMemoryDownload* download) {
client_->OnUploadProgress(download->guid(), download->bytes_uploaded());
}
void InMemoryDownloadDriver::RetrieveBlobContextGetter(
BlobContextGetterCallback callback) {
blob_context_getter_factory_->RetrieveBlobContextGetter(std::move(callback));
}
} // namespace download
......@@ -24,7 +24,6 @@ class InMemoryDownloadFactory : public InMemoryDownload::Factory {
public:
InMemoryDownloadFactory(
network::mojom::URLLoaderFactory* url_loader_factory,
BlobTaskProxy::BlobContextGetter blob_context_getter,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
~InMemoryDownloadFactory() override;
......@@ -39,7 +38,6 @@ class InMemoryDownloadFactory : public InMemoryDownload::Factory {
network::mojom::URLLoaderFactory* url_loader_factory_;
BlobTaskProxy::BlobContextGetter blob_context_getter_;
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
DISALLOW_COPY_AND_ASSIGN(InMemoryDownloadFactory);
......@@ -50,8 +48,9 @@ class InMemoryDownloadFactory : public InMemoryDownload::Factory {
class InMemoryDownloadDriver : public DownloadDriver,
public InMemoryDownload::Delegate {
public:
explicit InMemoryDownloadDriver(
std::unique_ptr<InMemoryDownload::Factory> download_factory);
InMemoryDownloadDriver(
std::unique_ptr<InMemoryDownload::Factory> download_factory,
BlobContextGetterFactoryPtr blob_context_getter_factory);
~InMemoryDownloadDriver() override;
private:
......@@ -77,6 +76,7 @@ class InMemoryDownloadDriver : public DownloadDriver,
void OnDownloadProgress(InMemoryDownload* download) override;
void OnDownloadComplete(InMemoryDownload* download) override;
void OnUploadProgress(InMemoryDownload* download) override;
void RetrieveBlobContextGetter(BlobContextGetterCallback callback) override;
// The client that receives updates from low level download logic.
DownloadDriver::Client* client_;
......@@ -84,6 +84,9 @@ class InMemoryDownloadDriver : public DownloadDriver,
// The factory used to create in memory download objects.
std::unique_ptr<InMemoryDownload::Factory> download_factory_;
// Used to retrieve BlobStorageContextGetter.
BlobContextGetterFactoryPtr blob_context_getter_factory_;
// A map of GUID and in memory download, which holds download data.
std::map<std::string, std::unique_ptr<InMemoryDownload>> downloads_;
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "components/download/internal/background_service/test/mock_download_driver_client.h"
#include "components/download/public/background_service/blob_context_getter_factory.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "storage/browser/blob/blob_data_handle.h"
......@@ -23,6 +24,17 @@ MATCHER_P(DriverEntryEqual, entry, "") {
entry.bytes_downloaded == arg.bytes_downloaded;
}
// BlobContextGetterFactory implementation that does nothing.
class NoopBlobContextGetterFactory : public BlobContextGetterFactory {
public:
NoopBlobContextGetterFactory() = default;
~NoopBlobContextGetterFactory() override = default;
private:
void RetrieveBlobContextGetter(BlobContextGetterCallback callback) override {}
DISALLOW_COPY_AND_ASSIGN(NoopBlobContextGetterFactory);
};
// Test in memory download that doesn't do complex IO.
class TestInMemoryDownload : public InMemoryDownload {
public:
......@@ -106,7 +118,10 @@ class InMemoryDownloadDriverTest : public testing::Test {
void SetUp() override {
auto factory = std::make_unique<TestInMemoryDownloadFactory>();
factory_ = factory.get();
driver_ = std::make_unique<InMemoryDownloadDriver>(std::move(factory));
auto blob_context_getter_factory =
std::make_unique<NoopBlobContextGetterFactory>();
driver_ = std::make_unique<InMemoryDownloadDriver>(
std::move(factory), std::move(blob_context_getter_factory));
driver()->Initialize(&driver_client_);
}
......
......@@ -45,9 +45,17 @@ void SetValue(T* address, T value) {
*address = value;
}
// Must run on IO thread task runner.
base::WeakPtr<storage::BlobStorageContext> BlobStorageContextGetter(
storage::BlobStorageContext* blob_context) {
DCHECK(blob_context);
return blob_context->AsWeakPtr();
}
class MockDelegate : public InMemoryDownload::Delegate {
public:
MockDelegate() = default;
MockDelegate(BlobContextGetter blob_context_getter)
: blob_context_getter_(blob_context_getter) {}
void WaitForCompletion() {
DCHECK(!run_loop_.running());
......@@ -62,20 +70,18 @@ class MockDelegate : public InMemoryDownload::Delegate {
run_loop_.Quit();
}
MOCK_METHOD1(OnUploadProgress, void(InMemoryDownload*));
void RetrieveBlobContextGetter(
base::OnceCallback<void(BlobContextGetter)> callback) override {
std::move(callback).Run(blob_context_getter_);
}
private:
base::RunLoop run_loop_;
BlobContextGetter blob_context_getter_;
DISALLOW_COPY_AND_ASSIGN(MockDelegate);
};
// Must run on IO thread task runner.
base::WeakPtr<storage::BlobStorageContext> BlobStorageContextGetter(
storage::BlobStorageContext* blob_context) {
DCHECK(blob_context);
return blob_context->AsWeakPtr();
}
class InMemoryDownloadTest : public testing::Test {
public:
InMemoryDownloadTest() = default;
......@@ -94,6 +100,11 @@ class InMemoryDownloadTest : public testing::Test {
loop.Quit();
}));
loop.Run();
auto blob_storage_context_getter = base::BindRepeating(
&BlobStorageContextGetter, blob_storage_context_.get());
mock_delegate_ =
std::make_unique<NiceMock<MockDelegate>>(blob_storage_context_getter);
}
void TearDown() override {
......@@ -108,13 +119,11 @@ class InMemoryDownloadTest : public testing::Test {
download_ = std::make_unique<InMemoryDownloadImpl>(
base::GenerateGUID(), request_params, /* request_body= */ nullptr,
TRAFFIC_ANNOTATION_FOR_TESTS, delegate(), &url_loader_factory_,
base::BindRepeating(&BlobStorageContextGetter,
blob_storage_context_.get()),
io_thread_->task_runner());
}
InMemoryDownload* download() { return download_.get(); }
MockDelegate* delegate() { return &mock_delegate_; }
MockDelegate* delegate() { return mock_delegate_.get(); }
network::TestURLLoaderFactory* url_loader_factory() {
return &url_loader_factory_;
}
......@@ -166,7 +175,7 @@ class InMemoryDownloadTest : public testing::Test {
base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<InMemoryDownloadImpl> download_;
NiceMock<MockDelegate> mock_delegate_;
std::unique_ptr<NiceMock<MockDelegate>> mock_delegate_;
// Used by SimpleURLLoader network backend.
network::TestURLLoaderFactory url_loader_factory_;
......
......@@ -9,6 +9,7 @@ if (is_android) {
source_set("public") {
sources = [
"blob_context_getter_factory.h",
"client.cc",
"client.h",
"clients.h",
......
// Copyright 2019 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_PUBLIC_BACKGROUND_SERVICE_BLOB_CONTEXT_GETTER_FACTORY_H_
#define COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_BLOB_CONTEXT_GETTER_FACTORY_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
namespace storage {
class BlobStorageContext;
} // namespace storage
namespace download {
using BlobContextGetter =
base::RepeatingCallback<base::WeakPtr<storage::BlobStorageContext>()>;
using BlobContextGetterCallback = base::OnceCallback<void(BlobContextGetter)>;
// Retrieves a blob storage context getter on main thread.
class BlobContextGetterFactory {
public:
virtual void RetrieveBlobContextGetter(
BlobContextGetterCallback callback) = 0;
virtual ~BlobContextGetterFactory() = default;
protected:
BlobContextGetterFactory() = default;
private:
DISALLOW_COPY_AND_ASSIGN(BlobContextGetterFactory);
};
using BlobContextGetterFactoryPtr = std::unique_ptr<BlobContextGetterFactory>;
} // namespace download
#endif // COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_BLOB_CONTEXT_GETTER_FACTORY_H_
......@@ -4,6 +4,9 @@
#include "content/shell/browser/web_test/web_test_background_fetch_delegate.h"
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/file_path.h"
......@@ -12,6 +15,7 @@
#include "base/task/post_task.h"
#include "base/test/scoped_feature_list.h"
#include "components/download/content/factory/download_service_factory_helper.h"
#include "components/download/public/background_service/blob_context_getter_factory.h"
#include "components/download/public/background_service/clients.h"
#include "components/download/public/background_service/download_metadata.h"
#include "components/download/public/background_service/download_params.h"
......@@ -32,6 +36,26 @@
namespace content {
// Provides BlobContextGetter from a BrowserContext.
class TestBlobContextGetterFactory : public download::BlobContextGetterFactory {
public:
TestBlobContextGetterFactory(content::BrowserContext* browser_context)
: browser_context_(browser_context) {}
~TestBlobContextGetterFactory() override = default;
private:
// download::BlobContextGetterFactory implementation.
void RetrieveBlobContextGetter(
download::BlobContextGetterCallback callback) override {
auto blob_context_getter =
content::BrowserContext::GetBlobStorageContext(browser_context_);
std::move(callback).Run(blob_context_getter);
}
content::BrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(TestBlobContextGetterFactory);
};
// Implementation of a Download Service client that will be servicing
// Background Fetch requests when running web tests.
class WebTestBackgroundFetchDelegate::WebTestBackgroundFetchDownloadClient
......@@ -256,7 +280,7 @@ void WebTestBackgroundFetchDelegate::CreateDownloadJob(
base::WrapUnique(download::BuildInMemoryDownloadService(
simple_key, std::move(clients), GetNetworkConnectionTracker(),
base::FilePath(),
BrowserContext::GetBlobStorageContext(browser_context_),
std::make_unique<TestBlobContextGetterFactory>(browser_context_),
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
url_loader_factory));
}
......
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