OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MediaSession_h | 5 #ifndef MediaSession_h |
6 #define MediaSession_h | 6 #define MediaSession_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | |
9 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
11 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
12 #include "public/platform/modules/mediasession/WebMediaSession.h" | 11 #include "public/platform/modules/mediasession/media_session.mojom-blink.h" |
13 #include <memory> | 12 #include <memory> |
14 | 13 |
15 namespace blink { | 14 namespace blink { |
16 | 15 |
17 class MediaMetadata; | 16 class MediaMetadata; |
18 class ScriptState; | 17 class ScriptState; |
19 | 18 |
20 class MODULES_EXPORT MediaSession final | 19 class MODULES_EXPORT MediaSession final |
21 : public GarbageCollectedFinalized<MediaSession>, | 20 : public GarbageCollectedFinalized<MediaSession>, |
22 public ScriptWrappable { | 21 public ScriptWrappable { |
23 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
24 | 23 |
25 public: | 24 public: |
26 static MediaSession* create(ExecutionContext*, ExceptionState&); | 25 static MediaSession* create(); |
27 | 26 |
28 WebMediaSession* getWebMediaSession() { return m_webMediaSession.get(); } | 27 void setMetadata(ScriptState*, MediaMetadata*); |
29 | 28 MediaMetadata* metadata(ScriptState*) const; |
30 ScriptPromise activate(ScriptState*); | |
31 ScriptPromise deactivate(ScriptState*); | |
32 | |
33 void setMetadata(MediaMetadata*); | |
34 MediaMetadata* metadata() const; | |
35 | 29 |
36 DECLARE_VIRTUAL_TRACE(); | 30 DECLARE_VIRTUAL_TRACE(); |
37 | 31 |
38 private: | 32 private: |
39 friend class MediaSessionTest; | 33 friend class MediaSessionTest; |
40 | 34 |
41 explicit MediaSession(std::unique_ptr<WebMediaSession>); | 35 MediaSession(); |
42 | 36 |
43 std::unique_ptr<WebMediaSession> m_webMediaSession; | 37 // Returns null when the ExecutionContext is not document. |
| 38 mojom::blink::MediaSessionService* getService(ScriptState*); |
| 39 |
44 Member<MediaMetadata> m_metadata; | 40 Member<MediaMetadata> m_metadata; |
| 41 mojom::blink::MediaSessionServicePtr m_service; |
45 }; | 42 }; |
46 | 43 |
47 } // namespace blink | 44 } // namespace blink |
48 | 45 |
49 #endif // MediaSession_h | 46 #endif // MediaSession_h |
OLD | NEW |