Commit 7f6d6b4a authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Specialize a duplicate RunOrPostTaskIfNecessary method

Two RunOrPostTaskIfNecessary methods, one in
content/browser/web_package/signed_exchange_devtools_proxy.cc and
one in content/browser/loader/navigation_url_loader_impl.cc,
clash in some extreme (non-default) jumbo builds.

This CL makes one of them more specialized since it was always
called with the same argument, and changes its name.

Bug: 824854
Change-Id: I65f1270ca826235596a846dec935a8ea9b7f624b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713515
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Auto-Submit: Daniel Bratell <bratell@opera.com>
Reviewed-by: default avatarTsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680291}
parent c597c5d5
...@@ -21,17 +21,16 @@ namespace content { ...@@ -21,17 +21,16 @@ namespace content {
namespace { namespace {
// Runs |task| on the thread specified by |thread_id| if already on that thread, // If on the UI thread, just run |task|, otherwise post a task to run
// otherwise posts a task to that thread. // the thread on the UI thread.
void RunOrPostTaskIfNecessary(const base::Location& from_here, void RunOrPostTaskIfNotOnUiThread(const base::Location& from_here,
BrowserThread::ID thread_id,
base::OnceClosure task) { base::OnceClosure task) {
if (BrowserThread::CurrentlyOn(thread_id)) { if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
std::move(task).Run(); std::move(task).Run();
return; return;
} }
base::PostTaskWithTraits(from_here, {thread_id}, std::move(task)); base::PostTaskWithTraits(from_here, {BrowserThread::UI}, std::move(task));
} }
void AddErrorMessageToConsoleOnUI( void AddErrorMessageToConsoleOnUI(
...@@ -132,8 +131,8 @@ void SignedExchangeDevToolsProxy::ReportError( ...@@ -132,8 +131,8 @@ void SignedExchangeDevToolsProxy::ReportError(
DCHECK_CURRENTLY_ON( DCHECK_CURRENTLY_ON(
NavigationURLLoaderImpl::GetLoaderRequestControllerThreadID()); NavigationURLLoaderImpl::GetLoaderRequestControllerThreadID());
errors_.push_back(SignedExchangeError(message, std::move(error_field))); errors_.push_back(SignedExchangeError(message, std::move(error_field)));
RunOrPostTaskIfNecessary( RunOrPostTaskIfNotOnUiThread(
FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce(&AddErrorMessageToConsoleOnUI, frame_tree_node_id_getter_, base::BindOnce(&AddErrorMessageToConsoleOnUI, frame_tree_node_id_getter_,
std::move(message))); std::move(message)));
} }
...@@ -144,8 +143,8 @@ void SignedExchangeDevToolsProxy::CertificateRequestSent( ...@@ -144,8 +143,8 @@ void SignedExchangeDevToolsProxy::CertificateRequestSent(
if (!devtools_enabled_) if (!devtools_enabled_)
return; return;
RunOrPostTaskIfNecessary( RunOrPostTaskIfNotOnUiThread(
FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce( base::BindOnce(
&CertificateRequestSentOnUI, frame_tree_node_id_getter_, request_id, &CertificateRequestSentOnUI, frame_tree_node_id_getter_, request_id,
devtools_navigation_token_ ? *devtools_navigation_token_ : request_id, devtools_navigation_token_ ? *devtools_navigation_token_ : request_id,
...@@ -163,8 +162,8 @@ void SignedExchangeDevToolsProxy::CertificateResponseReceived( ...@@ -163,8 +162,8 @@ void SignedExchangeDevToolsProxy::CertificateResponseReceived(
auto resource_response = base::MakeRefCounted<network::ResourceResponse>(); auto resource_response = base::MakeRefCounted<network::ResourceResponse>();
resource_response->head = head; resource_response->head = head;
RunOrPostTaskIfNecessary( RunOrPostTaskIfNotOnUiThread(
FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce( base::BindOnce(
&CertificateResponseReceivedOnUI, frame_tree_node_id_getter_, &CertificateResponseReceivedOnUI, frame_tree_node_id_getter_,
request_id, request_id,
...@@ -177,8 +176,8 @@ void SignedExchangeDevToolsProxy::CertificateRequestCompleted( ...@@ -177,8 +176,8 @@ void SignedExchangeDevToolsProxy::CertificateRequestCompleted(
const network::URLLoaderCompletionStatus& status) { const network::URLLoaderCompletionStatus& status) {
if (!devtools_enabled_) if (!devtools_enabled_)
return; return;
RunOrPostTaskIfNecessary( RunOrPostTaskIfNotOnUiThread(
FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce(&CertificateRequestCompletedOnUI, base::BindOnce(&CertificateRequestCompletedOnUI,
frame_tree_node_id_getter_, request_id, status)); frame_tree_node_id_getter_, request_id, status));
} }
...@@ -199,8 +198,8 @@ void SignedExchangeDevToolsProxy::OnSignedExchangeReceived( ...@@ -199,8 +198,8 @@ void SignedExchangeDevToolsProxy::OnSignedExchangeReceived(
auto resource_response = base::MakeRefCounted<network::ResourceResponse>(); auto resource_response = base::MakeRefCounted<network::ResourceResponse>();
resource_response->head = outer_response_; resource_response->head = outer_response_;
RunOrPostTaskIfNecessary( RunOrPostTaskIfNotOnUiThread(
FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce(&OnSignedExchangeReceivedOnUI, frame_tree_node_id_getter_, base::BindOnce(&OnSignedExchangeReceivedOnUI, frame_tree_node_id_getter_,
outer_request_url_, resource_response->DeepCopy(), outer_request_url_, resource_response->DeepCopy(),
devtools_navigation_token_, envelope, certificate, devtools_navigation_token_, envelope, certificate,
......
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