Index: Source/modules/encryptedmedia/MediaKeySession.h |
diff --git a/Source/modules/encryptedmedia/MediaKeySession.h b/Source/modules/encryptedmedia/MediaKeySession.h |
index 04e254a5ef4592cc8cb910fc0c35f46e93f5bce5..429e4cd87b7d960c88b232d431eeb7c60b3e964a 100644 |
--- a/Source/modules/encryptedmedia/MediaKeySession.h |
+++ b/Source/modules/encryptedmedia/MediaKeySession.h |
@@ -26,13 +26,12 @@ |
#ifndef MediaKeySession_h |
#define MediaKeySession_h |
-#if ENABLE(ENCRYPTED_MEDIA_V2) |
- |
#include "bindings/v8/ScriptWrappable.h" |
#include "core/dom/ContextDestructionObserver.h" |
#include "core/dom/EventTarget.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/platform/Timer.h" |
+#include "core/platform/graphics/ContentDecryptionModuleSession.h" |
#include "wtf/Deque.h" |
#include "wtf/PassRefPtr.h" |
#include "wtf/RefCounted.h" |
@@ -44,22 +43,26 @@ namespace WebCore { |
class GenericEventQueue; |
class MediaKeyError; |
class MediaKeys; |
-class CDMSession; |
- |
-class MediaKeySession : public RefCounted<MediaKeySession>, public ScriptWrappable, public EventTarget, public ContextDestructionObserver { |
+class ContentDecryptionModule; |
+class ContentDecryptionModuleSession; |
+ |
+// References are held by JS and MediaKeys. |
+// Because this object controls the lifetime of the ContentDecryptionModuleSession, |
+// it may outlive any references to it as long as the MediaKeys object is alive. |
+// The ContentDecryptionModuleSession has the same lifetime as this object. |
+class MediaKeySession |
+ : public RefCounted<MediaKeySession>, public ScriptWrappable, public EventTarget, public ContextDestructionObserver |
+ , private ContentDecryptionModuleSessionClient { |
public: |
- static PassRefPtr<MediaKeySession> create(ScriptExecutionContext*, MediaKeys*, const String& keySystem); |
+ static PassRefPtr<MediaKeySession> create(ScriptExecutionContext*, ContentDecryptionModule*, MediaKeys*); |
~MediaKeySession(); |
const String& keySystem() const { return m_keySystem; } |
- const String& sessionId() const; |
+ String sessionId() const; |
void setError(MediaKeyError*); |
MediaKeyError* error() { return m_error.get(); } |
- void setKeys(MediaKeys* keys) { m_keys = keys; } |
- MediaKeys* keys() const { return m_keys; } |
- |
void generateKeyRequest(const String& mimeType, Uint8Array* initData); |
void update(Uint8Array* key, ExceptionCode&); |
void close(); |
@@ -76,17 +79,22 @@ public: |
virtual const AtomicString& interfaceName() const OVERRIDE; |
virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
-protected: |
- MediaKeySession(ScriptExecutionContext*, MediaKeys*, const String& keySystem); |
+private: |
+ MediaKeySession(ScriptExecutionContext*, ContentDecryptionModule*, MediaKeys*); |
void keyRequestTimerFired(Timer<MediaKeySession>*); |
void addKeyTimerFired(Timer<MediaKeySession>*); |
- MediaKeys* m_keys; |
+ // ContentDecryptionModuleSessionClient |
+ virtual void keyAdded() OVERRIDE; |
+ virtual void keyError(MediaKeyErrorCode, unsigned long systemCode) OVERRIDE; |
+ virtual void keyMessage(const unsigned char* message, size_t messageLength, const KURL& destinationURL) OVERRIDE; |
+ |
String m_keySystem; |
- String m_sessionId; |
RefPtr<MediaKeyError> m_error; |
OwnPtr<GenericEventQueue> m_asyncEventQueue; |
- OwnPtr<CDMSession> m_session; |
+ OwnPtr<ContentDecryptionModuleSession> m_session; |
+ // Used to remove the reference from the parent MediaKeys when close()'d. |
+ MediaKeys* m_keys; |
struct PendingKeyRequest { |
PendingKeyRequest(const String& mimeType, Uint8Array* initData) : mimeType(mimeType), initData(initData) { } |
@@ -111,6 +119,4 @@ private: |
} |
-#endif // ENABLE(ENCRYPTED_MEDIA_V2) |
- |
#endif // MediaKeySession_h |