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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 WTF_LOG(Media, "MediaKeySession(%p)::~MediaKeySession", this); | 395 WTF_LOG(Media, "MediaKeySession(%p)::~MediaKeySession", this); |
396 m_session.clear(); | 396 m_session.clear(); |
397 #if !ENABLE(OILPAN) | 397 #if !ENABLE(OILPAN) |
398 // MediaKeySession and m_asyncEventQueue always become unreachable | 398 // MediaKeySession and m_asyncEventQueue always become unreachable |
399 // together. So MediaKeySession and m_asyncEventQueue are destructed in the | 399 // together. So MediaKeySession and m_asyncEventQueue are destructed in the |
400 // same GC. We don't need to call cancelAllEvents explicitly in Oilpan. | 400 // same GC. We don't need to call cancelAllEvents explicitly in Oilpan. |
401 m_asyncEventQueue->cancelAllEvents(); | 401 m_asyncEventQueue->cancelAllEvents(); |
402 #endif | 402 #endif |
403 } | 403 } |
404 | 404 |
405 void MediaKeySession::setError(MediaKeyError* error) | |
406 { | |
407 m_error = error; | |
408 } | |
409 | |
410 String MediaKeySession::sessionId() const | 405 String MediaKeySession::sessionId() const |
411 { | 406 { |
412 return m_session->sessionId(); | 407 return m_session->sessionId(); |
413 } | 408 } |
414 | 409 |
415 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) | 410 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) |
416 { | 411 { |
417 return m_closedPromise->promise(scriptState->world()); | 412 return m_closedPromise->promise(scriptState->world()); |
418 } | 413 } |
419 | 414 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 init.bubbles = false; | 874 init.bubbles = false; |
880 init.cancelable = false; | 875 init.cancelable = false; |
881 init.message = DOMArrayBuffer::create(static_cast<const void*>(message), mes sageLength); | 876 init.message = DOMArrayBuffer::create(static_cast<const void*>(message), mes sageLength); |
882 init.destinationURL = destinationURL.string(); | 877 init.destinationURL = destinationURL.string(); |
883 | 878 |
884 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat e(EventTypeNames::message, init); | 879 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat e(EventTypeNames::message, init); |
885 event->setTarget(this); | 880 event->setTarget(this); |
886 m_asyncEventQueue->enqueueEvent(event.release()); | 881 m_asyncEventQueue->enqueueEvent(event.release()); |
887 } | 882 } |
888 | 883 |
889 void MediaKeySession::ready() | |
890 { | |
891 WTF_LOG(Media, "MediaKeySession(%p)::ready", this); | |
892 | |
893 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::ready); | |
ddorwin
2014/11/03 19:50:50
Did we add this event name? If so, we should remov
jrummell
2014/11/03 20:47:32
Done.
| |
894 event->setTarget(this); | |
895 m_asyncEventQueue->enqueueEvent(event.release()); | |
896 } | |
897 | |
898 void MediaKeySession::close() | 884 void MediaKeySession::close() |
899 { | 885 { |
900 WTF_LOG(Media, "MediaKeySession(%p)::close", this); | 886 WTF_LOG(Media, "MediaKeySession(%p)::close", this); |
901 | 887 |
902 // Once closed, the session can no longer be the target of events from | 888 // Once closed, the session can no longer be the target of events from |
903 // the CDM so this object can be garbage collected. | 889 // the CDM so this object can be garbage collected. |
904 m_isClosed = true; | 890 m_isClosed = true; |
905 | 891 |
906 // Resolve the closed promise. | 892 // Resolve the closed promise. |
907 m_closedPromise->resolve(V8UndefinedType()); | 893 m_closedPromise->resolve(V8UndefinedType()); |
908 } | 894 } |
909 | 895 |
910 // Queue a task to fire a simple event named keyadded at the MediaKeySession obj ect. | |
911 void MediaKeySession::error(MediaKeyErrorCode errorCode, unsigned long systemCod e) | |
912 { | |
913 WTF_LOG(Media, "MediaKeySession(%p)::error: errorCode=%d, systemCode=%lu", t his, errorCode, systemCode); | |
914 | |
915 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
916 switch (errorCode) { | |
917 case MediaKeyErrorCodeUnknown: | |
918 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
919 break; | |
920 case MediaKeyErrorCodeClient: | |
921 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; | |
922 break; | |
923 } | |
924 | |
925 // 1. Create a new MediaKeyError object with the following attributes: | |
926 // code = the appropriate MediaKeyError code | |
927 // systemCode = a Key System-specific value, if provided, and 0 otherwise | |
928 // 2. Set the MediaKeySession object's error attribute to the error object c reated in the previous step. | |
929 m_error = MediaKeyError::create(mediaKeyErrorCode, systemCode); | |
930 | |
931 // 3. queue a task to fire a simple event named keyerror at the MediaKeySess ion object. | |
932 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::error); | |
ddorwin
2014/11/03 19:50:50
ditto
jrummell
2014/11/03 20:47:32
error event used in a bunch of places (e.g. core/e
| |
933 event->setTarget(this); | |
934 m_asyncEventQueue->enqueueEvent(event.release()); | |
935 } | |
936 | |
937 void MediaKeySession::error(WebContentDecryptionModuleException exception, unsig ned long systemCode, const WebString& errorMessage) | |
938 { | |
939 WTF_LOG(Media, "MediaKeySession::error: exception=%d, systemCode=%lu", excep tion, systemCode); | |
940 | |
941 // FIXME: EME-WD MediaKeyError now derives from DOMException. Figure out how | |
942 // to implement this without breaking prefixed EME, which has a totally | |
943 // different definition. The spec may also change to be just a DOMException. | |
944 // For now, simply generate an existing MediaKeyError. | |
945 MediaKeyErrorCode errorCode; | |
946 switch (exception) { | |
947 case WebContentDecryptionModuleExceptionClientError: | |
948 errorCode = MediaKeyErrorCodeClient; | |
949 break; | |
950 default: | |
951 // All other exceptions get converted into Unknown. | |
952 errorCode = MediaKeyErrorCodeUnknown; | |
953 break; | |
954 } | |
955 error(errorCode, systemCode); | |
956 } | |
957 | |
958 void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) | 896 void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) |
959 { | 897 { |
960 m_expiration = updatedExpiryTimeInMS; | 898 m_expiration = updatedExpiryTimeInMS; |
961 } | 899 } |
962 | 900 |
963 const AtomicString& MediaKeySession::interfaceName() const | 901 const AtomicString& MediaKeySession::interfaceName() const |
964 { | 902 { |
965 return EventTargetNames::MediaKeySession; | 903 return EventTargetNames::MediaKeySession; |
966 } | 904 } |
967 | 905 |
(...skipping 25 matching lines...) Expand all Loading... | |
993 m_isClosed = true; | 931 m_isClosed = true; |
994 | 932 |
995 if (m_actionTimer.isActive()) | 933 if (m_actionTimer.isActive()) |
996 m_actionTimer.stop(); | 934 m_actionTimer.stop(); |
997 m_pendingActions.clear(); | 935 m_pendingActions.clear(); |
998 m_asyncEventQueue->close(); | 936 m_asyncEventQueue->close(); |
999 } | 937 } |
1000 | 938 |
1001 void MediaKeySession::trace(Visitor* visitor) | 939 void MediaKeySession::trace(Visitor* visitor) |
1002 { | 940 { |
1003 visitor->trace(m_error); | |
1004 visitor->trace(m_asyncEventQueue); | 941 visitor->trace(m_asyncEventQueue); |
1005 visitor->trace(m_pendingActions); | 942 visitor->trace(m_pendingActions); |
1006 visitor->trace(m_mediaKeys); | 943 visitor->trace(m_mediaKeys); |
1007 visitor->trace(m_closedPromise); | 944 visitor->trace(m_closedPromise); |
1008 EventTargetWithInlineData::trace(visitor); | 945 EventTargetWithInlineData::trace(visitor); |
1009 } | 946 } |
1010 | 947 |
1011 } // namespace blink | 948 } // namespace blink |
OLD | NEW |