| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // NOTE: Continued from step 2. of MediaKeySession::update() | 125 // NOTE: Continued from step 2. of MediaKeySession::update() |
| 126 // 2.1. Let cdm be the cdm loaded in the MediaKeys constructor. | 126 // 2.1. Let cdm be the cdm loaded in the MediaKeys constructor. |
| 127 // NOTE: This is m_session. | 127 // NOTE: This is m_session. |
| 128 // 2.2. Let 'did store key' be false. | 128 // 2.2. Let 'did store key' be false. |
| 129 // 2.3. Let 'next message' be null. | 129 // 2.3. Let 'next message' be null. |
| 130 // 2.4. Use cdm to handle key. | 130 // 2.4. Use cdm to handle key. |
| 131 m_session->update(*pendingKey); | 131 m_session->update(*pendingKey); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 void MediaKeySession::keyAdded() | 135 // Queue a task to fire a simple event named keymessage at the new object |
| 136 void MediaKeySession::message(const unsigned char* message, size_t messageLength
, const KURL& destinationURL) |
| 136 { | 137 { |
| 137 RefPtr<Event> event = Event::create(EventTypeNames::webkitkeyadded); | 138 MediaKeyMessageEventInit init; |
| 139 init.bubbles = false; |
| 140 init.cancelable = false; |
| 141 init.message = Uint8Array::create(message, messageLength); |
| 142 init.destinationURL = destinationURL; |
| 143 |
| 144 RefPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::create(EventTypeN
ames::message, init); |
| 145 event->setTarget(this); |
| 146 m_asyncEventQueue->enqueueEvent(event.release()); |
| 147 } |
| 148 |
| 149 void MediaKeySession::ready() |
| 150 { |
| 151 RefPtr<Event> event = Event::create(EventTypeNames::ready); |
| 152 event->setTarget(this); |
| 153 m_asyncEventQueue->enqueueEvent(event.release()); |
| 154 } |
| 155 |
| 156 void MediaKeySession::close() |
| 157 { |
| 158 RefPtr<Event> event = Event::create(EventTypeNames::close); |
| 138 event->setTarget(this); | 159 event->setTarget(this); |
| 139 m_asyncEventQueue->enqueueEvent(event.release()); | 160 m_asyncEventQueue->enqueueEvent(event.release()); |
| 140 } | 161 } |
| 141 | 162 |
| 142 // Queue a task to fire a simple event named keyadded at the MediaKeySession obj
ect. | 163 // Queue a task to fire a simple event named keyadded at the MediaKeySession obj
ect. |
| 143 void MediaKeySession::keyError(MediaKeyErrorCode errorCode, unsigned long system
Code) | 164 void MediaKeySession::error(MediaKeyErrorCode errorCode, unsigned long systemCod
e) |
| 144 { | 165 { |
| 145 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | 166 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
| 146 switch (errorCode) { | 167 switch (errorCode) { |
| 147 case UnknownError: | 168 case UnknownError: |
| 148 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | 169 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
| 149 break; | 170 break; |
| 150 case ClientError: | 171 case ClientError: |
| 151 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; | 172 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; |
| 152 break; | 173 break; |
| 153 } | 174 } |
| 154 | 175 |
| 155 // 1. Create a new MediaKeyError object with the following attributes: | 176 // 1. Create a new MediaKeyError object with the following attributes: |
| 156 // code = the appropriate MediaKeyError code | 177 // code = the appropriate MediaKeyError code |
| 157 // systemCode = a Key System-specific value, if provided, and 0 otherwise | 178 // systemCode = a Key System-specific value, if provided, and 0 otherwise |
| 158 // 2. Set the MediaKeySession object's error attribute to the error object c
reated in the previous step. | 179 // 2. Set the MediaKeySession object's error attribute to the error object c
reated in the previous step. |
| 159 m_error = MediaKeyError::create(mediaKeyErrorCode, systemCode); | 180 m_error = MediaKeyError::create(mediaKeyErrorCode, systemCode); |
| 160 | 181 |
| 161 // 3. queue a task to fire a simple event named keyerror at the MediaKeySess
ion object. | 182 // 3. queue a task to fire a simple event named keyerror at the MediaKeySess
ion object. |
| 162 RefPtr<Event> event = Event::create(EventTypeNames::webkitkeyerror); | 183 RefPtr<Event> event = Event::create(EventTypeNames::error); |
| 163 event->setTarget(this); | 184 event->setTarget(this); |
| 164 m_asyncEventQueue->enqueueEvent(event.release()); | 185 m_asyncEventQueue->enqueueEvent(event.release()); |
| 165 } | 186 } |
| 166 | |
| 167 // Queue a task to fire a simple event named keymessage at the new object | |
| 168 void MediaKeySession::keyMessage(const unsigned char* message, size_t messageLen
gth, const KURL& destinationURL) | |
| 169 { | |
| 170 MediaKeyMessageEventInit init; | |
| 171 init.bubbles = false; | |
| 172 init.cancelable = false; | |
| 173 init.message = Uint8Array::create(message, messageLength); | |
| 174 init.destinationURL = destinationURL; | |
| 175 | |
| 176 RefPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::create(EventTypeN
ames::webkitkeymessage, init); | |
| 177 event->setTarget(this); | |
| 178 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 179 } | |
| 180 | 187 |
| 181 const AtomicString& MediaKeySession::interfaceName() const | 188 const AtomicString& MediaKeySession::interfaceName() const |
| 182 { | 189 { |
| 183 return EventTargetNames::MediaKeySession; | 190 return EventTargetNames::MediaKeySession; |
| 184 } | 191 } |
| 185 | 192 |
| 186 ExecutionContext* MediaKeySession::executionContext() const | 193 ExecutionContext* MediaKeySession::executionContext() const |
| 187 { | 194 { |
| 188 return ContextLifecycleObserver::executionContext(); | 195 return ContextLifecycleObserver::executionContext(); |
| 189 } | 196 } |
| 190 | 197 |
| 191 } | 198 } |
| OLD | NEW |