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

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

Issue 16387015: Make unprefixed EME APIs use platform and Chromium. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #ifndef MediaKeySession_h 26 #ifndef MediaKeySession_h
27 #define MediaKeySession_h 27 #define MediaKeySession_h
28 28
29 #if ENABLE(ENCRYPTED_MEDIA_V2) 29 #if ENABLE(ENCRYPTED_MEDIA_V2)
30 30
31 #include "bindings/v8/ScriptWrappable.h" 31 #include "bindings/v8/ScriptWrappable.h"
32 #include "core/dom/ContextDestructionObserver.h" 32 #include "core/dom/ContextDestructionObserver.h"
33 #include "core/dom/EventTarget.h" 33 #include "core/dom/EventTarget.h"
34 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
35 #include "core/platform/Timer.h" 35 #include "core/platform/Timer.h"
36 #include "core/platform/graphics/CDMSession.h"
36 #include "wtf/Deque.h" 37 #include "wtf/Deque.h"
37 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
38 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.h"
39 #include "wtf/Uint8Array.h" 40 #include "wtf/Uint8Array.h"
40 #include "wtf/text/WTFString.h" 41 #include "wtf/text/WTFString.h"
41 42
42 namespace WebCore { 43 namespace WebCore {
43 44
44 class GenericEventQueue; 45 class GenericEventQueue;
45 class MediaKeyError; 46 class MediaKeyError;
46 class MediaKeys; 47 class MediaKeys;
48 class CDM;
47 class CDMSession; 49 class CDMSession;
48 50
49 class MediaKeySession : public RefCounted<MediaKeySession>, public ScriptWrappab le, public EventTarget, public ContextDestructionObserver { 51 // References are held by JS and MediaKeys.
52 // Because this object controls the lifetime of the CDMSession, it may outlive
53 // any references to it as long as the MediaKeys object is alive.
54 // The CDMSession has the same lifetime as this object.
55 class MediaKeySession
56 : public RefCounted<MediaKeySession>, public ScriptWrappable, public EventTa rget, public ContextDestructionObserver
57 , private CDMSessionClient {
50 public: 58 public:
51 static PassRefPtr<MediaKeySession> create(ScriptExecutionContext*, MediaKeys *, const String& keySystem); 59 static PassRefPtr<MediaKeySession> create(ScriptExecutionContext*, CDM&, Med iaKeys*);
52 ~MediaKeySession(); 60 ~MediaKeySession();
53 61
54 const String& keySystem() const { return m_keySystem; } 62 const String& keySystem() const { return m_keySystem; }
55 const String& sessionId() const; 63 String sessionId() const;
56 64
57 void setError(MediaKeyError*); 65 void setError(MediaKeyError*);
58 MediaKeyError* error() { return m_error.get(); } 66 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?
59
60 void setKeys(MediaKeys* keys) { m_keys = keys; }
61 MediaKeys* keys() const { return m_keys; }
62 67
63 void generateKeyRequest(const String& mimeType, Uint8Array* initData); 68 void generateKeyRequest(const String& mimeType, Uint8Array* initData);
64 void update(Uint8Array* key, ExceptionCode&); 69 void update(Uint8Array* key, ExceptionCode&);
65 void close(); 70 void close();
66 71
67 using RefCounted<MediaKeySession>::ref; 72 using RefCounted<MediaKeySession>::ref;
68 using RefCounted<MediaKeySession>::deref; 73 using RefCounted<MediaKeySession>::deref;
69 74
70 void enqueueEvent(PassRefPtr<Event>); 75 void enqueueEvent(PassRefPtr<Event>);
71 76
72 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded); 77 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded);
73 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror); 78 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror);
74 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage); 79 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage);
75 80
76 virtual const AtomicString& interfaceName() const OVERRIDE; 81 virtual const AtomicString& interfaceName() const OVERRIDE;
77 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; 82 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
78 83
79 protected: 84 private:
80 MediaKeySession(ScriptExecutionContext*, MediaKeys*, const String& keySystem ); 85 MediaKeySession(ScriptExecutionContext*, CDM&, MediaKeys*);
81 void keyRequestTimerFired(Timer<MediaKeySession>*); 86 void keyRequestTimerFired(Timer<MediaKeySession>*);
82 void addKeyTimerFired(Timer<MediaKeySession>*); 87 void addKeyTimerFired(Timer<MediaKeySession>*);
83 88
84 MediaKeys* m_keys; 89 // CDMSessionClient
85 String m_keySystem; 90 virtual void keyAdded() OVERRIDE;
86 String m_sessionId; 91 virtual void keyError(MediaKeyError::Code, unsigned long systemCode) OVERRID E;
92 virtual void keyMessage(const unsigned char* message, unsigned messageLength , const KURL& destinationURL) OVERRIDE;
93
94 const String m_keySystem;
87 RefPtr<MediaKeyError> m_error; 95 RefPtr<MediaKeyError> m_error;
88 OwnPtr<GenericEventQueue> m_asyncEventQueue; 96 OwnPtr<GenericEventQueue> m_asyncEventQueue;
89 OwnPtr<CDMSession> m_session; 97 OwnPtr<CDMSession> m_session;
98 // Used to remove the reference from the parent MediaKeys when close()'d.
99 MediaKeys* m_keys;
90 100
91 struct PendingKeyRequest { 101 struct PendingKeyRequest {
92 PendingKeyRequest(const String& mimeType, Uint8Array* initData) : mimeTy pe(mimeType), initData(initData) { } 102 PendingKeyRequest(const String& mimeType, Uint8Array* initData) : mimeTy pe(mimeType), initData(initData) { }
93 String mimeType; 103 String mimeType;
94 RefPtr<Uint8Array> initData; 104 RefPtr<Uint8Array> initData;
95 }; 105 };
96 Deque<PendingKeyRequest> m_pendingKeyRequests; 106 Deque<PendingKeyRequest> m_pendingKeyRequests;
97 Timer<MediaKeySession> m_keyRequestTimer; 107 Timer<MediaKeySession> m_keyRequestTimer;
98 108
99 Deque<RefPtr<Uint8Array> > m_pendingKeys; 109 Deque<RefPtr<Uint8Array> > m_pendingKeys;
100 Timer<MediaKeySession> m_addKeyTimer; 110 Timer<MediaKeySession> m_addKeyTimer;
101 111
102 private: 112 private:
103 virtual void refEventTarget() OVERRIDE { ref(); } 113 virtual void refEventTarget() OVERRIDE { ref(); }
104 virtual void derefEventTarget() OVERRIDE { deref(); } 114 virtual void derefEventTarget() OVERRIDE { deref(); }
105 115
106 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD ata; } 116 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD ata; }
107 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT argetData; } 117 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT argetData; }
108 118
109 EventTargetData m_eventTargetData; 119 EventTargetData m_eventTargetData;
110 }; 120 };
111 121
112 } 122 }
113 123
114 #endif // ENABLE(ENCRYPTED_MEDIA_V2) 124 #endif // ENABLE(ENCRYPTED_MEDIA_V2)
115 125
116 #endif // MediaKeySession_h 126 #endif // MediaKeySession_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698