summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.h
blob: d460c995d0dbdb89aec4f0f1d64aa085a383a9b0 (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
// Copyright 2015 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 PresentationConnectionCallbacks_h
#define PresentationConnectionCallbacks_h

#include "platform/heap/Handle.h"
#include "public/platform/WebCallbacks.h"
#include "wtf/Noncopyable.h"

namespace blink {

class PresentationRequest;
class ScriptPromiseResolver;
class WebPresentationConnectionClient;
struct WebPresentationError;

// PresentationConnectionCallbacks extends WebCallbacks to resolve the
// underlying promise depending on the result passed to the callback. It takes
// the PresentationRequest object that originated the call in its constructor
// and will pass it to the created PresentationConnection.
class PresentationConnectionCallbacks final
    : public WebCallbacks<WebPassOwnPtr<WebPresentationConnectionClient>, const WebPresentationError&> {
public:
    PresentationConnectionCallbacks(ScriptPromiseResolver*, PresentationRequest*);
    ~PresentationConnectionCallbacks() override = default;

    void onSuccess(WebPassOwnPtr<WebPresentationConnectionClient>) override;
    void onError(const WebPresentationError&) override;

private:
    Persistent<ScriptPromiseResolver> m_resolver;
    Persistent<PresentationRequest> m_request;

    WTF_MAKE_NONCOPYABLE(PresentationConnectionCallbacks);
};

} // namespace blink

#endif // PresentationConnectionCallbacks_h