Commit 5b28104d authored by Han Leon's avatar Han Leon Committed by Commit Bot

[OnionSoup] Remove WebServiceWorkerSkipWaitingCallbacks

After https://chromium-review.googlesource.com/c/chromium/src/+/1214709,
now we send SkipWaiting Mojo message from within Blink, no longer need
this WebServiceWorkerSkipWaitingCallbacks to cross boundary of Content
and Blink.

BUG=879019

Change-Id: I0c945c3f75713163fce65b6ebed67e117e0f1b34
Reviewed-on: https://chromium-review.googlesource.com/1226810Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#592347}
parent 460a14b6
...@@ -177,7 +177,6 @@ source_set("blink_headers") { ...@@ -177,7 +177,6 @@ source_set("blink_headers") {
"platform/modules/service_worker/web_service_worker_registration_proxy.h", "platform/modules/service_worker/web_service_worker_registration_proxy.h",
"platform/modules/service_worker/web_service_worker_request.h", "platform/modules/service_worker/web_service_worker_request.h",
"platform/modules/service_worker/web_service_worker_response.h", "platform/modules/service_worker/web_service_worker_response.h",
"platform/modules/service_worker/web_service_worker_skip_waiting_callbacks.h",
"platform/modules/service_worker/web_service_worker_stream_handle.h", "platform/modules/service_worker/web_service_worker_stream_handle.h",
"platform/modules/webmidi/web_midi_accessor.h", "platform/modules/webmidi/web_midi_accessor.h",
"platform/modules/webmidi/web_midi_accessor_client.h", "platform/modules/webmidi/web_midi_accessor_client.h",
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_SKIP_WAITING_CALLBACKS_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_SKIP_WAITING_CALLBACKS_H_
#include "third_party/blink/public/platform/web_callbacks.h"
namespace blink {
using WebServiceWorkerSkipWaitingCallbacks = WebCallbacks<void, void>;
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_SKIP_WAITING_CALLBACKS_H_
...@@ -76,6 +76,20 @@ ...@@ -76,6 +76,20 @@
namespace blink { namespace blink {
namespace {
void DidSkipWaiting(ScriptPromiseResolver* resolver, bool success) {
if (!resolver->GetExecutionContext() ||
resolver->GetExecutionContext()->IsContextDestroyed())
return;
// Per spec the promise returned by skipWaiting() can never reject.
if (!success)
return;
resolver->Resolve();
}
} // namespace
ServiceWorkerGlobalScope* ServiceWorkerGlobalScope::Create( ServiceWorkerGlobalScope* ServiceWorkerGlobalScope::Create(
ServiceWorkerThread* thread, ServiceWorkerThread* thread,
std::unique_ptr<GlobalScopeCreationParams> creation_params, std::unique_ptr<GlobalScopeCreationParams> creation_params,
...@@ -261,12 +275,9 @@ ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* script_state) { ...@@ -261,12 +275,9 @@ ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* script_state) {
return ScriptPromise(); return ScriptPromise();
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
ScriptPromise promise = resolver->Promise();
ServiceWorkerGlobalScopeClient::From(execution_context) ServiceWorkerGlobalScopeClient::From(execution_context)
->SkipWaiting( ->SkipWaiting(WTF::Bind(&DidSkipWaiting, WrapPersistent(resolver)));
std::make_unique<CallbackPromiseAdapter<void, void>>(resolver)); return resolver->Promise();
return promise;
} }
void ServiceWorkerGlobalScope::BindServiceWorkerHost( void ServiceWorkerGlobalScope::BindServiceWorkerHost(
......
...@@ -142,16 +142,6 @@ void DidNavigateClient( ...@@ -142,16 +142,6 @@ void DidNavigateClient(
callbacks->OnSuccess(std::move(web_client)); callbacks->OnSuccess(std::move(web_client));
} }
void DidSkipWaiting(
std::unique_ptr<blink::WebServiceWorkerSkipWaitingCallbacks> callbacks,
bool success) {
// OnError() should not be called here since per spec the promise returned by
// skipWaiting() can never reject.
if (!success)
return;
callbacks->OnSuccess();
}
} // namespace } // namespace
ServiceWorkerGlobalScopeClient::ServiceWorkerGlobalScopeClient( ServiceWorkerGlobalScopeClient::ServiceWorkerGlobalScopeClient(
...@@ -208,11 +198,8 @@ void ServiceWorkerGlobalScopeClient::PostMessageToClient( ...@@ -208,11 +198,8 @@ void ServiceWorkerGlobalScopeClient::PostMessageToClient(
service_worker_host_->PostMessageToClient(client_uuid, std::move(message)); service_worker_host_->PostMessageToClient(client_uuid, std::move(message));
} }
void ServiceWorkerGlobalScopeClient::SkipWaiting( void ServiceWorkerGlobalScopeClient::SkipWaiting(SkipWaitingCallback callback) {
std::unique_ptr<WebServiceWorkerSkipWaitingCallbacks> callbacks) { service_worker_host_->SkipWaiting(std::move(callback));
DCHECK(callbacks);
service_worker_host_->SkipWaiting(
WTF::Bind(&DidSkipWaiting, std::move(callbacks)));
} }
void ServiceWorkerGlobalScopeClient::Claim(ClaimCallback callback) { void ServiceWorkerGlobalScopeClient::Claim(ClaimCallback callback) {
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "third_party/blink/public/mojom/service_worker/service_worker.mojom-blink.h" #include "third_party/blink/public/mojom/service_worker/service_worker.mojom-blink.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom-blink.h" #include "third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom-blink.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_clients_info.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_clients_info.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_skip_waiting_callbacks.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_stream_handle.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_stream_handle.h"
#include "third_party/blink/renderer/core/messaging/message_port.h" #include "third_party/blink/renderer/core/messaging/message_port.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h" #include "third_party/blink/renderer/core/workers/worker_clients.h"
...@@ -63,6 +62,8 @@ class MODULES_EXPORT ServiceWorkerGlobalScopeClient final ...@@ -63,6 +62,8 @@ class MODULES_EXPORT ServiceWorkerGlobalScopeClient final
public: public:
using ClaimCallback = mojom::blink::ServiceWorkerHost::ClaimClientsCallback; using ClaimCallback = mojom::blink::ServiceWorkerHost::ClaimClientsCallback;
using SkipWaitingCallback =
mojom::blink::ServiceWorkerHost::SkipWaitingCallback;
static const char kSupplementName[]; static const char kSupplementName[];
...@@ -81,7 +82,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScopeClient final ...@@ -81,7 +82,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScopeClient final
void SetCachedMetadata(const KURL&, const char*, size_t); void SetCachedMetadata(const KURL&, const char*, size_t);
void ClearCachedMetadata(const KURL&); void ClearCachedMetadata(const KURL&);
void PostMessageToClient(const String& client_uuid, BlinkTransferableMessage); void PostMessageToClient(const String& client_uuid, BlinkTransferableMessage);
void SkipWaiting(std::unique_ptr<WebServiceWorkerSkipWaitingCallbacks>); void SkipWaiting(SkipWaitingCallback);
void Claim(ClaimCallback); void Claim(ClaimCallback);
void Focus(const String& client_uuid, void Focus(const String& client_uuid,
std::unique_ptr<WebServiceWorkerClientCallbacks>); std::unique_ptr<WebServiceWorkerClientCallbacks>);
......
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