| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 WTF_LOG(Media, "MediaKeySession(%p)::~MediaKeySession", this); | 346 WTF_LOG(Media, "MediaKeySession(%p)::~MediaKeySession", this); |
| 347 m_session.clear(); | 347 m_session.clear(); |
| 348 #if !ENABLE(OILPAN) | 348 #if !ENABLE(OILPAN) |
| 349 // MediaKeySession and m_asyncEventQueue always become unreachable | 349 // MediaKeySession and m_asyncEventQueue always become unreachable |
| 350 // together. So MediaKeySession and m_asyncEventQueue are destructed in the | 350 // together. So MediaKeySession and m_asyncEventQueue are destructed in the |
| 351 // same GC. We don't need to call cancelAllEvents explicitly in Oilpan. | 351 // same GC. We don't need to call cancelAllEvents explicitly in Oilpan. |
| 352 m_asyncEventQueue->cancelAllEvents(); | 352 m_asyncEventQueue->cancelAllEvents(); |
| 353 #endif | 353 #endif |
| 354 } | 354 } |
| 355 | 355 |
| 356 void MediaKeySession::setError(MediaKeyError* error) | |
| 357 { | |
| 358 m_error = error; | |
| 359 } | |
| 360 | |
| 361 String MediaKeySession::sessionId() const | 356 String MediaKeySession::sessionId() const |
| 362 { | 357 { |
| 363 return m_session->sessionId(); | 358 return m_session->sessionId(); |
| 364 } | 359 } |
| 365 | 360 |
| 366 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) | 361 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) |
| 367 { | 362 { |
| 368 return m_closedPromise->promise(scriptState->world()); | 363 return m_closedPromise->promise(scriptState->world()); |
| 369 } | 364 } |
| 370 | 365 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 init.bubbles = false; | 825 init.bubbles = false; |
| 831 init.cancelable = false; | 826 init.cancelable = false; |
| 832 init.message = DOMArrayBuffer::create(static_cast<const void*>(message), mes
sageLength); | 827 init.message = DOMArrayBuffer::create(static_cast<const void*>(message), mes
sageLength); |
| 833 init.destinationURL = destinationURL.string(); | 828 init.destinationURL = destinationURL.string(); |
| 834 | 829 |
| 835 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); | 830 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); |
| 836 event->setTarget(this); | 831 event->setTarget(this); |
| 837 m_asyncEventQueue->enqueueEvent(event.release()); | 832 m_asyncEventQueue->enqueueEvent(event.release()); |
| 838 } | 833 } |
| 839 | 834 |
| 840 void MediaKeySession::ready() | |
| 841 { | |
| 842 WTF_LOG(Media, "MediaKeySession(%p)::ready", this); | |
| 843 | |
| 844 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::ready); | |
| 845 event->setTarget(this); | |
| 846 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 847 } | |
| 848 | |
| 849 void MediaKeySession::close() | 835 void MediaKeySession::close() |
| 850 { | 836 { |
| 851 WTF_LOG(Media, "MediaKeySession(%p)::close", this); | 837 WTF_LOG(Media, "MediaKeySession(%p)::close", this); |
| 852 | 838 |
| 853 // Once closed, the session can no longer be the target of events from | 839 // Once closed, the session can no longer be the target of events from |
| 854 // the CDM so this object can be garbage collected. | 840 // the CDM so this object can be garbage collected. |
| 855 m_isClosed = true; | 841 m_isClosed = true; |
| 856 | 842 |
| 857 // Resolve the closed promise. | 843 // Resolve the closed promise. |
| 858 m_closedPromise->resolve(ToV8UndefinedGenerator()); | 844 m_closedPromise->resolve(ToV8UndefinedGenerator()); |
| 859 } | 845 } |
| 860 | 846 |
| 861 // Queue a task to fire a simple event named keyadded at the MediaKeySession obj
ect. | |
| 862 void MediaKeySession::error(MediaKeyErrorCode errorCode, unsigned long systemCod
e) | |
| 863 { | |
| 864 WTF_LOG(Media, "MediaKeySession(%p)::error: errorCode=%d, systemCode=%lu", t
his, errorCode, systemCode); | |
| 865 | |
| 866 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
| 867 switch (errorCode) { | |
| 868 case MediaKeyErrorCodeUnknown: | |
| 869 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
| 870 break; | |
| 871 case MediaKeyErrorCodeClient: | |
| 872 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; | |
| 873 break; | |
| 874 } | |
| 875 | |
| 876 // 1. Create a new MediaKeyError object with the following attributes: | |
| 877 // code = the appropriate MediaKeyError code | |
| 878 // systemCode = a Key System-specific value, if provided, and 0 otherwise | |
| 879 // 2. Set the MediaKeySession object's error attribute to the error object c
reated in the previous step. | |
| 880 m_error = MediaKeyError::create(mediaKeyErrorCode, systemCode); | |
| 881 | |
| 882 // 3. queue a task to fire a simple event named keyerror at the MediaKeySess
ion object. | |
| 883 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::error); | |
| 884 event->setTarget(this); | |
| 885 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 886 } | |
| 887 | |
| 888 void MediaKeySession::error(WebContentDecryptionModuleException exception, unsig
ned long systemCode, const WebString& errorMessage) | |
| 889 { | |
| 890 WTF_LOG(Media, "MediaKeySession::error: exception=%d, systemCode=%lu", excep
tion, systemCode); | |
| 891 | |
| 892 // FIXME: EME-WD MediaKeyError now derives from DOMException. Figure out how | |
| 893 // to implement this without breaking prefixed EME, which has a totally | |
| 894 // different definition. The spec may also change to be just a DOMException. | |
| 895 // For now, simply generate an existing MediaKeyError. | |
| 896 MediaKeyErrorCode errorCode; | |
| 897 switch (exception) { | |
| 898 case WebContentDecryptionModuleExceptionClientError: | |
| 899 errorCode = MediaKeyErrorCodeClient; | |
| 900 break; | |
| 901 default: | |
| 902 // All other exceptions get converted into Unknown. | |
| 903 errorCode = MediaKeyErrorCodeUnknown; | |
| 904 break; | |
| 905 } | |
| 906 error(errorCode, systemCode); | |
| 907 } | |
| 908 | |
| 909 void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) | 847 void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) |
| 910 { | 848 { |
| 911 m_expiration = updatedExpiryTimeInMS; | 849 m_expiration = updatedExpiryTimeInMS; |
| 912 } | 850 } |
| 913 | 851 |
| 914 const AtomicString& MediaKeySession::interfaceName() const | 852 const AtomicString& MediaKeySession::interfaceName() const |
| 915 { | 853 { |
| 916 return EventTargetNames::MediaKeySession; | 854 return EventTargetNames::MediaKeySession; |
| 917 } | 855 } |
| 918 | 856 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 944 m_isClosed = true; | 882 m_isClosed = true; |
| 945 | 883 |
| 946 if (m_actionTimer.isActive()) | 884 if (m_actionTimer.isActive()) |
| 947 m_actionTimer.stop(); | 885 m_actionTimer.stop(); |
| 948 m_pendingActions.clear(); | 886 m_pendingActions.clear(); |
| 949 m_asyncEventQueue->close(); | 887 m_asyncEventQueue->close(); |
| 950 } | 888 } |
| 951 | 889 |
| 952 void MediaKeySession::trace(Visitor* visitor) | 890 void MediaKeySession::trace(Visitor* visitor) |
| 953 { | 891 { |
| 954 visitor->trace(m_error); | |
| 955 visitor->trace(m_asyncEventQueue); | 892 visitor->trace(m_asyncEventQueue); |
| 956 visitor->trace(m_pendingActions); | 893 visitor->trace(m_pendingActions); |
| 957 visitor->trace(m_mediaKeys); | 894 visitor->trace(m_mediaKeys); |
| 958 visitor->trace(m_closedPromise); | 895 visitor->trace(m_closedPromise); |
| 959 EventTargetWithInlineData::trace(visitor); | 896 EventTargetWithInlineData::trace(visitor); |
| 960 } | 897 } |
| 961 | 898 |
| 962 } // namespace blink | 899 } // namespace blink |
| OLD | NEW |