| 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 20 matching lines...) Expand all Loading... |
| 31 #include "bindings/core/v8/ScriptState.h" | 31 #include "bindings/core/v8/ScriptState.h" |
| 32 #include "core/dom/DOMArrayBuffer.h" | 32 #include "core/dom/DOMArrayBuffer.h" |
| 33 #include "core/dom/DOMException.h" | 33 #include "core/dom/DOMException.h" |
| 34 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 35 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
| 36 #include "core/events/GenericEventQueue.h" | 36 #include "core/events/GenericEventQueue.h" |
| 37 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" | 37 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" |
| 38 #include "modules/encryptedmedia/EncryptedMediaUtils.h" | 38 #include "modules/encryptedmedia/EncryptedMediaUtils.h" |
| 39 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" | 39 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" |
| 40 #include "modules/encryptedmedia/MediaKeys.h" | 40 #include "modules/encryptedmedia/MediaKeys.h" |
| 41 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResultPromise.h" | |
| 42 #include "platform/ContentDecryptionModuleResult.h" | 41 #include "platform/ContentDecryptionModuleResult.h" |
| 43 #include "platform/ContentType.h" | 42 #include "platform/ContentType.h" |
| 44 #include "platform/Timer.h" | 43 #include "platform/Timer.h" |
| 45 #include "public/platform/WebContentDecryptionModule.h" | 44 #include "public/platform/WebContentDecryptionModule.h" |
| 46 #include "public/platform/WebContentDecryptionModuleException.h" | 45 #include "public/platform/WebContentDecryptionModuleException.h" |
| 47 #include "public/platform/WebContentDecryptionModuleSession.h" | 46 #include "public/platform/WebContentDecryptionModuleSession.h" |
| 48 #include "public/platform/WebEncryptedMediaKeyInformation.h" | 47 #include "public/platform/WebEncryptedMediaKeyInformation.h" |
| 49 #include "public/platform/WebString.h" | 48 #include "public/platform/WebString.h" |
| 50 #include "public/platform/WebURL.h" | 49 #include "public/platform/WebURL.h" |
| 51 #include "wtf/ASCIICType.h" | 50 #include "wtf/ASCIICType.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 284 |
| 286 DEFINE_INLINE_TRACE() { | 285 DEFINE_INLINE_TRACE() { |
| 287 visitor->trace(m_session); | 286 visitor->trace(m_session); |
| 288 ContentDecryptionModuleResultPromise::trace(visitor); | 287 ContentDecryptionModuleResultPromise::trace(visitor); |
| 289 } | 288 } |
| 290 | 289 |
| 291 private: | 290 private: |
| 292 Member<MediaKeySession> m_session; | 291 Member<MediaKeySession> m_session; |
| 293 }; | 292 }; |
| 294 | 293 |
| 294 // This class wraps the promise resolver used by update/close/remove. The |
| 295 // implementation of complete() will resolve the promise with void. All other |
| 296 // complete() methods are not expected to be called (and will reject the |
| 297 // promise). |
| 298 class SimpleResultPromise : public ContentDecryptionModuleResultPromise { |
| 299 public: |
| 300 SimpleResultPromise(ScriptState* scriptState, MediaKeySession* session) |
| 301 : ContentDecryptionModuleResultPromise(scriptState), m_session(session) {} |
| 302 |
| 303 ~SimpleResultPromise() override {} |
| 304 |
| 305 // ContentDecryptionModuleResultPromise implementation. |
| 306 void complete() override { resolve(); } |
| 307 |
| 308 DEFINE_INLINE_TRACE() { |
| 309 visitor->trace(m_session); |
| 310 ContentDecryptionModuleResultPromise::trace(visitor); |
| 311 } |
| 312 |
| 313 private: |
| 314 Member<MediaKeySession> m_session; |
| 315 }; |
| 316 |
| 295 MediaKeySession* MediaKeySession::create( | 317 MediaKeySession* MediaKeySession::create( |
| 296 ScriptState* scriptState, | 318 ScriptState* scriptState, |
| 297 MediaKeys* mediaKeys, | 319 MediaKeys* mediaKeys, |
| 298 WebEncryptedMediaSessionType sessionType) { | 320 WebEncryptedMediaSessionType sessionType) { |
| 299 MediaKeySession* session = | 321 MediaKeySession* session = |
| 300 new MediaKeySession(scriptState, mediaKeys, sessionType); | 322 new MediaKeySession(scriptState, mediaKeys, sessionType); |
| 301 session->suspendIfNeeded(); | 323 session->suspendIfNeeded(); |
| 302 return session; | 324 return session; |
| 303 } | 325 } |
| 304 | 326 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 return ScriptPromise::rejectWithDOMException( | 561 return ScriptPromise::rejectWithDOMException( |
| 540 scriptState, DOMException::create(InvalidAccessError, | 562 scriptState, DOMException::create(InvalidAccessError, |
| 541 "The response parameter is empty.")); | 563 "The response parameter is empty.")); |
| 542 } | 564 } |
| 543 | 565 |
| 544 // 3. Let response copy be a copy of the contents of the response parameter. | 566 // 3. Let response copy be a copy of the contents of the response parameter. |
| 545 DOMArrayBuffer* responseCopy = | 567 DOMArrayBuffer* responseCopy = |
| 546 DOMArrayBuffer::create(response.data(), response.byteLength()); | 568 DOMArrayBuffer::create(response.data(), response.byteLength()); |
| 547 | 569 |
| 548 // 4. Let promise be a new promise. | 570 // 4. Let promise be a new promise. |
| 549 SimpleContentDecryptionModuleResultPromise* result = | 571 SimpleResultPromise* result = new SimpleResultPromise(scriptState, this); |
| 550 new SimpleContentDecryptionModuleResultPromise(scriptState); | |
| 551 ScriptPromise promise = result->promise(); | 572 ScriptPromise promise = result->promise(); |
| 552 | 573 |
| 553 // 5. Run the following steps asynchronously (documented in | 574 // 5. Run the following steps asynchronously (documented in |
| 554 // actionTimerFired()) | 575 // actionTimerFired()) |
| 555 m_pendingActions.append( | 576 m_pendingActions.append( |
| 556 PendingAction::CreatePendingUpdate(result, responseCopy)); | 577 PendingAction::CreatePendingUpdate(result, responseCopy)); |
| 557 if (!m_actionTimer.isActive()) | 578 if (!m_actionTimer.isActive()) |
| 558 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 579 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 559 | 580 |
| 560 // 6. Return promise. | 581 // 6. Return promise. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 573 // with a new DOMException whose name is "InvalidStateError". | 594 // with a new DOMException whose name is "InvalidStateError". |
| 574 if (!m_isCallable) | 595 if (!m_isCallable) |
| 575 return CreateRejectedPromiseNotCallable(scriptState); | 596 return CreateRejectedPromiseNotCallable(scriptState); |
| 576 | 597 |
| 577 // 2. If the Session Close algorithm has been run on this object, | 598 // 2. If the Session Close algorithm has been run on this object, |
| 578 // return a resolved promise. | 599 // return a resolved promise. |
| 579 if (m_isClosed) | 600 if (m_isClosed) |
| 580 return ScriptPromise::cast(scriptState, ScriptValue()); | 601 return ScriptPromise::cast(scriptState, ScriptValue()); |
| 581 | 602 |
| 582 // 3. Let promise be a new promise. | 603 // 3. Let promise be a new promise. |
| 583 SimpleContentDecryptionModuleResultPromise* result = | 604 SimpleResultPromise* result = new SimpleResultPromise(scriptState, this); |
| 584 new SimpleContentDecryptionModuleResultPromise(scriptState); | |
| 585 ScriptPromise promise = result->promise(); | 605 ScriptPromise promise = result->promise(); |
| 586 | 606 |
| 587 // 4. Run the following steps asynchronously (documented in | 607 // 4. Run the following steps asynchronously (documented in |
| 588 // actionTimerFired()). | 608 // actionTimerFired()). |
| 589 m_pendingActions.append(PendingAction::CreatePendingClose(result)); | 609 m_pendingActions.append(PendingAction::CreatePendingClose(result)); |
| 590 if (!m_actionTimer.isActive()) | 610 if (!m_actionTimer.isActive()) |
| 591 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 611 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 592 | 612 |
| 593 // 5. Return promise. | 613 // 5. Return promise. |
| 594 return promise; | 614 return promise; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 620 // 3. If the Session Close algorithm has been run on this object, return a | 640 // 3. If the Session Close algorithm has been run on this object, return a |
| 621 // promise rejected with a new DOMException whose name is | 641 // promise rejected with a new DOMException whose name is |
| 622 // "InvalidStateError". | 642 // "InvalidStateError". |
| 623 if (m_isClosed) { | 643 if (m_isClosed) { |
| 624 return ScriptPromise::rejectWithDOMException( | 644 return ScriptPromise::rejectWithDOMException( |
| 625 scriptState, DOMException::create(InvalidStateError, | 645 scriptState, DOMException::create(InvalidStateError, |
| 626 "The session is already closed.")); | 646 "The session is already closed.")); |
| 627 } | 647 } |
| 628 | 648 |
| 629 // 4. Let promise be a new promise. | 649 // 4. Let promise be a new promise. |
| 630 SimpleContentDecryptionModuleResultPromise* result = | 650 SimpleResultPromise* result = new SimpleResultPromise(scriptState, this); |
| 631 new SimpleContentDecryptionModuleResultPromise(scriptState); | |
| 632 ScriptPromise promise = result->promise(); | 651 ScriptPromise promise = result->promise(); |
| 633 | 652 |
| 634 // 5. Run the following steps asynchronously (documented in | 653 // 5. Run the following steps asynchronously (documented in |
| 635 // actionTimerFired()). | 654 // actionTimerFired()). |
| 636 m_pendingActions.append(PendingAction::CreatePendingRemove(result)); | 655 m_pendingActions.append(PendingAction::CreatePendingRemove(result)); |
| 637 if (!m_actionTimer.isActive()) | 656 if (!m_actionTimer.isActive()) |
| 638 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 657 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 639 | 658 |
| 640 // 6. Return promise. | 659 // 6. Return promise. |
| 641 return promise; | 660 return promise; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 visitor->trace(m_asyncEventQueue); | 976 visitor->trace(m_asyncEventQueue); |
| 958 visitor->trace(m_pendingActions); | 977 visitor->trace(m_pendingActions); |
| 959 visitor->trace(m_mediaKeys); | 978 visitor->trace(m_mediaKeys); |
| 960 visitor->trace(m_keyStatusesMap); | 979 visitor->trace(m_keyStatusesMap); |
| 961 visitor->trace(m_closedPromise); | 980 visitor->trace(m_closedPromise); |
| 962 EventTargetWithInlineData::trace(visitor); | 981 EventTargetWithInlineData::trace(visitor); |
| 963 ActiveDOMObject::trace(visitor); | 982 ActiveDOMObject::trace(visitor); |
| 964 } | 983 } |
| 965 | 984 |
| 966 } // namespace blink | 985 } // namespace blink |
| OLD | NEW |