OLD | NEW |
---|---|
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 // Because this object controls the lifetime of the WebContentDecryptionModuleSe ssion, | 58 // Because this object controls the lifetime of the WebContentDecryptionModuleSe ssion, |
59 // it may outlive any JavaScript references as long as the MediaKeys object is a live. | 59 // it may outlive any JavaScript references as long as the MediaKeys object is a live. |
60 // The WebContentDecryptionModuleSession has the same lifetime as this object. | 60 // The WebContentDecryptionModuleSession has the same lifetime as this object. |
61 class MediaKeySession FINAL | 61 class MediaKeySession FINAL |
62 : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<MediaKeyS ession>, public ActiveDOMObject, public EventTargetWithInlineData | 62 : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<MediaKeyS ession>, public ActiveDOMObject, public EventTargetWithInlineData |
63 , private WebContentDecryptionModuleSession::Client { | 63 , private WebContentDecryptionModuleSession::Client { |
64 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<M ediaKeySession>); | 64 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<M ediaKeySession>); |
65 DEFINE_WRAPPERTYPEINFO(); | 65 DEFINE_WRAPPERTYPEINFO(); |
66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaKeySession); | 66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaKeySession); |
67 public: | 67 public: |
68 static ScriptPromise create(ScriptState*, MediaKeys*, const String& initData Type, PassRefPtr<ArrayBuffer> initData, const String& sessionType); | 68 static MediaKeySession* create(ScriptState*, MediaKeys*, const String& sessi onType); |
69 virtual ~MediaKeySession(); | 69 virtual ~MediaKeySession(); |
70 | 70 |
71 const String& keySystem() const { return m_keySystem; } | 71 const String& keySystem() const { return m_keySystem; } |
72 String sessionId() const; | 72 const String& sessionId() const { return m_sessionId; } |
73 double expiration() const { return m_expiration; } | |
ddorwin
2014/09/09 00:44:36
Ideally, expiration should have been added in a se
jrummell
2014/09/09 19:55:59
Removed since it's not used. Adding expiration wil
| |
73 ScriptPromise closed(ScriptState*); | 74 ScriptPromise closed(ScriptState*); |
74 | 75 |
76 ScriptPromise generateRequest(ScriptState*, const String& initDataType, Arra yBuffer* initData); | |
77 ScriptPromise generateRequest(ScriptState*, const String& initDataType, Arra yBufferView* initData); | |
78 | |
75 void setError(MediaKeyError*); | 79 void setError(MediaKeyError*); |
76 MediaKeyError* error() { return m_error.get(); } | 80 MediaKeyError* error() { return m_error.get(); } |
77 | 81 |
78 ScriptPromise update(ScriptState*, ArrayBuffer* response); | 82 ScriptPromise update(ScriptState*, ArrayBuffer* response); |
79 ScriptPromise update(ScriptState*, ArrayBufferView* response); | 83 ScriptPromise update(ScriptState*, ArrayBufferView* response); |
80 ScriptPromise release(ScriptState*); | 84 ScriptPromise release(ScriptState*); |
81 | 85 |
82 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); | 86 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); |
83 | 87 |
84 // EventTarget | 88 // EventTarget |
85 virtual const AtomicString& interfaceName() const OVERRIDE; | 89 virtual const AtomicString& interfaceName() const OVERRIDE; |
86 virtual ExecutionContext* executionContext() const OVERRIDE; | 90 virtual ExecutionContext* executionContext() const OVERRIDE; |
87 | 91 |
88 // ActiveDOMObject | 92 // ActiveDOMObject |
89 virtual bool hasPendingActivity() const OVERRIDE; | 93 virtual bool hasPendingActivity() const OVERRIDE; |
90 virtual void stop() OVERRIDE; | 94 virtual void stop() OVERRIDE; |
91 | 95 |
92 virtual void trace(Visitor*) OVERRIDE; | 96 virtual void trace(Visitor*) OVERRIDE; |
93 | 97 |
94 private: | 98 private: |
95 class PendingAction; | 99 class PendingAction; |
96 friend class MediaKeySessionInitializer; | 100 friend class NewSessionResult; |
97 | 101 |
98 MediaKeySession(ExecutionContext*, MediaKeys*, PassOwnPtr<WebContentDecrypti onModuleSession>); | 102 MediaKeySession(ScriptState*, MediaKeys*, const String& sessionType); |
103 | |
99 void actionTimerFired(Timer<MediaKeySession>*); | 104 void actionTimerFired(Timer<MediaKeySession>*); |
100 | 105 |
101 // WebContentDecryptionModuleSession::Client | 106 // WebContentDecryptionModuleSession::Client |
102 virtual void message(const unsigned char* message, size_t messageLength, con st WebURL& destinationURL) OVERRIDE; | 107 virtual void message(const unsigned char* message, size_t messageLength, con st WebURL& destinationURL) OVERRIDE; |
103 virtual void ready() OVERRIDE; | 108 virtual void ready() OVERRIDE; |
104 virtual void close() OVERRIDE; | 109 virtual void close() OVERRIDE; |
105 virtual void error(MediaKeyErrorCode, unsigned long systemCode) OVERRIDE; | 110 virtual void error(MediaKeyErrorCode, unsigned long systemCode) OVERRIDE; |
106 virtual void error(WebContentDecryptionModuleException, unsigned long system Code, const WebString& errorMessage) OVERRIDE; | 111 virtual void error(WebContentDecryptionModuleException, unsigned long system Code, const WebString& errorMessage) OVERRIDE; |
107 | 112 |
113 ScriptPromise generateRequestInternal(ScriptState*, const String& initDataTy pe, PassRefPtr<ArrayBuffer> initData); | |
108 ScriptPromise updateInternal(ScriptState*, PassRefPtr<ArrayBuffer> response) ; | 114 ScriptPromise updateInternal(ScriptState*, PassRefPtr<ArrayBuffer> response) ; |
109 | 115 |
116 // Called by NewSessionResult when the new sesison has been created. | |
117 void finishGenerateRequest(); | |
118 | |
110 String m_keySystem; | 119 String m_keySystem; |
ddorwin
2014/09/09 00:44:36
This should be removed in a separate CL. It's no l
jrummell
2014/09/09 19:55:59
Acknowledged.
| |
111 RefPtrWillBeMember<MediaKeyError> m_error; | 120 RefPtrWillBeMember<MediaKeyError> m_error; |
112 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; | 121 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; |
113 OwnPtr<WebContentDecryptionModuleSession> m_session; | 122 OwnPtr<WebContentDecryptionModuleSession> m_session; |
114 | 123 |
115 // Used to determine if MediaKeys is still active. | 124 // Used to determine if MediaKeys is still active. Until the session is |
125 // initialized, keep a hard reference to MediaKeys (as it is needed during | |
126 // initialization). Afterwards, a weak reference is all that is needed. | |
ddorwin
2014/09/09 00:44:36
We discussed a different solution that didn't requ
jrummell
2014/09/09 19:55:59
Done.
| |
127 Member<MediaKeys> m_mediaKeys; | |
116 WeakMember<MediaKeys> m_keys; | 128 WeakMember<MediaKeys> m_keys; |
ddorwin
2014/09/09 00:44:36
Eventually, this should be m_mediaKeys - I think t
jrummell
2014/09/09 19:55:59
Done.
| |
117 | 129 |
130 // Session properties. | |
131 String m_sessionId; | |
ddorwin
2014/09/09 00:44:36
Why is this being tracked here now?
jrummell
2014/09/09 19:55:59
m_session wasn't being created until the generateR
| |
132 double m_expiration; | |
133 String m_sessionType; | |
134 bool m_uninitialized; | |
ddorwin
2014/09/09 00:44:36
m_isUn...
ditto below.
jrummell
2014/09/09 19:56:00
Done.
| |
135 bool m_callable; | |
136 | |
ddorwin
2014/09/09 00:44:36
nit: Keep the states together, separate from the p
jrummell
2014/09/09 19:55:59
Done.
| |
118 // Is the CDM finished with this session? | 137 // Is the CDM finished with this session? |
119 bool m_isClosed; | 138 bool m_isClosed; |
120 | 139 |
121 // Keep track of the closed promise. | 140 // Keep track of the closed promise. |
122 typedef ScriptPromiseProperty<Member<MediaKeySession>, V8UndefinedType, RefP trWillBeMember<DOMException> > ClosedPromise; | 141 typedef ScriptPromiseProperty<Member<MediaKeySession>, V8UndefinedType, RefP trWillBeMember<DOMException> > ClosedPromise; |
123 Member<ClosedPromise> m_closedPromise; | 142 Member<ClosedPromise> m_closedPromise; |
124 | 143 |
125 HeapDeque<Member<PendingAction> > m_pendingActions; | 144 HeapDeque<Member<PendingAction> > m_pendingActions; |
126 Timer<MediaKeySession> m_actionTimer; | 145 Timer<MediaKeySession> m_actionTimer; |
127 }; | 146 }; |
128 | 147 |
129 } // namespace blink | 148 } // namespace blink |
130 | 149 |
131 #endif // MediaKeySession_h | 150 #endif // MediaKeySession_h |
OLD | NEW |