summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/presentation/PresentationRequest.h
blob: 8e355b7a0c22e3a51f539b5f60e9586e9fea7ea6 (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
49
50
51
52
53
54
55
56
57
58
59
// 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 PresentationRequest_h
#define PresentationRequest_h

#include "bindings/core/v8/ScriptPromise.h"
#include "core/dom/ActiveDOMObject.h"
#include "core/events/EventTarget.h"
#include "platform/heap/Handle.h"
#include "platform/heap/Heap.h"
#include "platform/weborigin/KURL.h"

namespace blink {

// Implements the PresentationRequest interface from the Presentation API from
// which websites can start or join presentation connections.
class PresentationRequest final
    : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationRequest>
    , public ActiveDOMObject {
    REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PresentationRequest);
    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationRequest);
    DEFINE_WRAPPERTYPEINFO();
public:
    ~PresentationRequest() = default;

    static PresentationRequest* create(ExecutionContext*, const String& url, ExceptionState&);

    // EventTarget implementation.
    const AtomicString& interfaceName() const override;
    ExecutionContext* getExecutionContext() const override;

    // ActiveDOMObject implementation.
    bool hasPendingActivity() const;

    ScriptPromise start(ScriptState*);
    ScriptPromise reconnect(ScriptState*, const String& id);
    ScriptPromise getAvailability(ScriptState*);

    const KURL& url() const;

    DEFINE_ATTRIBUTE_EVENT_LISTENER(connectionavailable);

    DECLARE_VIRTUAL_TRACE();

protected:
    // EventTarget implementation.
    bool addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&) override;

private:
    PresentationRequest(ExecutionContext*, const KURL&);

    KURL m_url;
};

} // namespace blink

#endif // PresentationRequest_h