Commit 4bb42a65 authored by Asami Doi's avatar Asami Doi Committed by Commit Bot

ServiceWorker: Remove RunOrPostTaskOnThread from SWContainerHost

This CL removes RunOrPostTaskOnThread from ServiceWorkerContainerHost
because a service worker runs on the UI thread now.

Bug: 1138155
Change-Id: I4b9d7631011f0fb9f7a294c4af68ba16a0fb9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507301
Commit-Queue: Asami Doi <asamidoi@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822560}
parent b921e417
...@@ -134,15 +134,9 @@ ServiceWorkerContainerHost::~ServiceWorkerContainerHost() { ...@@ -134,15 +134,9 @@ ServiceWorkerContainerHost::~ServiceWorkerContainerHost() {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
if (IsBackForwardCacheEnabled() && IsContainerForClient()) { if (IsBackForwardCacheEnabled() && IsContainerForClient()) {
RunOrPostTaskOnThread( auto* rfh = RenderFrameHostImpl::FromID(process_id(), frame_id());
FROM_HERE, BrowserThread::UI, if (rfh)
base::BindOnce( rfh->RemoveServiceWorkerContainerHost(client_uuid());
[](int process_id, int frame_id, const std::string& uuid) {
auto* rfh = RenderFrameHostImpl::FromID(process_id, frame_id);
if (rfh)
rfh->RemoveServiceWorkerContainerHost(uuid);
},
process_id(), frame_id(), client_uuid()));
} }
if (fetch_request_window_id_) if (fetch_request_window_id_)
...@@ -759,18 +753,10 @@ void ServiceWorkerContainerHost::OnBeginNavigationCommit( ...@@ -759,18 +753,10 @@ void ServiceWorkerContainerHost::OnBeginNavigationCommit(
} }
if (IsBackForwardCacheEnabled()) { if (IsBackForwardCacheEnabled()) {
RunOrPostTaskOnThread( auto* rfh = RenderFrameHostImpl::FromID(container_process_id, frame_id());
FROM_HERE, BrowserThread::UI, // |rfh| may be null in tests (but it should not happen in production).
base::BindOnce( if (rfh)
[](int process_id, int frame_id, const std::string& uuid, rfh->AddServiceWorkerContainerHost(client_uuid(), GetWeakPtr());
base::WeakPtr<ServiceWorkerContainerHost> self) {
auto* rfh = RenderFrameHostImpl::FromID(process_id, frame_id);
// |rfh| may be null in tests (but it should not happen in
// production).
if (rfh)
rfh->AddServiceWorkerContainerHost(uuid, self);
},
container_process_id, frame_id_, client_uuid(), GetWeakPtr()));
} }
DCHECK_EQ(ukm_source_id_, ukm::kInvalidSourceId); DCHECK_EQ(ukm_source_id_, ukm::kInvalidSourceId);
...@@ -957,9 +943,7 @@ bool ServiceWorkerContainerHost::AllowServiceWorker(const GURL& scope, ...@@ -957,9 +943,7 @@ bool ServiceWorkerContainerHost::AllowServiceWorker(const GURL& scope,
GetContentClient()->browser()->AllowServiceWorker( GetContentClient()->browser()->AllowServiceWorker(
scope, site_for_cookies().RepresentativeUrl(), top_frame_origin(), scope, site_for_cookies().RepresentativeUrl(), top_frame_origin(),
script_url, context_->wrapper()->browser_context()); script_url, context_->wrapper()->browser_context());
RunOrPostTaskOnThread(FROM_HERE, BrowserThread::UI, ReportServiceWorkerAccess(process_id(), frame_id(), scope, allowed);
base::BindOnce(&ReportServiceWorkerAccess, process_id_,
frame_id_, scope, allowed));
return allowed; return allowed;
} }
...@@ -1079,18 +1063,11 @@ void ServiceWorkerContainerHost::EvictFromBackForwardCache( ...@@ -1079,18 +1063,11 @@ void ServiceWorkerContainerHost::EvictFromBackForwardCache(
DCHECK(IsBackForwardCacheEnabled()); DCHECK(IsBackForwardCacheEnabled());
DCHECK(IsContainerForWindowClient()); DCHECK(IsContainerForWindowClient());
is_in_back_forward_cache_ = false; is_in_back_forward_cache_ = false;
RunOrPostTaskOnThread(
FROM_HERE, BrowserThread::UI, auto* rfh = RenderFrameHostImpl::FromID(process_id(), frame_id());
base::BindOnce( // |rfh| could be evicted before this function is called.
[](int process_id, int frame_id, if (rfh && rfh->IsInBackForwardCache())
BackForwardCacheMetrics::NotRestoredReason reason) { rfh->EvictFromBackForwardCacheWithReason(reason);
auto* rfh = RenderFrameHostImpl::FromID(process_id, frame_id);
// |rfh| could be evicted before this function is called.
if (!rfh || !rfh->IsInBackForwardCache())
return;
rfh->EvictFromBackForwardCacheWithReason(reason);
},
process_id_, frame_id_, reason));
} }
void ServiceWorkerContainerHost::OnEnterBackForwardCache() { void ServiceWorkerContainerHost::OnEnterBackForwardCache() {
......
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