Commit f0285cde authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Reland "Migrate ContentHashFetcher to SimpleURLLoader"

This is a reland of 27f8891c

The main difference from the original CL is that instead of passing raw
network::mojom::URLLoaderFactory pointers, this CL takes a more conservative
approach where a thread-agnostic network::mojom::URLLoaderFactoryPtrInfo instance
is passed through ContentHash::FetchParams, which allows us to "bind" the
network::URLLoaderFactoryPtr instance only when it is actually going to be used
(in ContentHashFetcher::Start).

Also, differently than the original/reverted CL, this CL does not change
the threads ContentHash methods run on.

Last, in order to adapt ContentVerifierHashTest, we:

1) Replace the use of net::TestURLRequestInterceptor by content::URLLoaderInterceptor.
2) Install the interceptor at the beginning of each test execution flow, so
that it is able to intercept all relevant URLLoaderFactory creation requests.

Some other minor differences, were because of some preparation CLs already landed,
eg https://crrev.com/c/1089273.

Original change's description:
> Migrate ContentHashFetcher to SimpleURLLoader
>
> This CL migrates ContentHashFetcher away from URLRequestFetcher to
> SimpleURLLoader.
>
> In order to accomplish this, a few other related changes are also performed:
>
> 1) The regular flow of the code is ContentVerifier -> ContentHash ->
>    ContentHashFetcher. In ContentVerifier, for instance, UI, IO and
>    "File tasks" threads take place.
>    Previously, the URLRequestFetcher logic residing in ContentHashFetcher
>    executed in the "file tasks" thread.
>
>    As part of the migration from URLRequestFetcher to SimpleURLLoader
>    machinery, this CL also changes the ContentHashFetcher logic to
>    execute to the IO thread.
>    Note that it could be possible to keep the new SimpleURLLoader logic
>    in the "file tasks" thread. However, this would impose a way bigger change,
>    and require unittests to be considerably rewritten as well (see for
>    patchsets 7, 8 and 9.
>    The issue is that mojo objects are not thread safe. We could create a new
>    URLLoaderFactory for the extensions thread, but then we'd need to create a
>    new one when the network service crashes (Something this SharedURLLoaderFactory
>    one, already bound to the IOThread, magically handles), but that would be
>    significantly more complicated.
>
> 2) content_verifier_hash_fetch_behavior_browsertest.cc was changed
>    to support running with the network service feature both enabled
>    and disabled. This is a pattern that is also present in various other
>    unittests.
>
> In summary, the migration to use SimpleURLLoader performed here includes
> also a change in the thread that ContentHashFetcher runs on, but no
> functionality change is expected from this CL.
>
> BUG=773295,844926
>
> Change-Id: If570f69d01ff75ac59d8d043f8687621336dddcf
> Reviewed-on: https://chromium-review.googlesource.com/1056587
> Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
> Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
> Reviewed-by: Matt Menke <mmenke@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#561480}

Bug: 773295, 844926
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ie2f3665bcca5378ff67bf78bec38bdc225ff6c26
Reviewed-on: https://chromium-review.googlesource.com/1076947
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568178}
parent f988ce79
......@@ -6,12 +6,14 @@
#include <string>
#include "base/macros.h"
#include "base/test/bind_test_util.h"
#include "chrome/browser/extensions/browsertest_util.h"
#include "chrome/browser/extensions/chrome_content_verifier_delegate.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/url_loader_interceptor.h"
#include "extensions/browser/computed_hashes.h"
#include "extensions/browser/content_verifier/test_utils.h"
#include "extensions/browser/extension_file_task_runner.h"
......@@ -19,7 +21,7 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/file_util.h"
#include "net/url_request/test_url_request_interceptor.h"
#include "services/network/public/cpp/features.h"
namespace extensions {
......@@ -70,6 +72,11 @@ class ContentVerifierHashTest
ChromeContentVerifierDelegate::SetDefaultModeForTesting(base::nullopt);
}
void TearDownOnMainThread() override {
url_loader_interceptor_.reset();
ExtensionBrowserTest::TearDownOnMainThread();
}
bool uses_enforce_strict_mode() {
return GetParam() == ContentVerificationMode::kEnforceStrict;
}
......@@ -190,12 +197,6 @@ class ContentVerifierHashTest
Result::SUCCESS);
}
if (interceptor_) {
EXPECT_EQ(0, interceptor_->GetHitCount()) << "Interceptor should not "
"have seen any requests "
"before enabling extension.";
}
TestExtensionRegistryObserver registry_observer(
ExtensionRegistry::Get(profile()), id());
VerifierObserver verifier_observer;
......@@ -316,37 +317,14 @@ class ContentVerifierHashTest
return true;
}
bool AddInterceptor() {
if (interceptor_) {
ADD_FAILURE() << "Already created interceptor.";
return false;
}
// Use stored copy of verified_contents.json as hash fetch response.
base::FilePath copied_verified_contents_path;
if (!CopyVerifiedContents(&copied_verified_contents_path)) {
ADD_FAILURE() << "Could not copy verified_contents.json.";
return false;
}
ExtensionSystem* system = ExtensionSystem::Get(profile());
GURL fetch_url = system->content_verifier()->GetSignatureFetchUrlForTest(
id(), info_->version);
// Mock serving |copied_verified_contents_path| for content hash, so that
// hash fetch succeeds.
interceptor_ = std::make_unique<net::TestURLRequestInterceptor>(
fetch_url.scheme(), fetch_url.host(),
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO),
GetExtensionFileTaskRunner());
interceptor_->SetResponse(fetch_url, copied_verified_contents_path);
return true;
}
// Installs test extension that is copied from the webstore with actual
// signatures.
testing::AssertionResult InstallExtension(ExtensionType type) {
// Install the interceptor at the very beginning of the tests' execution
// flow, so that it catches all URLLoaderFactory creations.
if (!hash_fetching_disabled_ && !InstallInterceptor())
return testing::AssertionFailure() << "Failed to install interceptor.";
// This observer will make sure content hash read and computed_hashes.json
// writing is complete before we proceed.
VerifierObserver verifier_observer;
......@@ -370,16 +348,60 @@ class ContentVerifierHashTest
info_ = std::make_unique<ExtensionInfo>(extension, type);
// Interceptor.
if (!hash_fetching_disabled_ && !AddInterceptor())
// Set up the data needed by the interceptor functor.
if (!hash_fetching_disabled_ && !SetUpInterceptorData())
return testing::AssertionFailure() << "Failed to install interceptor.";
return testing::AssertionSuccess();
}
std::unique_ptr<net::TestURLRequestInterceptor> interceptor_;
bool InstallInterceptor() {
if (url_loader_interceptor_) {
testing::AssertionFailure() << "Already created interceptor.";
return false;
}
auto interceptor_function =
[](GURL* fetch_url, base::FilePath* file_path,
content::URLLoaderInterceptor::RequestParams* params) {
GURL url = params->url_request.url;
if (url == *fetch_url) {
base::ScopedAllowBlockingForTesting allow_io;
std::string contents;
CHECK(base::ReadFileToString(*file_path, &contents));
content::URLLoaderInterceptor::WriteResponse(
std::string(), contents, params->client.get());
return true;
}
return false;
};
url_loader_interceptor_ = std::make_unique<content::URLLoaderInterceptor>(
base::BindRepeating(interceptor_function, &fetch_url_,
&copied_verified_contents_path_));
return true;
}
bool SetUpInterceptorData() {
// Use stored copy of verified_contents.json as hash fetch response.
if (!CopyVerifiedContents(&copied_verified_contents_path_)) {
ADD_FAILURE() << "Could not copy verified_contents.json.";
return false;
}
ExtensionSystem* system = ExtensionSystem::Get(profile());
fetch_url_ = system->content_verifier()->GetSignatureFetchUrlForTest(
id(), info_->version);
return true;
}
std::unique_ptr<content::URLLoaderInterceptor> url_loader_interceptor_;
base::ScopedTempDir temp_dir_;
base::FilePath copied_verified_contents_path_;
GURL fetch_url_;
// Information about the loaded extension.
std::unique_ptr<ExtensionInfo> info_;
......
......@@ -643,6 +643,7 @@ source_set("unit_tests") {
"//services/data_decoder:lib",
"//services/data_decoder/public/cpp:test_support",
"//services/device/public/mojom",
"//services/network:test_support",
"//services/service_manager/public/cpp/test:test_support",
"//storage/browser:test_support",
"//third_party/leveldatabase",
......
......@@ -27,6 +27,7 @@ include_rules = [
"+services/data_decoder/public",
"+services/network/public/cpp",
"+services/network/public/mojom",
"+services/network",
"+services/preferences/public/cpp",
"+services/service_manager/public/cpp",
"+skia/ext/image_operations.h",
......
......@@ -25,8 +25,8 @@
#include "extensions/common/file_util.h"
#include "net/base/load_flags.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
namespace extensions {
......@@ -38,22 +38,16 @@ ContentHashFetcher::ContentHashFetcher(const ContentHash::ExtensionKey& key,
fetch_params_(std::move(fetch_params)),
response_task_runner_(base::SequencedTaskRunnerHandle::Get()) {}
void ContentHashFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
void ContentHashFetcher::OnSimpleLoaderComplete(
std::unique_ptr<std::string> response_body) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
VLOG(1) << "URLFetchComplete for " << extension_key_.extension_id
<< " is_success:" << url_fetcher_->GetStatus().is_success() << " "
<< " is_success:" << !!response_body << " "
<< fetch_params_.fetch_url.possibly_invalid_spec();
DCHECK(hash_fetcher_callback_);
std::unique_ptr<net::URLFetcher> url_fetcher = std::move(url_fetcher_);
std::unique_ptr<std::string> response(new std::string);
if (!url_fetcher->GetStatus().is_success() ||
!url_fetcher->GetResponseAsString(response.get())) {
// Failed.
response = nullptr;
}
response_task_runner_->PostTask(
FROM_HERE, base::BindOnce(std::move(hash_fetcher_callback_),
extension_key_, std::move(response)));
extension_key_, std::move(response_body)));
delete this;
}
......@@ -86,14 +80,26 @@ void ContentHashFetcher::Start(HashFetcherCallback hash_fetcher_callback) {
"the Web Store, this feature is required to ensure the "
"extensions match what is distributed by the store."
})");
url_fetcher_ = net::URLFetcher::Create(
fetch_params_.fetch_url, net::URLFetcher::GET, this, traffic_annotation);
url_fetcher_->SetRequestContext(fetch_params_.request_context);
url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES |
net::LOAD_DISABLE_CACHE);
url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3);
url_fetcher_->Start();
auto resource_request = std::make_unique<network::ResourceRequest>();
resource_request->url = fetch_params_.fetch_url;
resource_request->load_flags = net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES |
net::LOAD_DISABLE_CACHE;
network::mojom::URLLoaderFactoryPtr url_loader_factory_ptr;
url_loader_factory_ptr.Bind(
std::move(fetch_params_.url_loader_factory_ptr_info));
simple_loader_ = network::SimpleURLLoader::Create(std::move(resource_request),
traffic_annotation);
const int kMaxRetries = 3;
simple_loader_->SetRetryOptions(
kMaxRetries,
network::SimpleURLLoader::RetryMode::RETRY_ON_NETWORK_CHANGE);
simple_loader_->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
url_loader_factory_ptr.get(),
base::BindOnce(&ContentHashFetcher::OnSimpleLoaderComplete,
base::Unretained(this)));
}
ContentHashFetcher::~ContentHashFetcher() {
......
......@@ -16,15 +16,14 @@
#include "base/memory/weak_ptr.h"
#include "extensions/browser/content_verifier/content_hash.h"
#include "extensions/common/extension_id.h"
#include "net/url_request/url_fetcher_delegate.h"
namespace base {
class SequencedTaskRunner;
}
namespace net {
class URLFetcher;
}
namespace network {
class SimpleURLLoader;
} // namespace network
namespace extensions {
namespace internals {
......@@ -36,13 +35,13 @@ namespace internals {
// have the contents of verified_contents.json files from the webstore.
//
// Note: This class manages its own lifetime. It deletes itself when
// Start() completes at OnURLFetchComplete().
// Start() completes at OnSimpleLoaderComplete().
//
// Note: This class is an internal implementation detail of ContentHash and is
// not be used independently.
// TODO(lazyboy): Consider changing BUILD rules to enforce the above, yet
// keeping the class unit testable.
class ContentHashFetcher : public net::URLFetcherDelegate {
class ContentHashFetcher {
public:
// A callback for when fetch is complete.
// The response contents is passed through std::unique_ptr<std::string>.
......@@ -53,16 +52,15 @@ class ContentHashFetcher : public net::URLFetcherDelegate {
ContentHashFetcher(const ContentHash::ExtensionKey& extension_key,
ContentHash::FetchParams fetch_params);
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
// Note: |this| is deleted once OnURLFetchComplete() completes.
// Note: |this| is deleted once OnSimpleLoaderComplete() completes.
void Start(HashFetcherCallback hash_fetcher_callback);
private:
friend class base::RefCounted<ContentHashFetcher>;
~ContentHashFetcher() override;
~ContentHashFetcher();
void OnSimpleLoaderComplete(std::unique_ptr<std::string> response_body);
ContentHash::ExtensionKey extension_key_;
ContentHash::FetchParams fetch_params_;
......@@ -72,7 +70,7 @@ class ContentHashFetcher : public net::URLFetcherDelegate {
scoped_refptr<base::SequencedTaskRunner> response_task_runner_;
// Alive when url fetch is ongoing.
std::unique_ptr<net::URLFetcher> url_fetcher_;
std::unique_ptr<network::SimpleURLLoader> simple_loader_;
SEQUENCE_CHECKER(sequence_checker_);
......
......@@ -23,9 +23,12 @@
#include "extensions/common/constants.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/file_util.h"
#include "net/url_request/test_url_request_interceptor.h"
#include "net/url_request/url_request_interceptor.h"
#include "net/url_request/url_request_test_util.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/zlib/google/zip.h"
......@@ -92,18 +95,33 @@ class ContentHashWaiter {
DISALLOW_COPY_AND_ASSIGN(ContentHashWaiter);
};
// Custom network::TestURLLoaderFactory that re-implements ::Clone.
class ClonableTestURLLoaderFactory : public network::TestURLLoaderFactory {
public:
ClonableTestURLLoaderFactory() = default;
~ClonableTestURLLoaderFactory() override = default;
void Clone(network::mojom::URLLoaderFactoryRequest request) override {
bindings_.AddBinding(this, std::move(request));
}
private:
mojo::BindingSet<network::mojom::URLLoaderFactory> bindings_;
DISALLOW_COPY_AND_ASSIGN(ClonableTestURLLoaderFactory);
};
// Installs and tests various functionality of an extension loaded without
// verified_contents.json file.
class ContentHashFetcherTest : public ExtensionsTest {
public:
ContentHashFetcherTest()
// We need a real IO thread to be able to intercept the network request
// We need a real IO thread to be able to entercept the network request
// for the missing verified_contents.json file.
: ExtensionsTest(content::TestBrowserThreadBundle::REAL_IO_THREAD) {
request_context_ = new net::TestURLRequestContextGetter(
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO));
}
: ExtensionsTest(content::TestBrowserThreadBundle::REAL_IO_THREAD),
test_shared_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_)) {}
~ContentHashFetcherTest() override {}
bool LoadTestExtension() {
......@@ -134,12 +152,18 @@ class ContentHashFetcherTest : public ExtensionsTest {
return nullptr;
}
network::mojom::URLLoaderFactoryPtr url_loader_factory_ptr;
test_url_loader_factory_.Clone(mojo::MakeRequest(&url_loader_factory_ptr));
network::mojom::URLLoaderFactoryPtrInfo url_loader_factory_ptr_info =
url_loader_factory_ptr.PassInterface();
std::unique_ptr<ContentHashFetcherResult> result =
ContentHashWaiter().CreateAndWaitForCallback(
ContentHash::ExtensionKey(extension_->id(), extension_->path(),
extension_->version(),
delegate_->GetPublicKey()),
ContentHash::FetchParams(request_context(), fetch_url_));
ContentHash::FetchParams(std::move(url_loader_factory_ptr_info),
fetch_url_));
delegate_.reset();
......@@ -164,20 +188,20 @@ class ContentHashFetcherTest : public ExtensionsTest {
void RegisterInterception(const GURL& url,
const base::FilePath& response_path) {
ASSERT_TRUE(base::PathExists(response_path));
ASSERT_FALSE(interceptor_);
interceptor_ = std::make_unique<net::TestURLRequestInterceptor>(
url.scheme(), url.host(),
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO),
GetExtensionFileTaskRunner());
interceptor_->SetResponse(url, response_path);
std::string data;
EXPECT_TRUE(ReadFileToString(response_path, &data));
constexpr size_t kMaxFileSize = 1024 * 2; // Using 2k file size for safety.
ASSERT_LE(data.length(), kMaxFileSize);
test_url_loader_factory_.AddResponse(url.spec(), data);
}
private:
net::URLRequestContextGetter* request_context() {
return request_context_.get();
void RegisterInterceptionWithFailure(const GURL& url, int net_error) {
test_url_loader_factory_.AddResponse(
GURL(url), network::ResourceResponseHead(), std::string(),
network::URLLoaderCompletionStatus(net_error));
}
private:
// Helper to get files from our subdirectory in the general extensions test
// data dir.
base::FilePath GetTestPath(const base::FilePath& relative_path) {
......@@ -202,8 +226,9 @@ class ContentHashFetcherTest : public ExtensionsTest {
return extension;
}
std::unique_ptr<net::TestURLRequestInterceptor> interceptor_;
scoped_refptr<net::TestURLRequestContextGetter> request_context_;
scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_;
ClonableTestURLLoaderFactory test_url_loader_factory_;
base::ScopedTempDir temp_dir_;
GURL fetch_url_;
......@@ -264,7 +289,7 @@ TEST_F(ContentHashFetcherTest, FetchInvalidVerifiedContents) {
TEST_F(ContentHashFetcherTest, Fetch404VerifiedContents) {
ASSERT_TRUE(LoadTestExtension());
// NOTE: No RegisterInterception(), hash fetch will result in 404.
RegisterInterceptionWithFailure(fetch_url(), net::HTTP_NOT_FOUND);
// Make sure the fetch was *not* successful.
std::unique_ptr<ContentHashFetcherResult> result = DoHashFetch();
......
......@@ -27,6 +27,7 @@
#include "extensions/common/file_util.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/manifest_handlers/content_scripts_handler.h"
#include "services/network/public/mojom/network_context.mojom.h"
namespace extensions {
......@@ -364,9 +365,6 @@ ContentVerifier::ContentVerifier(
std::unique_ptr<ContentVerifierDelegate> delegate)
: context_(context),
delegate_(std::move(delegate)),
request_context_getter_(
content::BrowserContext::GetDefaultStoragePartition(context)
->GetURLRequestContext()),
observer_(this),
io_data_(new ContentVerifierIOData) {}
......@@ -579,11 +577,37 @@ void ContentVerifier::OnFetchComplete(
ContentHash::FetchParams ContentVerifier::GetFetchParams(
const ExtensionId& extension_id,
const base::Version& extension_version) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// Create a new mojo pipe. It's safe to pass this around and use immediately,
// even though it needs to finish initialization on the UI thread.
network::mojom::URLLoaderFactoryPtr url_loader_factory_ptr;
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::BindOnce(&ContentVerifier::BindURLLoaderFactoryRequestOnUIThread,
this, mojo::MakeRequest(&url_loader_factory_ptr)));
network::mojom::URLLoaderFactoryPtrInfo url_loader_factory_info =
url_loader_factory_ptr.PassInterface();
return ContentHash::FetchParams(
request_context_getter_,
std::move(url_loader_factory_info),
delegate_->GetSignatureFetchUrl(extension_id, extension_version));
}
void ContentVerifier::BindURLLoaderFactoryRequestOnUIThread(
network::mojom::URLLoaderFactoryRequest url_loader_factory_request) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (shutdown_on_ui_)
return;
network::mojom::URLLoaderFactoryParamsPtr params =
network::mojom::URLLoaderFactoryParams::New();
params->process_id = network::mojom::kBrowserProcessId;
params->is_corb_enabled = false;
content::BrowserContext::GetDefaultStoragePartition(context_)
->GetURLLoaderFactoryForBrowserProcess()
->Clone(std::move(url_loader_factory_request));
}
bool ContentVerifier::ShouldVerifyAnyPaths(
const std::string& extension_id,
const base::FilePath& extension_root,
......
......@@ -19,6 +19,7 @@
#include "extensions/browser/content_verifier_io_data.h"
#include "extensions/browser/content_verify_job.h"
#include "extensions/browser/extension_registry_observer.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace base {
class FilePath;
......@@ -28,10 +29,6 @@ namespace content {
class BrowserContext;
}
namespace net {
class URLRequestContextGetter;
}
namespace extensions {
class Extension;
......@@ -120,6 +117,10 @@ class ContentVerifier : public base::RefCountedThreadSafe<ContentVerifier>,
const ExtensionId& extension_id,
const base::Version& extension_version);
// Binds an URLLoaderFactoryRequest on the UI thread.
void BindURLLoaderFactoryRequestOnUIThread(
network::mojom::URLLoaderFactoryRequest url_loader_factory_request);
// Performs IO thread operations after extension load.
void OnExtensionLoadedOnIO(
const ExtensionId& extension_id,
......@@ -163,9 +164,6 @@ class ContentVerifier : public base::RefCountedThreadSafe<ContentVerifier>,
std::unique_ptr<ContentVerifierDelegate> delegate_;
// Used by ContentHashFetcher.
net::URLRequestContextGetter* request_context_getter_;
// For observing the ExtensionRegistry.
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> observer_;
......
......@@ -20,6 +20,7 @@
#include "extensions/common/file_util.h"
#include "net/base/load_flags.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace extensions {
......@@ -79,9 +80,10 @@ ContentHash::ExtensionKey& ContentHash::ExtensionKey::operator=(
const ContentHash::ExtensionKey& other) = default;
ContentHash::FetchParams::FetchParams(
net::URLRequestContextGetter* request_context,
network::mojom::URLLoaderFactoryPtrInfo url_loader_factory_ptr_info,
const GURL& fetch_url)
: request_context(request_context), fetch_url(fetch_url) {}
: url_loader_factory_ptr_info(std::move(url_loader_factory_ptr_info)),
fetch_url(fetch_url) {}
ContentHash::FetchParams::~FetchParams() = default;
ContentHash::FetchParams::FetchParams(FetchParams&&) = default;
ContentHash::FetchParams& ContentHash::FetchParams::operator=(FetchParams&&) =
......
......@@ -15,12 +15,9 @@
#include "extensions/browser/verified_contents.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_id.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "url/gurl.h"
namespace net {
class URLRequestContextGetter;
}
namespace extensions {
// Represents content verification hashes for an extension.
......@@ -71,13 +68,14 @@ class ContentHash : public base::RefCountedThreadSafe<ContentHash> {
// Parameters to fetch verified_contents.json.
struct FetchParams {
FetchParams(net::URLRequestContextGetter* request_context,
const GURL& fetch_url);
FetchParams(
network::mojom::URLLoaderFactoryPtrInfo url_loader_factory_ptr_info,
const GURL& fetch_url);
~FetchParams();
FetchParams(FetchParams&&);
FetchParams& operator=(FetchParams&&);
net::URLRequestContextGetter* request_context;
network::mojom::URLLoaderFactoryPtrInfo url_loader_factory_ptr_info;
GURL fetch_url;
};
......
......@@ -390,29 +390,6 @@
-NativeBindings/ExternallyConnectableMessagingTest.WebConnectableWithNonEmptyTlsChannelId/0
-NativeBindings/MessagingApiTest.DifferentStoragePartitionTLSChannelID/0
# ContentHastVerifier needs to be switched to SimpleURLLoader
# https://crbug.com/844926
-FetchBehaviorTests/ContentVerifierHashTest.DefaultRequestExtensionTamperNotRequestedResourceDeleteComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.DefaultRequestExtensionTamperNotRequestedResourceDeleteComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.DefaultRequestExtensionTamperNotRequestedResourceKeepComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.DefaultRequestExtensionTamperNotRequestedResourceKeepComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.DefaultRequestExtensionTamperNotRequestedResourceTamperComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.DefaultRequestExtensionTamperNotRequestedResourceTamperComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.TamperNoResourceExtensionDeleteComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.TamperNoResourceExtensionDeleteComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.TamperNoResourceExtensionKeepComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.TamperNoResourceExtensionKeepComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.TamperNoResourceExtensionTamperComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.TamperNoResourceExtensionTamperComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.TamperNotRequestedResourceKeepComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.TamperNotRequestedResourceKeepComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.TamperRequestedResourceDeleteComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.TamperRequestedResourceDeleteComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.TamperRequestedResourceKeepComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.TamperRequestedResourceKeepComputedHashes/1
-FetchBehaviorTests/ContentVerifierHashTest.TamperRequestedResourceTamperComputedHashes/0
-FetchBehaviorTests/ContentVerifierHashTest.TamperRequestedResourceTamperComputedHashes/1
# https://crbug.com/846339: CORB: Don't block requests from plugins.
-OutOfProcessPPAPITest.URLLoaderTrusted
......
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