summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/mediasession/MediaSession.h
blob: 8501a3bd4a7ce46a06686c6ab2c6060c50bb28b9 (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 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 MediaSession_h
#define MediaSession_h

#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptWrappable.h"
#include "modules/ModulesExport.h"
#include "platform/heap/Handle.h"
#include "public/platform/modules/mediasession/WebMediaSession.h"
#include "wtf/OwnPtr.h"

namespace blink {

class MediaMetadata;
class ScriptState;

class MODULES_EXPORT MediaSession final
    : public GarbageCollectedFinalized<MediaSession>
    , public ScriptWrappable {
    DEFINE_WRAPPERTYPEINFO();
public:
    static MediaSession* create(ExecutionContext*, ExceptionState&);

    WebMediaSession* getWebMediaSession() { return m_webMediaSession.get(); }

    ScriptPromise activate(ScriptState*);
    ScriptPromise deactivate(ScriptState*);

    void setMetadata(MediaMetadata*);
    MediaMetadata* metadata() const;

    DECLARE_VIRTUAL_TRACE();

private:
    friend class MediaSessionTest;

    explicit MediaSession(PassOwnPtr<WebMediaSession>);

    OwnPtr<WebMediaSession> m_webMediaSession;
    Member<MediaMetadata> m_metadata;
};

} // namespace blink

#endif // MediaSession_h