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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 // A class holding a pending action. | 44 // A class holding a pending action. |
45 class MediaKeys::PendingAction : public GarbageCollectedFinalized<MediaKeys::Pen
dingAction> { | 45 class MediaKeys::PendingAction : public GarbageCollectedFinalized<MediaKeys::Pen
dingAction> { |
46 public: | 46 public: |
47 const Persistent<ContentDecryptionModuleResult> result() const | 47 const Persistent<ContentDecryptionModuleResult> result() const |
48 { | 48 { |
49 return m_result; | 49 return m_result; |
50 } | 50 } |
51 | 51 |
52 const RefPtr<DOMArrayBuffer> data() const | 52 DOMArrayBuffer* data() const |
53 { | 53 { |
54 return m_data; | 54 return m_data; |
55 } | 55 } |
56 | 56 |
57 static PendingAction* CreatePendingSetServerCertificate(ContentDecryptionMod
uleResult* result, PassRefPtr<DOMArrayBuffer> serverCertificate) | 57 static PendingAction* CreatePendingSetServerCertificate(ContentDecryptionMod
uleResult* result, DOMArrayBuffer* serverCertificate) |
58 { | 58 { |
59 ASSERT(result); | 59 ASSERT(result); |
60 ASSERT(serverCertificate); | 60 ASSERT(serverCertificate); |
61 return new PendingAction(result, serverCertificate); | 61 return new PendingAction(result, serverCertificate); |
62 } | 62 } |
63 | 63 |
64 ~PendingAction() | 64 ~PendingAction() |
65 { | 65 { |
66 } | 66 } |
67 | 67 |
68 DEFINE_INLINE_TRACE() | 68 DEFINE_INLINE_TRACE() |
69 { | 69 { |
70 visitor->trace(m_result); | 70 visitor->trace(m_result); |
| 71 visitor->trace(m_data); |
71 } | 72 } |
72 | 73 |
73 private: | 74 private: |
74 PendingAction(ContentDecryptionModuleResult* result, PassRefPtr<DOMArrayBuff
er> data) | 75 PendingAction(ContentDecryptionModuleResult* result, DOMArrayBuffer* data) |
75 : m_result(result) | 76 : m_result(result) |
76 , m_data(data) | 77 , m_data(data) |
77 { | 78 { |
78 } | 79 } |
79 | 80 |
80 const Member<ContentDecryptionModuleResult> m_result; | 81 const Member<ContentDecryptionModuleResult> m_result; |
81 const RefPtr<DOMArrayBuffer> m_data; | 82 const Member<DOMArrayBuffer> m_data; |
82 }; | 83 }; |
83 | 84 |
84 MediaKeys* MediaKeys::create(ExecutionContext* context, const WebVector<WebEncry
ptedMediaSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionMod
ule> cdm) | 85 MediaKeys* MediaKeys::create(ExecutionContext* context, const WebVector<WebEncry
ptedMediaSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionMod
ule> cdm) |
85 { | 86 { |
86 MediaKeys* mediaKeys = new MediaKeys(context, supportedSessionTypes, cdm); | 87 MediaKeys* mediaKeys = new MediaKeys(context, supportedSessionTypes, cdm); |
87 mediaKeys->suspendIfNeeded(); | 88 mediaKeys->suspendIfNeeded(); |
88 return mediaKeys; | 89 return mediaKeys; |
89 } | 90 } |
90 | 91 |
91 MediaKeys::MediaKeys(ExecutionContext* context, const WebVector<WebEncryptedMedi
aSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm
) | 92 MediaKeys::MediaKeys(ExecutionContext* context, const WebVector<WebEncryptedMedi
aSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm
) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 scriptState, DOMException::create(InvalidAccessError, "The serverCer
tificate parameter is empty.")); | 147 scriptState, DOMException::create(InvalidAccessError, "The serverCer
tificate parameter is empty.")); |
147 } | 148 } |
148 | 149 |
149 // 2. If the keySystem does not support server certificates, return a | 150 // 2. If the keySystem does not support server certificates, return a |
150 // promise rejected with a new DOMException whose name is | 151 // promise rejected with a new DOMException whose name is |
151 // "NotSupportedError". | 152 // "NotSupportedError". |
152 // (Let the CDM decide whether to support this or not.) | 153 // (Let the CDM decide whether to support this or not.) |
153 | 154 |
154 // 3. Let certificate be a copy of the contents of the serverCertificate | 155 // 3. Let certificate be a copy of the contents of the serverCertificate |
155 // parameter. | 156 // parameter. |
156 RefPtr<DOMArrayBuffer> serverCertificateBuffer = DOMArrayBuffer::create(serv
erCertificate.data(), serverCertificate.byteLength()); | 157 DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create(serverCerti
ficate.data(), serverCertificate.byteLength()); |
157 | 158 |
158 // 4. Let promise be a new promise. | 159 // 4. Let promise be a new promise. |
159 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp
tionModuleResultPromise(scriptState); | 160 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp
tionModuleResultPromise(scriptState); |
160 ScriptPromise promise = result->promise(); | 161 ScriptPromise promise = result->promise(); |
161 | 162 |
162 // 5. Run the following steps asynchronously (documented in timerFired()). | 163 // 5. Run the following steps asynchronously (documented in timerFired()). |
163 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res
ult, serverCertificateBuffer.release())); | 164 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res
ult, serverCertificateBuffer)); |
164 if (!m_timer.isActive()) | 165 if (!m_timer.isActive()) |
165 m_timer.startOneShot(0, BLINK_FROM_HERE); | 166 m_timer.startOneShot(0, BLINK_FROM_HERE); |
166 | 167 |
167 // 6. Return promise. | 168 // 6. Return promise. |
168 return promise; | 169 return promise; |
169 } | 170 } |
170 | 171 |
171 bool MediaKeys::reserveForMediaElement(HTMLMediaElement* mediaElement) | 172 bool MediaKeys::reserveForMediaElement(HTMLMediaElement* mediaElement) |
172 { | 173 { |
173 // If some other HtmlMediaElement already has a reference to us, fail. | 174 // If some other HtmlMediaElement already has a reference to us, fail. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 void MediaKeys::stop() | 266 void MediaKeys::stop() |
266 { | 267 { |
267 ActiveDOMObject::stop(); | 268 ActiveDOMObject::stop(); |
268 | 269 |
269 if (m_timer.isActive()) | 270 if (m_timer.isActive()) |
270 m_timer.stop(); | 271 m_timer.stop(); |
271 m_pendingActions.clear(); | 272 m_pendingActions.clear(); |
272 } | 273 } |
273 | 274 |
274 } // namespace blink | 275 } // namespace blink |
OLD | NEW |