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") {
"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_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/webmidi/web_midi_accessor.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 @@
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(
ServiceWorkerThread* thread,
std::unique_ptr<GlobalScopeCreationParams> creation_params,
......@@ -261,12 +275,9 @@ ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* script_state) {
return ScriptPromise();
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
ScriptPromise promise = resolver->Promise();
ServiceWorkerGlobalScopeClient::From(execution_context)
->SkipWaiting(
std::make_unique<CallbackPromiseAdapter<void, void>>(resolver));
return promise;
->SkipWaiting(WTF::Bind(&DidSkipWaiting, WrapPersistent(resolver)));
return resolver->Promise();
}
void ServiceWorkerGlobalScope::BindServiceWorkerHost(
......
......@@ -142,16 +142,6 @@ void DidNavigateClient(
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
ServiceWorkerGlobalScopeClient::ServiceWorkerGlobalScopeClient(
......@@ -208,11 +198,8 @@ void ServiceWorkerGlobalScopeClient::PostMessageToClient(
service_worker_host_->PostMessageToClient(client_uuid, std::move(message));
}
void ServiceWorkerGlobalScopeClient::SkipWaiting(
std::unique_ptr<WebServiceWorkerSkipWaitingCallbacks> callbacks) {
DCHECK(callbacks);
service_worker_host_->SkipWaiting(
WTF::Bind(&DidSkipWaiting, std::move(callbacks)));
void ServiceWorkerGlobalScopeClient::SkipWaiting(SkipWaitingCallback callback) {
service_worker_host_->SkipWaiting(std::move(callback));
}
void ServiceWorkerGlobalScopeClient::Claim(ClaimCallback callback) {
......
......@@ -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_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_skip_waiting_callbacks.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/workers/worker_clients.h"
......@@ -63,6 +62,8 @@ class MODULES_EXPORT ServiceWorkerGlobalScopeClient final
public:
using ClaimCallback = mojom::blink::ServiceWorkerHost::ClaimClientsCallback;
using SkipWaitingCallback =
mojom::blink::ServiceWorkerHost::SkipWaitingCallback;
static const char kSupplementName[];
......@@ -81,7 +82,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScopeClient final
void SetCachedMetadata(const KURL&, const char*, size_t);
void ClearCachedMetadata(const KURL&);
void PostMessageToClient(const String& client_uuid, BlinkTransferableMessage);
void SkipWaiting(std::unique_ptr<WebServiceWorkerSkipWaitingCallbacks>);
void SkipWaiting(SkipWaitingCallback);
void Claim(ClaimCallback);
void Focus(const String& client_uuid,
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