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