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