Commit 50039cd3 authored by tzik's avatar tzik Committed by Commit Bot

Avoid touching extensions::ContentVerifyJob's ref count before it's fully constructed

extensions::ContentVerifyJob is ref counted, and its first reference may
be implicitly created in ContentVerifyJob::Start through base::BindOnce.
However, after an upcoming change to base::Bind, it starts rejecting to
make the implicit first reference to a ref-counted object, as this is
an error prone pattern.

This CL updates callers of ContentVerifyJob::Start to hold to hold the
first reference, before Start() is called.

Bug: 866456
Change-Id: Ib3a70973ac789f60a75e636db03f4e4d66e12603
Reviewed-on: https://chromium-review.googlesource.com/1156704Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579653}
parent ee5b9bf7
......@@ -196,7 +196,7 @@ class URLRequestExtensionJob : public net::URLRequestFileJob {
const std::string& content_security_policy,
bool send_cors_header,
bool follow_symlinks_anywhere,
ContentVerifyJob* verify_job)
scoped_refptr<ContentVerifyJob> verify_job)
: net::URLRequestFileJob(
request,
network_delegate,
......@@ -204,7 +204,7 @@ class URLRequestExtensionJob : public net::URLRequestFileJob {
base::CreateTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})),
verify_job_(verify_job),
verify_job_(std::move(verify_job)),
seek_position_(0),
bytes_read_(0),
directory_path_(directory_path),
......@@ -643,7 +643,7 @@ ExtensionProtocolHandler::MaybeCreateJob(
if (g_test_handler)
g_test_handler->Run(&directory_path, &relative_path);
ContentVerifyJob* verify_job = nullptr;
scoped_refptr<ContentVerifyJob> verify_job;
ContentVerifier* verifier = extension_info_map_->content_verifier();
if (verifier) {
verify_job =
......@@ -652,15 +652,10 @@ ExtensionProtocolHandler::MaybeCreateJob(
verify_job->Start(verifier);
}
return new URLRequestExtensionJob(request,
network_delegate,
extension_id,
directory_path,
relative_path,
content_security_policy,
send_cors_header,
follow_symlinks_anywhere,
verify_job);
return new URLRequestExtensionJob(
request, network_delegate, extension_id, directory_path, relative_path,
content_security_policy, send_cors_header, follow_symlinks_anywhere,
std::move(verify_job));
}
bool ExtensionProtocolHandler::IsSafeRedirectTarget(
......@@ -962,7 +957,7 @@ class ExtensionURLLoaderFactory : public network::mojom::URLLoaderFactory {
scoped_refptr<ContentVerifier> content_verifier,
const ExtensionResource& resource,
scoped_refptr<net::HttpResponseHeaders> response_headers) {
ContentVerifyJob* verify_job = nullptr;
scoped_refptr<ContentVerifyJob> verify_job;
if (content_verifier) {
verify_job = content_verifier->CreateJobFor(resource.extension_id(),
resource.extension_root(),
......@@ -973,7 +968,7 @@ class ExtensionURLLoaderFactory : public network::mojom::URLLoaderFactory {
content::CreateFileURLLoader(
request, std::move(loader), std::move(client),
std::make_unique<FileLoaderObserver>(verify_job),
std::make_unique<FileLoaderObserver>(std::move(verify_job)),
std::move(response_headers));
}
......
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