| 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 12 matching lines...) Expand all Loading... |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "modules/encryptedmedia/MediaKeySession.h" | 27 #include "modules/encryptedmedia/MediaKeySession.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/DOMWrapperWorld.h" | 29 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 30 #include "bindings/core/v8/ScriptPromise.h" | 30 #include "bindings/core/v8/ScriptPromise.h" |
| 31 #include "bindings/core/v8/ScriptPromiseResolver.h" | 31 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 32 #include "bindings/core/v8/ScriptState.h" | 32 #include "bindings/core/v8/ScriptState.h" |
| 33 #include "core/dom/DOMArrayBuffer.h" |
| 34 #include "core/dom/DOMArrayBufferView.h" |
| 33 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 34 #include "core/events/Event.h" | 36 #include "core/events/Event.h" |
| 35 #include "core/events/GenericEventQueue.h" | 37 #include "core/events/GenericEventQueue.h" |
| 36 #include "core/html/MediaKeyError.h" | 38 #include "core/html/MediaKeyError.h" |
| 37 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" | 39 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" |
| 38 #include "modules/encryptedmedia/MediaKeys.h" | 40 #include "modules/encryptedmedia/MediaKeys.h" |
| 39 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" | 41 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" |
| 40 #include "platform/ContentDecryptionModuleResult.h" | 42 #include "platform/ContentDecryptionModuleResult.h" |
| 41 #include "platform/ContentType.h" | 43 #include "platform/ContentType.h" |
| 42 #include "platform/Logging.h" | 44 #include "platform/Logging.h" |
| 43 #include "platform/MIMETypeRegistry.h" | 45 #include "platform/MIMETypeRegistry.h" |
| 44 #include "platform/Timer.h" | 46 #include "platform/Timer.h" |
| 45 #include "public/platform/WebContentDecryptionModule.h" | 47 #include "public/platform/WebContentDecryptionModule.h" |
| 46 #include "public/platform/WebContentDecryptionModuleException.h" | 48 #include "public/platform/WebContentDecryptionModuleException.h" |
| 47 #include "public/platform/WebContentDecryptionModuleSession.h" | 49 #include "public/platform/WebContentDecryptionModuleSession.h" |
| 48 #include "public/platform/WebString.h" | 50 #include "public/platform/WebString.h" |
| 49 #include "public/platform/WebURL.h" | 51 #include "public/platform/WebURL.h" |
| 50 #include "wtf/ArrayBuffer.h" | |
| 51 #include "wtf/ArrayBufferView.h" | |
| 52 #include <cmath> | 52 #include <cmath> |
| 53 #include <limits> | 53 #include <limits> |
| 54 | 54 |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 // The list of possible values for |sessionType| passed to createSession(). | 57 // The list of possible values for |sessionType| passed to createSession(). |
| 58 #if ENABLE(ASSERT) | 58 #if ENABLE(ASSERT) |
| 59 const char* kTemporary = "temporary"; | 59 const char* kTemporary = "temporary"; |
| 60 #endif | 60 #endif |
| 61 const char* kPersistent = "persistent"; | 61 const char* kPersistent = "persistent"; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 String MediaKeySession::sessionId() const | 294 String MediaKeySession::sessionId() const |
| 295 { | 295 { |
| 296 return m_session->sessionId(); | 296 return m_session->sessionId(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) | 299 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) |
| 300 { | 300 { |
| 301 return m_closedPromise->promise(scriptState->world()); | 301 return m_closedPromise->promise(scriptState->world()); |
| 302 } | 302 } |
| 303 | 303 |
| 304 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, ArrayBuffer* initData) | 304 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, DOMArrayBuffer* initData) |
| 305 { | 305 { |
| 306 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->data(), ini
tData->byteLength()); | 306 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->data(), ini
tData->byteLength()); |
| 307 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); | 307 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, ArrayBufferView* initData) | 310 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, DOMArrayBufferView* initData) |
| 311 { | 311 { |
| 312 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->baseAddress
(), initData->byteLength()); | 312 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->baseAddress
(), initData->byteLength()); |
| 313 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); | 313 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); |
| 314 } | 314 } |
| 315 | 315 |
| 316 ScriptPromise MediaKeySession::generateRequestInternal(ScriptState* scriptState,
const String& initDataType, PassRefPtr<ArrayBuffer> initData) | 316 ScriptPromise MediaKeySession::generateRequestInternal(ScriptState* scriptState,
const String& initDataType, PassRefPtr<ArrayBuffer> initData) |
| 317 { | 317 { |
| 318 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType
.ascii().data()); | 318 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType
.ascii().data()); |
| 319 | 319 |
| 320 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-generaterequest: | 320 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-generaterequest: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // 10. Run the following steps asynchronously (documented in | 370 // 10. Run the following steps asynchronously (documented in |
| 371 // actionTimerFired()) | 371 // actionTimerFired()) |
| 372 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result,
initDataType, initData)); | 372 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result,
initDataType, initData)); |
| 373 ASSERT(!m_actionTimer.isActive()); | 373 ASSERT(!m_actionTimer.isActive()); |
| 374 m_actionTimer.startOneShot(0, FROM_HERE); | 374 m_actionTimer.startOneShot(0, FROM_HERE); |
| 375 | 375 |
| 376 // 11. Return promise. | 376 // 11. Return promise. |
| 377 return promise; | 377 return promise; |
| 378 } | 378 } |
| 379 | 379 |
| 380 ScriptPromise MediaKeySession::update(ScriptState* scriptState, ArrayBuffer* res
ponse) | 380 ScriptPromise MediaKeySession::update(ScriptState* scriptState, DOMArrayBuffer*
response) |
| 381 { | 381 { |
| 382 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->data(), res
ponse->byteLength()); | 382 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->data(), res
ponse->byteLength()); |
| 383 return updateInternal(scriptState, responseCopy.release()); | 383 return updateInternal(scriptState, responseCopy.release()); |
| 384 } | 384 } |
| 385 | 385 |
| 386 ScriptPromise MediaKeySession::update(ScriptState* scriptState, ArrayBufferView*
response) | 386 ScriptPromise MediaKeySession::update(ScriptState* scriptState, DOMArrayBufferVi
ew* response) |
| 387 { | 387 { |
| 388 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->baseAddress
(), response->byteLength()); | 388 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->baseAddress
(), response->byteLength()); |
| 389 return updateInternal(scriptState, responseCopy.release()); | 389 return updateInternal(scriptState, responseCopy.release()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 ScriptPromise MediaKeySession::updateInternal(ScriptState* scriptState, PassRefP
tr<ArrayBuffer> response) | 392 ScriptPromise MediaKeySession::updateInternal(ScriptState* scriptState, PassRefP
tr<ArrayBuffer> response) |
| 393 { | 393 { |
| 394 WTF_LOG(Media, "MediaKeySession(%p)::update", this); | 394 WTF_LOG(Media, "MediaKeySession(%p)::update", this); |
| 395 ASSERT(!m_isClosed); | 395 ASSERT(!m_isClosed); |
| 396 | 396 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 void MediaKeySession::message(const unsigned char* message, size_t messageLength
, const WebURL& destinationURL) | 617 void MediaKeySession::message(const unsigned char* message, size_t messageLength
, const WebURL& destinationURL) |
| 618 { | 618 { |
| 619 WTF_LOG(Media, "MediaKeySession(%p)::message", this); | 619 WTF_LOG(Media, "MediaKeySession(%p)::message", this); |
| 620 | 620 |
| 621 // Verify that 'message' not fired before session initialization is complete
. | 621 // Verify that 'message' not fired before session initialization is complete
. |
| 622 ASSERT(m_isCallable); | 622 ASSERT(m_isCallable); |
| 623 | 623 |
| 624 MediaKeyMessageEventInit init; | 624 MediaKeyMessageEventInit init; |
| 625 init.bubbles = false; | 625 init.bubbles = false; |
| 626 init.cancelable = false; | 626 init.cancelable = false; |
| 627 init.message = ArrayBuffer::create(static_cast<const void*>(message), messag
eLength); | 627 init.message = DOMArrayBuffer::create(static_cast<const void*>(message), mes
sageLength); |
| 628 init.destinationURL = destinationURL.string(); | 628 init.destinationURL = destinationURL.string(); |
| 629 | 629 |
| 630 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); | 630 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); |
| 631 event->setTarget(this); | 631 event->setTarget(this); |
| 632 m_asyncEventQueue->enqueueEvent(event.release()); | 632 m_asyncEventQueue->enqueueEvent(event.release()); |
| 633 } | 633 } |
| 634 | 634 |
| 635 void MediaKeySession::ready() | 635 void MediaKeySession::ready() |
| 636 { | 636 { |
| 637 WTF_LOG(Media, "MediaKeySession(%p)::ready", this); | 637 WTF_LOG(Media, "MediaKeySession(%p)::ready", this); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 { | 748 { |
| 749 visitor->trace(m_error); | 749 visitor->trace(m_error); |
| 750 visitor->trace(m_asyncEventQueue); | 750 visitor->trace(m_asyncEventQueue); |
| 751 visitor->trace(m_pendingActions); | 751 visitor->trace(m_pendingActions); |
| 752 visitor->trace(m_mediaKeys); | 752 visitor->trace(m_mediaKeys); |
| 753 visitor->trace(m_closedPromise); | 753 visitor->trace(m_closedPromise); |
| 754 EventTargetWithInlineData::trace(visitor); | 754 EventTargetWithInlineData::trace(visitor); |
| 755 } | 755 } |
| 756 | 756 |
| 757 } // namespace blink | 757 } // namespace blink |
| OLD | NEW |