blob: 4191beac17e949ba67b5bd278bd49d6dd868d9d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// 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_RENDERER_MODULES_PUSH_MESSAGING_PUSH_SUBSCRIPTION_CALLBACKS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_PUSH_MESSAGING_PUSH_SUBSCRIPTION_CALLBACKS_H_
#include "base/macros.h"
#include "third_party/blink/public/platform/web_callbacks.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
namespace blink {
class DOMException;
class PushSubscription;
class ServiceWorkerRegistration;
class ScriptPromiseResolver;
// Used from PushProvider, for calls to PushMessaging::Unsubscribe().
using PushUnsubscribeCallbacks = WebCallbacks<bool, DOMException*>;
// This class is an implementation of WebCallbacks<PushSubscription*,
// DOMException*> that will resolve the underlying promise depending on the
// constructor and will pass it to the PushSubscription.
class PushSubscriptionCallbacks final
: public WebCallbacks<PushSubscription*, DOMException*> {
USING_FAST_MALLOC(PushSubscriptionCallbacks);
public:
PushSubscriptionCallbacks(
ScriptPromiseResolver* resolver,
ServiceWorkerRegistration* service_worker_registration);
~PushSubscriptionCallbacks() override;
// WebCallbacks<S, T> interface.
void OnSuccess(PushSubscription* push_subscription) override;
void OnError(DOMException* error) override;
private:
Persistent<ScriptPromiseResolver> resolver_;
Persistent<ServiceWorkerRegistration> service_worker_registration_;
DISALLOW_COPY_AND_ASSIGN(PushSubscriptionCallbacks);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_PUSH_MESSAGING_PUSH_SUBSCRIPTION_CALLBACKS_H_
|