| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 Remove | 129 Remove |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 Type getType() const { return m_type; } | 132 Type getType() const { return m_type; } |
| 133 | 133 |
| 134 const Persistent<ContentDecryptionModuleResult> result() const | 134 const Persistent<ContentDecryptionModuleResult> result() const |
| 135 { | 135 { |
| 136 return m_result; | 136 return m_result; |
| 137 } | 137 } |
| 138 | 138 |
| 139 const PassRefPtr<DOMArrayBuffer> data() const | 139 DOMArrayBuffer* data() const |
| 140 { | 140 { |
| 141 ASSERT(m_type == GenerateRequest || m_type == Update); | 141 ASSERT(m_type == GenerateRequest || m_type == Update); |
| 142 return m_data; | 142 return m_data; |
| 143 } | 143 } |
| 144 | 144 |
| 145 WebEncryptedMediaInitDataType initDataType() const | 145 WebEncryptedMediaInitDataType initDataType() const |
| 146 { | 146 { |
| 147 ASSERT(m_type == GenerateRequest); | 147 ASSERT(m_type == GenerateRequest); |
| 148 return m_initDataType; | 148 return m_initDataType; |
| 149 } | 149 } |
| 150 | 150 |
| 151 const String& sessionId() const | 151 const String& sessionId() const |
| 152 { | 152 { |
| 153 ASSERT(m_type == Load); | 153 ASSERT(m_type == Load); |
| 154 return m_stringData; | 154 return m_stringData; |
| 155 } | 155 } |
| 156 | 156 |
| 157 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe
sult* result, WebEncryptedMediaInitDataType initDataType, PassRefPtr<DOMArrayBuf
fer> initData) | 157 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe
sult* result, WebEncryptedMediaInitDataType initDataType, DOMArrayBuffer* initDa
ta) |
| 158 { | 158 { |
| 159 ASSERT(result); | 159 ASSERT(result); |
| 160 ASSERT(initData); | 160 ASSERT(initData); |
| 161 return new PendingAction(GenerateRequest, result, initDataType, initData
, String()); | 161 return new PendingAction(GenerateRequest, result, initDataType, initData
, String()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult
* result, const String& sessionId) | 164 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult
* result, const String& sessionId) |
| 165 { | 165 { |
| 166 ASSERT(result); | 166 ASSERT(result); |
| 167 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un
known, PassRefPtr<DOMArrayBuffer>(), sessionId); | 167 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un
known, nullptr, sessionId); |
| 168 } | 168 } |
| 169 | 169 |
| 170 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res
ult, PassRefPtr<DOMArrayBuffer> data) | 170 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res
ult, DOMArrayBuffer* data) |
| 171 { | 171 { |
| 172 ASSERT(result); | 172 ASSERT(result); |
| 173 ASSERT(data); | 173 ASSERT(data); |
| 174 return new PendingAction(Update, result, WebEncryptedMediaInitDataType::
Unknown, data, String()); | 174 return new PendingAction(Update, result, WebEncryptedMediaInitDataType::
Unknown, data, String()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu
lt) | 177 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu
lt) |
| 178 { | 178 { |
| 179 ASSERT(result); | 179 ASSERT(result); |
| 180 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U
nknown, PassRefPtr<DOMArrayBuffer>(), String()); | 180 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U
nknown, nullptr, String()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res
ult) | 183 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res
ult) |
| 184 { | 184 { |
| 185 ASSERT(result); | 185 ASSERT(result); |
| 186 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType::
Unknown, PassRefPtr<DOMArrayBuffer>(), String()); | 186 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType::
Unknown, nullptr, String()); |
| 187 } | 187 } |
| 188 | 188 |
| 189 ~PendingAction() | 189 ~PendingAction() |
| 190 { | 190 { |
| 191 } | 191 } |
| 192 | 192 |
| 193 DEFINE_INLINE_TRACE() | 193 DEFINE_INLINE_TRACE() |
| 194 { | 194 { |
| 195 visitor->trace(m_result); | 195 visitor->trace(m_result); |
| 196 visitor->trace(m_data); |
| 196 } | 197 } |
| 197 | 198 |
| 198 private: | 199 private: |
| 199 PendingAction(Type type, ContentDecryptionModuleResult* result, WebEncrypted
MediaInitDataType initDataType, PassRefPtr<DOMArrayBuffer> data, const String& s
tringData) | 200 PendingAction(Type type, ContentDecryptionModuleResult* result, WebEncrypted
MediaInitDataType initDataType, DOMArrayBuffer* data, const String& stringData) |
| 200 : m_type(type) | 201 : m_type(type) |
| 201 , m_result(result) | 202 , m_result(result) |
| 202 , m_initDataType(initDataType) | 203 , m_initDataType(initDataType) |
| 203 , m_data(data) | 204 , m_data(data) |
| 204 , m_stringData(stringData) | 205 , m_stringData(stringData) |
| 205 { | 206 { |
| 206 } | 207 } |
| 207 | 208 |
| 208 const Type m_type; | 209 const Type m_type; |
| 209 const Member<ContentDecryptionModuleResult> m_result; | 210 const Member<ContentDecryptionModuleResult> m_result; |
| 210 const WebEncryptedMediaInitDataType m_initDataType; | 211 const WebEncryptedMediaInitDataType m_initDataType; |
| 211 const RefPtr<DOMArrayBuffer> m_data; | 212 const Member<DOMArrayBuffer> m_data; |
| 212 const String m_stringData; | 213 const String m_stringData; |
| 213 }; | 214 }; |
| 214 | 215 |
| 215 // This class wraps the promise resolver used when initializing a new session | 216 // This class wraps the promise resolver used when initializing a new session |
| 216 // and is passed to Chromium to fullfill the promise. This implementation of | 217 // and is passed to Chromium to fullfill the promise. This implementation of |
| 217 // completeWithSession() will resolve the promise with void, while | 218 // completeWithSession() will resolve the promise with void, while |
| 218 // completeWithError() will reject the promise with an exception. complete() | 219 // completeWithError() will reject the promise with an exception. complete() |
| 219 // is not expected to be called, and will reject the promise. | 220 // is not expected to be called, and will reject the promise. |
| 220 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise { | 221 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise { |
| 221 public: | 222 public: |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // (blink side doesn't know what the CDM supports, so the proper check | 427 // (blink side doesn't know what the CDM supports, so the proper check |
| 427 // will be done on the Chromium side. However, we can verify that | 428 // will be done on the Chromium side. However, we can verify that |
| 428 // |initDataType| is one of the registered values.) | 429 // |initDataType| is one of the registered values.) |
| 429 WebEncryptedMediaInitDataType initDataType = EncryptedMediaUtils::convertToI
nitDataType(initDataTypeString); | 430 WebEncryptedMediaInitDataType initDataType = EncryptedMediaUtils::convertToI
nitDataType(initDataTypeString); |
| 430 if (initDataType == WebEncryptedMediaInitDataType::Unknown) { | 431 if (initDataType == WebEncryptedMediaInitDataType::Unknown) { |
| 431 return ScriptPromise::rejectWithDOMException( | 432 return ScriptPromise::rejectWithDOMException( |
| 432 scriptState, DOMException::create(NotSupportedError, "The initializa
tion data type '" + initDataTypeString + "' is not supported.")); | 433 scriptState, DOMException::create(NotSupportedError, "The initializa
tion data type '" + initDataTypeString + "' is not supported.")); |
| 433 } | 434 } |
| 434 | 435 |
| 435 // 6. Let init data be a copy of the contents of the initData parameter. | 436 // 6. Let init data be a copy of the contents of the initData parameter. |
| 436 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::create(initData.data
(), initData.byteLength()); | 437 DOMArrayBuffer* initDataBuffer = DOMArrayBuffer::create(initData.data(), ini
tData.byteLength()); |
| 437 | 438 |
| 438 // 7. Let session type be this object's session type. | 439 // 7. Let session type be this object's session type. |
| 439 // (Done in constructor.) | 440 // (Done in constructor.) |
| 440 | 441 |
| 441 // 8. Let promise be a new promise. | 442 // 8. Let promise be a new promise. |
| 442 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t
his); | 443 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t
his); |
| 443 ScriptPromise promise = result->promise(); | 444 ScriptPromise promise = result->promise(); |
| 444 | 445 |
| 445 // 9. Run the following steps asynchronously (documented in | 446 // 9. Run the following steps asynchronously (documented in |
| 446 // actionTimerFired()) | 447 // actionTimerFired()) |
| 447 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result,
initDataType, initDataBuffer.release())); | 448 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result,
initDataType, initDataBuffer)); |
| 448 ASSERT(!m_actionTimer.isActive()); | 449 ASSERT(!m_actionTimer.isActive()); |
| 449 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 450 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 450 | 451 |
| 451 // 10. Return promise. | 452 // 10. Return promise. |
| 452 return promise; | 453 return promise; |
| 453 } | 454 } |
| 454 | 455 |
| 455 ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess
ionId) | 456 ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess
ionId) |
| 456 { | 457 { |
| 457 WTF_LOG(Media, "MediaKeySession(%p)::load %s", this, sessionId.ascii().data(
)); | 458 WTF_LOG(Media, "MediaKeySession(%p)::load %s", this, sessionId.ascii().data(
)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 return CreateRejectedPromiseNotCallable(scriptState); | 522 return CreateRejectedPromiseNotCallable(scriptState); |
| 522 | 523 |
| 523 // 2. If response is an empty array, return a promise rejected with a | 524 // 2. If response is an empty array, return a promise rejected with a |
| 524 // new DOMException whose name is InvalidAccessError. | 525 // new DOMException whose name is InvalidAccessError. |
| 525 if (!response.byteLength()) { | 526 if (!response.byteLength()) { |
| 526 return ScriptPromise::rejectWithDOMException( | 527 return ScriptPromise::rejectWithDOMException( |
| 527 scriptState, DOMException::create(InvalidAccessError, "The response
parameter is empty.")); | 528 scriptState, DOMException::create(InvalidAccessError, "The response
parameter is empty.")); |
| 528 } | 529 } |
| 529 | 530 |
| 530 // 3. Let response copy be a copy of the contents of the response parameter. | 531 // 3. Let response copy be a copy of the contents of the response parameter. |
| 531 RefPtr<DOMArrayBuffer> responseCopy = DOMArrayBuffer::create(response.data()
, response.byteLength()); | 532 DOMArrayBuffer* responseCopy = DOMArrayBuffer::create(response.data(), respo
nse.byteLength()); |
| 532 | 533 |
| 533 // 4. Let promise be a new promise. | 534 // 4. Let promise be a new promise. |
| 534 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp
tionModuleResultPromise(scriptState); | 535 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp
tionModuleResultPromise(scriptState); |
| 535 ScriptPromise promise = result->promise(); | 536 ScriptPromise promise = result->promise(); |
| 536 | 537 |
| 537 // 5. Run the following steps asynchronously (documented in | 538 // 5. Run the following steps asynchronously (documented in |
| 538 // actionTimerFired()) | 539 // actionTimerFired()) |
| 539 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC
opy.release())); | 540 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC
opy)); |
| 540 if (!m_actionTimer.isActive()) | 541 if (!m_actionTimer.isActive()) |
| 541 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 542 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 542 | 543 |
| 543 // 6. Return promise. | 544 // 6. Return promise. |
| 544 return promise; | 545 return promise; |
| 545 } | 546 } |
| 546 | 547 |
| 547 ScriptPromise MediaKeySession::close(ScriptState* scriptState) | 548 ScriptPromise MediaKeySession::close(ScriptState* scriptState) |
| 548 { | 549 { |
| 549 WTF_LOG(Media, "MediaKeySession(%p)::close", this); | 550 WTF_LOG(Media, "MediaKeySession(%p)::close", this); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 visitor->trace(m_asyncEventQueue); | 923 visitor->trace(m_asyncEventQueue); |
| 923 visitor->trace(m_pendingActions); | 924 visitor->trace(m_pendingActions); |
| 924 visitor->trace(m_mediaKeys); | 925 visitor->trace(m_mediaKeys); |
| 925 visitor->trace(m_keyStatusesMap); | 926 visitor->trace(m_keyStatusesMap); |
| 926 visitor->trace(m_closedPromise); | 927 visitor->trace(m_closedPromise); |
| 927 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace(
visitor); | 928 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace(
visitor); |
| 928 ActiveDOMObject::trace(visitor); | 929 ActiveDOMObject::trace(visitor); |
| 929 } | 930 } |
| 930 | 931 |
| 931 } // namespace blink | 932 } // namespace blink |
| OLD | NEW |