Index: Source/modules/encryptedmedia/MediaKeySession.h |
diff --git a/Source/modules/encryptedmedia/MediaKeySession.h b/Source/modules/encryptedmedia/MediaKeySession.h |
index 04e254a5ef4592cc8cb910fc0c35f46e93f5bce5..93258f55b394addf25d1c17c0346c3e65850d9ad 100644 |
--- a/Source/modules/encryptedmedia/MediaKeySession.h |
+++ b/Source/modules/encryptedmedia/MediaKeySession.h |
@@ -33,6 +33,7 @@ |
#include "core/dom/EventTarget.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/platform/Timer.h" |
+#include "core/platform/graphics/CDMSession.h" |
#include "wtf/Deque.h" |
#include "wtf/PassRefPtr.h" |
#include "wtf/RefCounted.h" |
@@ -44,21 +45,25 @@ namespace WebCore { |
class GenericEventQueue; |
class MediaKeyError; |
class MediaKeys; |
+class CDM; |
class CDMSession; |
-class MediaKeySession : public RefCounted<MediaKeySession>, public ScriptWrappable, public EventTarget, public ContextDestructionObserver { |
+// References are held by JS and MediaKeys. |
+// Because this object controls the lifetime of the CDMSession, it may outlive |
+// any references to it as long as the MediaKeys object is alive. |
+// The CDMSession has the same lifetime as this object. |
+class MediaKeySession |
+ : public RefCounted<MediaKeySession>, public ScriptWrappable, public EventTarget, public ContextDestructionObserver |
+ , private CDMSessionClient { |
public: |
- static PassRefPtr<MediaKeySession> create(ScriptExecutionContext*, MediaKeys*, const String& keySystem); |
+ static PassRefPtr<MediaKeySession> create(ScriptExecutionContext*, CDM&, 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; } |
+ PassRefPtr<MediaKeyError> error() const; |
ddorwin
2013/06/06 23:29:50
abarth: Which way should we prefer?
I changed this
abarth-chromium
2013/06/07 00:08:23
Do you mean between returning a MediaKeyError* and
ddorwin
2013/06/10 22:52:34
Done.
Should we change HTMLMediaElement too?
|
void generateKeyRequest(const String& mimeType, Uint8Array* initData); |
void update(Uint8Array* key, ExceptionCode&); |
@@ -76,17 +81,22 @@ public: |
virtual const AtomicString& interfaceName() const OVERRIDE; |
virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
-protected: |
- MediaKeySession(ScriptExecutionContext*, MediaKeys*, const String& keySystem); |
+private: |
+ MediaKeySession(ScriptExecutionContext*, CDM&, MediaKeys*); |
void keyRequestTimerFired(Timer<MediaKeySession>*); |
void addKeyTimerFired(Timer<MediaKeySession>*); |
- MediaKeys* m_keys; |
- String m_keySystem; |
- String m_sessionId; |
+ // CDMSessionClient |
+ virtual void keyAdded() OVERRIDE; |
+ virtual void keyError(MediaKeyError::Code, unsigned long systemCode) OVERRIDE; |
+ virtual void keyMessage(const unsigned char* message, unsigned messageLength, const KURL& destinationURL) OVERRIDE; |
+ |
+ const String m_keySystem; |
RefPtr<MediaKeyError> m_error; |
OwnPtr<GenericEventQueue> m_asyncEventQueue; |
OwnPtr<CDMSession> 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) { } |