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 String sessionId() const; |
73 ScriptPromise closed(ScriptState*); | 73 ScriptPromise closed(ScriptState*); |
74 | 74 |
| 75 ScriptPromise generateRequest(ScriptState*, const String& initDataType, Arra
yBuffer* initData); |
| 76 ScriptPromise generateRequest(ScriptState*, const String& initDataType, Arra
yBufferView* initData); |
| 77 |
75 void setError(MediaKeyError*); | 78 void setError(MediaKeyError*); |
76 MediaKeyError* error() { return m_error.get(); } | 79 MediaKeyError* error() { return m_error.get(); } |
77 | 80 |
78 ScriptPromise update(ScriptState*, ArrayBuffer* response); | 81 ScriptPromise update(ScriptState*, ArrayBuffer* response); |
79 ScriptPromise update(ScriptState*, ArrayBufferView* response); | 82 ScriptPromise update(ScriptState*, ArrayBufferView* response); |
80 ScriptPromise release(ScriptState*); | 83 ScriptPromise release(ScriptState*); |
81 | 84 |
82 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); | 85 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); |
83 | 86 |
84 // EventTarget | 87 // EventTarget |
85 virtual const AtomicString& interfaceName() const OVERRIDE; | 88 virtual const AtomicString& interfaceName() const OVERRIDE; |
86 virtual ExecutionContext* executionContext() const OVERRIDE; | 89 virtual ExecutionContext* executionContext() const OVERRIDE; |
87 | 90 |
88 // ActiveDOMObject | 91 // ActiveDOMObject |
89 virtual bool hasPendingActivity() const OVERRIDE; | 92 virtual bool hasPendingActivity() const OVERRIDE; |
90 virtual void stop() OVERRIDE; | 93 virtual void stop() OVERRIDE; |
91 | 94 |
92 virtual void trace(Visitor*) OVERRIDE; | 95 virtual void trace(Visitor*) OVERRIDE; |
93 | 96 |
94 private: | 97 private: |
95 class PendingAction; | 98 class PendingAction; |
96 friend class MediaKeySessionInitializer; | 99 friend class NewSessionResult; |
97 | 100 |
98 MediaKeySession(ExecutionContext*, MediaKeys*, PassOwnPtr<WebContentDecrypti
onModuleSession>); | 101 MediaKeySession(ScriptState*, MediaKeys*, const String& sessionType); |
| 102 |
99 void actionTimerFired(Timer<MediaKeySession>*); | 103 void actionTimerFired(Timer<MediaKeySession>*); |
100 | 104 |
101 // WebContentDecryptionModuleSession::Client | 105 // WebContentDecryptionModuleSession::Client |
102 virtual void message(const unsigned char* message, size_t messageLength, con
st WebURL& destinationURL) OVERRIDE; | 106 virtual void message(const unsigned char* message, size_t messageLength, con
st WebURL& destinationURL) OVERRIDE; |
103 virtual void ready() OVERRIDE; | 107 virtual void ready() OVERRIDE; |
104 virtual void close() OVERRIDE; | 108 virtual void close() OVERRIDE; |
105 virtual void error(MediaKeyErrorCode, unsigned long systemCode) OVERRIDE; | 109 virtual void error(MediaKeyErrorCode, unsigned long systemCode) OVERRIDE; |
106 virtual void error(WebContentDecryptionModuleException, unsigned long system
Code, const WebString& errorMessage) OVERRIDE; | 110 virtual void error(WebContentDecryptionModuleException, unsigned long system
Code, const WebString& errorMessage) OVERRIDE; |
107 | 111 |
| 112 ScriptPromise generateRequestInternal(ScriptState*, const String& initDataTy
pe, PassRefPtr<ArrayBuffer> initData); |
108 ScriptPromise updateInternal(ScriptState*, PassRefPtr<ArrayBuffer> response)
; | 113 ScriptPromise updateInternal(ScriptState*, PassRefPtr<ArrayBuffer> response)
; |
109 | 114 |
| 115 // Called by NewSessionResult when the new sesison has been created. |
| 116 void finishGenerateRequest(); |
| 117 |
110 String m_keySystem; | 118 String m_keySystem; |
111 RefPtrWillBeMember<MediaKeyError> m_error; | 119 RefPtrWillBeMember<MediaKeyError> m_error; |
112 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; | 120 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; |
113 OwnPtr<WebContentDecryptionModuleSession> m_session; | 121 OwnPtr<WebContentDecryptionModuleSession> m_session; |
114 | 122 |
115 // Used to determine if MediaKeys is still active. | 123 // Used to determine if MediaKeys is still active. |
116 WeakMember<MediaKeys> m_keys; | 124 WeakMember<MediaKeys> m_mediaKeys; |
117 | 125 |
118 // Is the CDM finished with this session? | 126 // Session properties. |
119 bool m_isClosed; | 127 String m_sessionType; |
| 128 |
| 129 // Session states. |
| 130 bool m_isUninitialized; |
| 131 bool m_isCallable; |
| 132 bool m_isClosed; // Is the CDM finished with this session? |
120 | 133 |
121 // Keep track of the closed promise. | 134 // Keep track of the closed promise. |
122 typedef ScriptPromiseProperty<Member<MediaKeySession>, V8UndefinedType, RefP
trWillBeMember<DOMException> > ClosedPromise; | 135 typedef ScriptPromiseProperty<Member<MediaKeySession>, V8UndefinedType, RefP
trWillBeMember<DOMException> > ClosedPromise; |
123 Member<ClosedPromise> m_closedPromise; | 136 Member<ClosedPromise> m_closedPromise; |
124 | 137 |
125 HeapDeque<Member<PendingAction> > m_pendingActions; | 138 HeapDeque<Member<PendingAction> > m_pendingActions; |
126 Timer<MediaKeySession> m_actionTimer; | 139 Timer<MediaKeySession> m_actionTimer; |
127 }; | 140 }; |
128 | 141 |
129 } // namespace blink | 142 } // namespace blink |
130 | 143 |
131 #endif // MediaKeySession_h | 144 #endif // MediaKeySession_h |
OLD | NEW |