| 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/ASCIICType.h" | 52 #include "wtf/ASCIICType.h" |
| 51 #include "wtf/ArrayBuffer.h" | |
| 52 #include "wtf/ArrayBufferView.h" | |
| 53 #include <cmath> | 53 #include <cmath> |
| 54 #include <limits> | 54 #include <limits> |
| 55 | 55 |
| 56 namespace { | 56 namespace { |
| 57 | 57 |
| 58 // The list of possible values for |sessionType|. | 58 // The list of possible values for |sessionType|. |
| 59 const char* kTemporary = "temporary"; | 59 const char* kTemporary = "temporary"; |
| 60 const char* kPersistent = "persistent"; | 60 const char* kPersistent = "persistent"; |
| 61 | 61 |
| 62 // Minimum and maximum length for session ids. | 62 // Minimum and maximum length for session ids. |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 String MediaKeySession::sessionId() const | 410 String MediaKeySession::sessionId() const |
| 411 { | 411 { |
| 412 return m_session->sessionId(); | 412 return m_session->sessionId(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) | 415 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) |
| 416 { | 416 { |
| 417 return m_closedPromise->promise(scriptState->world()); | 417 return m_closedPromise->promise(scriptState->world()); |
| 418 } | 418 } |
| 419 | 419 |
| 420 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, ArrayBuffer* initData) | 420 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, DOMArrayBuffer* initData) |
| 421 { | 421 { |
| 422 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->data(), ini
tData->byteLength()); | 422 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->data(), ini
tData->byteLength()); |
| 423 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); | 423 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, ArrayBufferView* initData) | 426 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, DOMArrayBufferView* initData) |
| 427 { | 427 { |
| 428 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->baseAddress
(), initData->byteLength()); | 428 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->baseAddress
(), initData->byteLength()); |
| 429 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); | 429 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea
se()); |
| 430 } | 430 } |
| 431 | 431 |
| 432 ScriptPromise MediaKeySession::generateRequestInternal(ScriptState* scriptState,
const String& initDataType, PassRefPtr<ArrayBuffer> initData) | 432 ScriptPromise MediaKeySession::generateRequestInternal(ScriptState* scriptState,
const String& initDataType, PassRefPtr<ArrayBuffer> initData) |
| 433 { | 433 { |
| 434 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType
.ascii().data()); | 434 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType
.ascii().data()); |
| 435 | 435 |
| 436 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-generaterequest: | 436 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-generaterequest: |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 // 8. Run the following steps asynchronously (documented in | 542 // 8. Run the following steps asynchronously (documented in |
| 543 // actionTimerFired()) | 543 // actionTimerFired()) |
| 544 m_pendingActions.append(PendingAction::CreatePendingLoadRequest(result, sess
ionId)); | 544 m_pendingActions.append(PendingAction::CreatePendingLoadRequest(result, sess
ionId)); |
| 545 ASSERT(!m_actionTimer.isActive()); | 545 ASSERT(!m_actionTimer.isActive()); |
| 546 m_actionTimer.startOneShot(0, FROM_HERE); | 546 m_actionTimer.startOneShot(0, FROM_HERE); |
| 547 | 547 |
| 548 // 9. Return promise. | 548 // 9. Return promise. |
| 549 return promise; | 549 return promise; |
| 550 } | 550 } |
| 551 | 551 |
| 552 ScriptPromise MediaKeySession::update(ScriptState* scriptState, ArrayBuffer* res
ponse) | 552 ScriptPromise MediaKeySession::update(ScriptState* scriptState, DOMArrayBuffer*
response) |
| 553 { | 553 { |
| 554 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->data(), res
ponse->byteLength()); | 554 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->data(), res
ponse->byteLength()); |
| 555 return updateInternal(scriptState, responseCopy.release()); | 555 return updateInternal(scriptState, responseCopy.release()); |
| 556 } | 556 } |
| 557 | 557 |
| 558 ScriptPromise MediaKeySession::update(ScriptState* scriptState, ArrayBufferView*
response) | 558 ScriptPromise MediaKeySession::update(ScriptState* scriptState, DOMArrayBufferVi
ew* response) |
| 559 { | 559 { |
| 560 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->baseAddress
(), response->byteLength()); | 560 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->baseAddress
(), response->byteLength()); |
| 561 return updateInternal(scriptState, responseCopy.release()); | 561 return updateInternal(scriptState, responseCopy.release()); |
| 562 } | 562 } |
| 563 | 563 |
| 564 ScriptPromise MediaKeySession::updateInternal(ScriptState* scriptState, PassRefP
tr<ArrayBuffer> response) | 564 ScriptPromise MediaKeySession::updateInternal(ScriptState* scriptState, PassRefP
tr<ArrayBuffer> response) |
| 565 { | 565 { |
| 566 WTF_LOG(Media, "MediaKeySession(%p)::update", this); | 566 WTF_LOG(Media, "MediaKeySession(%p)::update", this); |
| 567 ASSERT(!m_isClosed); | 567 ASSERT(!m_isClosed); |
| 568 | 568 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 void MediaKeySession::message(const unsigned char* message, size_t messageLength
, const WebURL& destinationURL) | 871 void MediaKeySession::message(const unsigned char* message, size_t messageLength
, const WebURL& destinationURL) |
| 872 { | 872 { |
| 873 WTF_LOG(Media, "MediaKeySession(%p)::message", this); | 873 WTF_LOG(Media, "MediaKeySession(%p)::message", this); |
| 874 | 874 |
| 875 // Verify that 'message' not fired before session initialization is complete
. | 875 // Verify that 'message' not fired before session initialization is complete
. |
| 876 ASSERT(m_isCallable); | 876 ASSERT(m_isCallable); |
| 877 | 877 |
| 878 MediaKeyMessageEventInit init; | 878 MediaKeyMessageEventInit init; |
| 879 init.bubbles = false; | 879 init.bubbles = false; |
| 880 init.cancelable = false; | 880 init.cancelable = false; |
| 881 init.message = ArrayBuffer::create(static_cast<const void*>(message), messag
eLength); | 881 init.message = DOMArrayBuffer::create(static_cast<const void*>(message), mes
sageLength); |
| 882 init.destinationURL = destinationURL.string(); | 882 init.destinationURL = destinationURL.string(); |
| 883 | 883 |
| 884 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); | 884 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); |
| 885 event->setTarget(this); | 885 event->setTarget(this); |
| 886 m_asyncEventQueue->enqueueEvent(event.release()); | 886 m_asyncEventQueue->enqueueEvent(event.release()); |
| 887 } | 887 } |
| 888 | 888 |
| 889 void MediaKeySession::ready() | 889 void MediaKeySession::ready() |
| 890 { | 890 { |
| 891 WTF_LOG(Media, "MediaKeySession(%p)::ready", this); | 891 WTF_LOG(Media, "MediaKeySession(%p)::ready", this); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 { | 1002 { |
| 1003 visitor->trace(m_error); | 1003 visitor->trace(m_error); |
| 1004 visitor->trace(m_asyncEventQueue); | 1004 visitor->trace(m_asyncEventQueue); |
| 1005 visitor->trace(m_pendingActions); | 1005 visitor->trace(m_pendingActions); |
| 1006 visitor->trace(m_mediaKeys); | 1006 visitor->trace(m_mediaKeys); |
| 1007 visitor->trace(m_closedPromise); | 1007 visitor->trace(m_closedPromise); |
| 1008 EventTargetWithInlineData::trace(visitor); | 1008 EventTargetWithInlineData::trace(visitor); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 } // namespace blink | 1011 } // namespace blink |
| OLD | NEW |