Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Side by Side Diff: Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h

Issue 423633002: Make HTMLMediaElement.setMediaKeys() asynchronous. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase + add comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 HTMLMediaElementEncryptedMedia_h 5 #ifndef HTMLMediaElementEncryptedMedia_h
6 #define HTMLMediaElementEncryptedMedia_h 6 #define HTMLMediaElementEncryptedMedia_h
7 7
8 #include "modules/EventTargetModules.h" 8 #include "modules/EventTargetModules.h"
9 #include "platform/Supplementable.h" 9 #include "platform/Supplementable.h"
10 #include "platform/graphics/media/MediaPlayer.h" 10 #include "platform/graphics/media/MediaPlayer.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "public/platform/WebMediaPlayerClient.h" 12 #include "public/platform/WebMediaPlayerClient.h"
13 #include "wtf/Forward.h" 13 #include "wtf/Forward.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class ExceptionState; 17 class ExceptionState;
18 class HTMLMediaElement; 18 class HTMLMediaElement;
19 class MediaKeys; 19 class MediaKeys;
20 class ScriptPromise;
21 class ScriptState;
20 22
21 class HTMLMediaElementEncryptedMedia FINAL : public NoBaseWillBeGarbageCollected <HTMLMediaElementEncryptedMedia>, public WillBeHeapSupplement<HTMLMediaElement> { 23 class HTMLMediaElementEncryptedMedia FINAL : public NoBaseWillBeGarbageCollected <HTMLMediaElementEncryptedMedia>, public WillBeHeapSupplement<HTMLMediaElement> {
22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElementEncryptedMedia); 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElementEncryptedMedia);
23 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMe dia); 25 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMe dia);
24 public: 26 public:
25 // encrypted media extensions (v0.1b) 27 // encrypted media extensions (v0.1b)
26 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys tem, PassRefPtr<Uint8Array> initData, ExceptionState&); 28 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys tem, PassRefPtr<Uint8Array> initData, ExceptionState&);
27 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys tem, ExceptionState&); 29 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys tem, ExceptionState&);
28 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef Ptr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, E xceptionState&); 30 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef Ptr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, E xceptionState&);
29 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef Ptr<Uint8Array> key, ExceptionState&); 31 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef Ptr<Uint8Array> key, ExceptionState&);
30 static void webkitCancelKeyRequest(HTMLMediaElement&, const String& keySyste m, const String& sessionId, ExceptionState&); 32 static void webkitCancelKeyRequest(HTMLMediaElement&, const String& keySyste m, const String& sessionId, ExceptionState&);
31 33
32 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded); 34 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded);
33 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror); 35 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror);
34 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage); 36 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage);
35 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitneedkey); 37 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitneedkey);
36 38
37 // encrypted media extensions (WD) 39 // encrypted media extensions (WD)
38 static MediaKeys* mediaKeys(HTMLMediaElement&); 40 static MediaKeys* mediaKeys(HTMLMediaElement&);
39 static void setMediaKeys(HTMLMediaElement&, MediaKeys*, ExceptionState&); 41 static ScriptPromise setMediaKeys(ScriptState*, HTMLMediaElement&, MediaKeys *);
40 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(needkey); 42 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(needkey);
41 43
42 static void keyAdded(HTMLMediaElement&, const String& keySystem, const Strin g& sessionId); 44 static void keyAdded(HTMLMediaElement&, const String& keySystem, const Strin g& sessionId);
43 static void keyError(HTMLMediaElement&, const String& keySystem, const Strin g& sessionId, WebMediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode ); 45 static void keyError(HTMLMediaElement&, const String& keySystem, const Strin g& sessionId, WebMediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode );
44 static void keyMessage(HTMLMediaElement&, const String& keySystem, const Str ing& sessionId, const unsigned char* message, unsigned messageLength, const WebU RL& defaultURL); 46 static void keyMessage(HTMLMediaElement&, const String& keySystem, const Str ing& sessionId, const unsigned char* message, unsigned messageLength, const WebU RL& defaultURL);
45 static void keyNeeded(HTMLMediaElement&, const String& contentType, const un signed char* initData, unsigned initDataLength); 47 static void keyNeeded(HTMLMediaElement&, const String& contentType, const un signed char* initData, unsigned initDataLength);
46 static void playerDestroyed(HTMLMediaElement&); 48 static void playerDestroyed(HTMLMediaElement&);
47 static WebContentDecryptionModule* contentDecryptionModule(HTMLMediaElement& ); 49 static WebContentDecryptionModule* contentDecryptionModule(HTMLMediaElement& );
48 50
49 static HTMLMediaElementEncryptedMedia& from(HTMLMediaElement&); 51 static HTMLMediaElementEncryptedMedia& from(HTMLMediaElement&);
50 static const char* supplementName(); 52 static const char* supplementName();
51 53
52 virtual void trace(Visitor*) OVERRIDE; 54 virtual void trace(Visitor*) OVERRIDE;
53 55
54 private: 56 private:
57 friend class SetMediaKeysHandler;
58
55 HTMLMediaElementEncryptedMedia(); 59 HTMLMediaElementEncryptedMedia();
56 void generateKeyRequest(WebMediaPlayer*, const String& keySystem, PassRefPtr <Uint8Array> initData, ExceptionState&); 60 void generateKeyRequest(WebMediaPlayer*, const String& keySystem, PassRefPtr <Uint8Array> initData, ExceptionState&);
57 void addKey(WebMediaPlayer*, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionState&) ; 61 void addKey(WebMediaPlayer*, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionState&) ;
58 void cancelKeyRequest(WebMediaPlayer*, const String& keySystem, const String & sessionId, ExceptionState&); 62 void cancelKeyRequest(WebMediaPlayer*, const String& keySystem, const String & sessionId, ExceptionState&);
59 63
60 // EventTarget 64 // EventTarget
61 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<Eve ntListener>); 65 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<Eve ntListener>);
62 EventListener* getAttributeEventListener(const AtomicString& eventType); 66 EventListener* getAttributeEventListener(const AtomicString& eventType);
63 67
64 // Currently we have both EME v0.1b and EME WD implemented in media element. 68 // Currently we have both EME v0.1b and EME WD implemented in media element.
65 // But we do not want to support both at the same time. The one used first 69 // But we do not want to support both at the same time. The one used first
66 // will be supported. Use |m_emeMode| to track this selection. 70 // will be supported. Use |m_emeMode| to track this selection.
67 // FIXME: Remove EmeMode once EME v0.1b support is removed. See crbug.com/24 9976. 71 // FIXME: Remove EmeMode once EME v0.1b support is removed. See crbug.com/24 9976.
68 enum EmeMode { EmeModeNotSelected, EmeModePrefixed, EmeModeUnprefixed }; 72 enum EmeMode { EmeModeNotSelected, EmeModePrefixed, EmeModeUnprefixed };
69 73
70 // check (and set if necessary) the encrypted media extensions (EME) mode 74 // check (and set if necessary) the encrypted media extensions (EME) mode
71 // (v0.1b or WD). Returns whether the mode is allowed and successfully set. 75 // (v0.1b or WD). Returns whether the mode is allowed and successfully set.
72 bool setEmeMode(EmeMode, ExceptionState&); 76 bool setEmeMode(EmeMode);
73 77
74 WebContentDecryptionModule* contentDecryptionModule(); 78 WebContentDecryptionModule* contentDecryptionModule();
75 void setMediaKeysInternal(HTMLMediaElement&, MediaKeys*);
76 79
77 EmeMode m_emeMode; 80 EmeMode m_emeMode;
78 81
79 PersistentWillBeMember<MediaKeys> m_mediaKeys; 82 PersistentWillBeMember<MediaKeys> m_mediaKeys;
80 }; 83 };
81 84
82 } // namespace blink 85 } // namespace blink
83 86
84 #endif 87 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698