Commit 81584280 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

ServiceWorker: Remove ServiceWorkerProviderHost::IsContextAlive() for cleanup

IsContextAlive() just checks ServiceWorkerProviderHost::context_, and is only
called in ServiceWorkerProviderHost. It's not necessary to expose it as a public
function.

Bug: n/a
Change-Id: I33f5b23c4f2bdaaffc7b8b45d99ee7cd84a13c5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1909053
Auto-Submit: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714154}
parent e1cd3000
...@@ -682,7 +682,7 @@ void ServiceWorkerProviderHost::RemoveServiceWorkerObjectHost( ...@@ -682,7 +682,7 @@ void ServiceWorkerProviderHost::RemoveServiceWorkerObjectHost(
bool ServiceWorkerProviderHost::AllowServiceWorker(const GURL& scope, bool ServiceWorkerProviderHost::AllowServiceWorker(const GURL& scope,
const GURL& script_url) { const GURL& script_url) {
DCHECK(IsContextAlive()); DCHECK(context_);
if (ServiceWorkerContext::IsServiceWorkerOnUIEnabled()) { if (ServiceWorkerContext::IsServiceWorkerOnUIEnabled()) {
return GetContentClient()->browser()->AllowServiceWorkerOnUI( return GetContentClient()->browser()->AllowServiceWorkerOnUI(
scope, site_for_cookies(), top_frame_origin(), script_url, scope, site_for_cookies(), top_frame_origin(), script_url,
...@@ -870,7 +870,7 @@ void ServiceWorkerProviderHost::ReturnRegistrationForReadyIfNeeded() { ...@@ -870,7 +870,7 @@ void ServiceWorkerProviderHost::ReturnRegistrationForReadyIfNeeded() {
TRACE_EVENT_ASYNC_END1("ServiceWorker", TRACE_EVENT_ASYNC_END1("ServiceWorker",
"ServiceWorkerProviderHost::GetRegistrationForReady", "ServiceWorkerProviderHost::GetRegistrationForReady",
this, "Registration ID", registration->id()); this, "Registration ID", registration->id());
if (!IsContextAlive()) { if (!context_) {
// Here no need to run or destroy |get_ready_callback_|, which will destroy // Here no need to run or destroy |get_ready_callback_|, which will destroy
// together with |receiver_| when |this| destroys. // together with |receiver_| when |this| destroys.
return; return;
...@@ -881,10 +881,6 @@ void ServiceWorkerProviderHost::ReturnRegistrationForReadyIfNeeded() { ...@@ -881,10 +881,6 @@ void ServiceWorkerProviderHost::ReturnRegistrationForReadyIfNeeded() {
scoped_refptr<ServiceWorkerRegistration>(registration))); scoped_refptr<ServiceWorkerRegistration>(registration)));
} }
bool ServiceWorkerProviderHost::IsContextAlive() {
return context_ != nullptr;
}
void ServiceWorkerProviderHost::SendSetControllerServiceWorker( void ServiceWorkerProviderHost::SendSetControllerServiceWorker(
bool notify_controllerchange) { bool notify_controllerchange) {
DCHECK(IsProviderForClient()); DCHECK(IsProviderForClient());
...@@ -1083,7 +1079,7 @@ void ServiceWorkerProviderHost::RegistrationComplete( ...@@ -1083,7 +1079,7 @@ void ServiceWorkerProviderHost::RegistrationComplete(
std::string(), nullptr); std::string(), nullptr);
return; return;
} }
if (!IsContextAlive()) { if (!context_) {
std::move(callback).Run( std::move(callback).Run(
blink::mojom::ServiceWorkerErrorType::kAbort, blink::mojom::ServiceWorkerErrorType::kAbort,
base::StringPrintf( base::StringPrintf(
...@@ -1190,7 +1186,7 @@ void ServiceWorkerProviderHost::GetRegistrationComplete( ...@@ -1190,7 +1186,7 @@ void ServiceWorkerProviderHost::GetRegistrationComplete(
"Status", blink::ServiceWorkerStatusToString(status), "Registration ID", "Status", blink::ServiceWorkerStatusToString(status), "Registration ID",
registration ? registration->id() registration ? registration->id()
: blink::mojom::kInvalidServiceWorkerRegistrationId); : blink::mojom::kInvalidServiceWorkerRegistrationId);
if (!IsContextAlive()) { if (!context_) {
std::move(callback).Run( std::move(callback).Run(
blink::mojom::ServiceWorkerErrorType::kAbort, blink::mojom::ServiceWorkerErrorType::kAbort,
std::string( std::string(
...@@ -1233,7 +1229,7 @@ void ServiceWorkerProviderHost::GetRegistrationsComplete( ...@@ -1233,7 +1229,7 @@ void ServiceWorkerProviderHost::GetRegistrationsComplete(
TRACE_EVENT_ASYNC_END1( TRACE_EVENT_ASYNC_END1(
"ServiceWorker", "ServiceWorkerProviderHost::GetRegistrations", trace_id, "ServiceWorker", "ServiceWorkerProviderHost::GetRegistrations", trace_id,
"Status", blink::ServiceWorkerStatusToString(status)); "Status", blink::ServiceWorkerStatusToString(status));
if (!IsContextAlive()) { if (!context_) {
std::move(callback).Run( std::move(callback).Run(
blink::mojom::ServiceWorkerErrorType::kAbort, blink::mojom::ServiceWorkerErrorType::kAbort,
std::string( std::string(
...@@ -1302,7 +1298,7 @@ void ServiceWorkerProviderHost::EnsureControllerServiceWorker( ...@@ -1302,7 +1298,7 @@ void ServiceWorkerProviderHost::EnsureControllerServiceWorker(
mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> receiver, mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> receiver,
blink::mojom::ControllerServiceWorkerPurpose purpose) { blink::mojom::ControllerServiceWorkerPurpose purpose) {
// TODO(kinuko): Log the reasons we drop the request. // TODO(kinuko): Log the reasons we drop the request.
if (!IsContextAlive() || !controller_) if (!context_ || !controller_)
return; return;
controller_->RunAfterStartWorker( controller_->RunAfterStartWorker(
...@@ -1447,7 +1443,7 @@ bool ServiceWorkerProviderHost::CanServeContainerHostMethods( ...@@ -1447,7 +1443,7 @@ bool ServiceWorkerProviderHost::CanServeContainerHostMethods(
const GURL& script_url, const GURL& script_url,
const char* error_prefix, const char* error_prefix,
Args... args) { Args... args) {
if (!IsContextAlive()) { if (!context_) {
std::move(*callback).Run( std::move(*callback).Run(
blink::mojom::ServiceWorkerErrorType::kAbort, blink::mojom::ServiceWorkerErrorType::kAbort,
std::string(error_prefix) + std::string(error_prefix) +
......
...@@ -331,10 +331,6 @@ class CONTENT_EXPORT ServiceWorkerProviderHost ...@@ -331,10 +331,6 @@ class CONTENT_EXPORT ServiceWorkerProviderHost
// May return nullptr if the context has shut down. // May return nullptr if the context has shut down.
base::WeakPtr<ServiceWorkerContextCore> context() { return context_; } base::WeakPtr<ServiceWorkerContextCore> context() { return context_; }
// Returns true if the context referred to by this host (i.e. |context_|) is
// still alive.
bool IsContextAlive();
// Dispatches message event to the document. // Dispatches message event to the document.
void PostMessageToClient(ServiceWorkerVersion* version, void PostMessageToClient(ServiceWorkerVersion* version,
blink::TransferableMessage message); blink::TransferableMessage message);
......
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