Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "modules/encryptedmedia/MediaKeySession.h" | 27 #include "modules/encryptedmedia/MediaKeySession.h" |
| 28 | 28 |
| 29 #include "bindings/v8/ExceptionState.h" | 29 #include "bindings/v8/ExceptionState.h" |
| 30 #include "core/events/Event.h" | 30 #include "core/events/Event.h" |
| 31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
| 32 #include "core/events/GenericEventQueue.h" | 32 #include "core/events/GenericEventQueue.h" |
| 33 #include "core/html/MediaKeyError.h" | 33 #include "core/html/MediaKeyError.h" |
| 34 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" | 34 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" |
| 35 #include "modules/encryptedmedia/MediaKeys.h" | 35 #include "modules/encryptedmedia/MediaKeys.h" |
| 36 #include "platform/Logging.h" | 36 #include "platform/Logging.h" |
| 37 #include "platform/drm/ContentDecryptionModule.h" | 37 #include "public/platform/WebContentDecryptionModule.h" |
| 38 #include "public/platform/WebString.h" | |
| 39 #include "public/platform/WebURL.h" | |
| 38 | 40 |
| 39 namespace WebCore { | 41 namespace WebCore { |
| 40 | 42 |
| 41 PassOwnPtr<MediaKeySession::PendingAction> MediaKeySession::PendingAction::Creat ePendingUpdate(PassRefPtr<Uint8Array> data) | 43 PassOwnPtr<MediaKeySession::PendingAction> MediaKeySession::PendingAction::Creat ePendingUpdate(PassRefPtr<Uint8Array> data) |
| 42 { | 44 { |
| 43 return adoptPtr(new PendingAction(Update, data)); | 45 return adoptPtr(new PendingAction(Update, data)); |
|
acolwell GONE FROM CHROMIUM
2014/03/04 00:39:26
nit: Put an ASSERT(data) here since the code below
jrummell
2014/03/04 01:13:28
Done.
| |
| 44 } | 46 } |
| 45 | 47 |
| 46 PassOwnPtr<MediaKeySession::PendingAction> MediaKeySession::PendingAction::Creat ePendingRelease() | 48 PassOwnPtr<MediaKeySession::PendingAction> MediaKeySession::PendingAction::Creat ePendingRelease() |
| 47 { | 49 { |
| 48 return adoptPtr(new PendingAction(Release, PassRefPtr<Uint8Array>())); | 50 return adoptPtr(new PendingAction(Release, PassRefPtr<Uint8Array>())); |
| 49 } | 51 } |
| 50 | 52 |
| 51 MediaKeySession::PendingAction::PendingAction(Type type, PassRefPtr<Uint8Array> data) | 53 MediaKeySession::PendingAction::PendingAction(Type type, PassRefPtr<Uint8Array> data) |
| 52 : type(type) | 54 : type(type) |
| 53 , data(data) | 55 , data(data) |
| 54 { | 56 { |
| 55 } | 57 } |
| 56 | 58 |
| 57 MediaKeySession::PendingAction::~PendingAction() | 59 MediaKeySession::PendingAction::~PendingAction() |
| 58 { | 60 { |
| 59 } | 61 } |
| 60 | 62 |
| 61 PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeySession::create(ExecutionContext * context, ContentDecryptionModule* cdm, WeakPtr<MediaKeys> keys) | 63 PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeySession::create(ExecutionContext * context, blink::WebContentDecryptionModule* cdm, WeakPtr<MediaKeys> keys) |
| 62 { | 64 { |
| 63 RefPtrWillBeRawPtr<MediaKeySession> session(adoptRefWillBeRefCountedGarbageC ollected(new MediaKeySession(context, cdm, keys))); | 65 RefPtrWillBeRawPtr<MediaKeySession> session(adoptRefWillBeRefCountedGarbageC ollected(new MediaKeySession(context, cdm, keys))); |
| 64 session->suspendIfNeeded(); | 66 session->suspendIfNeeded(); |
| 65 return session.release(); | 67 return session.release(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 MediaKeySession::MediaKeySession(ExecutionContext* context, ContentDecryptionMod ule* cdm, WeakPtr<MediaKeys> keys) | 70 MediaKeySession::MediaKeySession(ExecutionContext* context, blink::WebContentDec ryptionModule* cdm, WeakPtr<MediaKeys> keys) |
| 69 : ActiveDOMObject(context) | 71 : ActiveDOMObject(context) |
| 70 , m_keySystem(keys->keySystem()) | 72 , m_keySystem(keys->keySystem()) |
| 71 , m_asyncEventQueue(GenericEventQueue::create(this)) | 73 , m_asyncEventQueue(GenericEventQueue::create(this)) |
| 72 , m_session(cdm->createSession(this)) | 74 , m_session(adoptPtr(cdm->createSession(this))) |
| 73 , m_keys(keys) | 75 , m_keys(keys) |
| 74 , m_isClosed(false) | 76 , m_isClosed(false) |
| 75 , m_actionTimer(this, &MediaKeySession::actionTimerFired) | 77 , m_actionTimer(this, &MediaKeySession::actionTimerFired) |
| 76 { | 78 { |
| 77 WTF_LOG(Media, "MediaKeySession::MediaKeySession"); | 79 WTF_LOG(Media, "MediaKeySession::MediaKeySession"); |
| 78 ScriptWrappable::init(this); | 80 ScriptWrappable::init(this); |
| 79 ASSERT(m_session); | 81 ASSERT(m_session); |
| 80 } | 82 } |
| 81 | 83 |
| 82 MediaKeySession::~MediaKeySession() | 84 MediaKeySession::~MediaKeySession() |
| 83 { | 85 { |
| 84 m_session.clear(); | 86 m_session.clear(); |
| 85 m_asyncEventQueue->cancelAllEvents(); | 87 m_asyncEventQueue->cancelAllEvents(); |
| 86 } | 88 } |
| 87 | 89 |
| 88 void MediaKeySession::setError(MediaKeyError* error) | 90 void MediaKeySession::setError(MediaKeyError* error) |
| 89 { | 91 { |
| 90 m_error = error; | 92 m_error = error; |
| 91 } | 93 } |
| 92 | 94 |
| 93 String MediaKeySession::sessionId() const | 95 String MediaKeySession::sessionId() const |
| 94 { | 96 { |
| 95 return m_session->sessionId(); | 97 return m_session->sessionId(); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void MediaKeySession::initializeNewSession(const String& mimeType, const Uint8Ar ray& initData) | 100 void MediaKeySession::initializeNewSession(const String& mimeType, const Uint8Ar ray& initData) |
| 99 { | 101 { |
| 100 ASSERT(!m_isClosed); | 102 ASSERT(!m_isClosed); |
| 101 m_session->initializeNewSession(mimeType, initData); | 103 m_session->initializeNewSession(mimeType, initData.data(), initData.length() ); |
| 102 } | 104 } |
| 103 | 105 |
| 104 void MediaKeySession::update(Uint8Array* response, ExceptionState& exceptionStat e) | 106 void MediaKeySession::update(Uint8Array* response, ExceptionState& exceptionStat e) |
| 105 { | 107 { |
| 106 WTF_LOG(Media, "MediaKeySession::update"); | 108 WTF_LOG(Media, "MediaKeySession::update"); |
| 107 ASSERT(!m_isClosed); | 109 ASSERT(!m_isClosed); |
| 108 | 110 |
| 109 // From <https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/ encrypted-media.html#dom-update>: | 111 // From <https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/ encrypted-media.html#dom-update>: |
| 110 // The update(response) method must run the following steps: | 112 // The update(response) method must run the following steps: |
| 111 // 1. If response is null or an empty array, throw an INVALID_ACCESS_ERR | 113 // 1. If response is null or an empty array, throw an INVALID_ACCESS_ERR |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 while (!m_pendingActions.isEmpty()) { | 153 while (!m_pendingActions.isEmpty()) { |
| 152 OwnPtr<PendingAction> pendingAction(m_pendingActions.takeFirst()); | 154 OwnPtr<PendingAction> pendingAction(m_pendingActions.takeFirst()); |
| 153 | 155 |
| 154 switch (pendingAction->type) { | 156 switch (pendingAction->type) { |
| 155 case PendingAction::Update: | 157 case PendingAction::Update: |
| 156 // NOTE: Continued from step 3. of MediaKeySession::update() | 158 // NOTE: Continued from step 3. of MediaKeySession::update() |
| 157 // 3.1. Let cdm be the cdm loaded in the MediaKeys constructor. | 159 // 3.1. Let cdm be the cdm loaded in the MediaKeys constructor. |
| 158 // 3.2. Let request be null. | 160 // 3.2. Let request be null. |
| 159 // 3.3. Use cdm to execute the following steps: | 161 // 3.3. Use cdm to execute the following steps: |
| 160 // 3.3.1 Process response. | 162 // 3.3.1 Process response. |
| 161 m_session->update(*(pendingAction->data)); | 163 m_session->update(pendingAction->data->data(), pendingAction->data-> length()); |
| 162 break; | 164 break; |
| 163 case PendingAction::Release: | 165 case PendingAction::Release: |
| 164 // NOTE: Continued from step 3. of MediaKeySession::release(). | 166 // NOTE: Continued from step 3. of MediaKeySession::release(). |
| 165 // 3.1 Let cdm be the cdm loaded in the MediaKeys constructor. | 167 // 3.1 Let cdm be the cdm loaded in the MediaKeys constructor. |
| 166 // 3.2 Use cdm to execute the following steps: | 168 // 3.2 Use cdm to execute the following steps: |
| 167 // 3.2.1 Process the release request. | 169 // 3.2.1 Process the release request. |
| 168 m_session->release(); | 170 m_session->release(); |
| 169 break; | 171 break; |
| 170 } | 172 } |
| 171 } | 173 } |
| 172 } | 174 } |
| 173 | 175 |
| 174 // Queue a task to fire a simple event named keymessage at the new object | 176 // Queue a task to fire a simple event named keymessage at the new object |
| 175 void MediaKeySession::message(const unsigned char* message, size_t messageLength , const KURL& destinationURL) | 177 void MediaKeySession::message(const unsigned char* message, size_t messageLength , const blink::WebURL& destinationURL) |
| 176 { | 178 { |
| 177 WTF_LOG(Media, "MediaKeySession::message"); | 179 WTF_LOG(Media, "MediaKeySession::message"); |
| 178 | 180 |
| 179 MediaKeyMessageEventInit init; | 181 MediaKeyMessageEventInit init; |
| 180 init.bubbles = false; | 182 init.bubbles = false; |
| 181 init.cancelable = false; | 183 init.cancelable = false; |
| 182 init.message = Uint8Array::create(message, messageLength); | 184 init.message = Uint8Array::create(message, messageLength); |
| 183 init.destinationURL = destinationURL; | 185 init.destinationURL = destinationURL.string(); |
| 184 | 186 |
| 185 RefPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::create(EventTypeN ames::message, init); | 187 RefPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::create(EventTypeN ames::message, init); |
| 186 event->setTarget(this); | 188 event->setTarget(this); |
| 187 m_asyncEventQueue->enqueueEvent(event.release()); | 189 m_asyncEventQueue->enqueueEvent(event.release()); |
| 188 } | 190 } |
| 189 | 191 |
| 190 void MediaKeySession::ready() | 192 void MediaKeySession::ready() |
| 191 { | 193 { |
| 192 WTF_LOG(Media, "MediaKeySession::ready"); | 194 WTF_LOG(Media, "MediaKeySession::ready"); |
| 193 | 195 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 209 m_isClosed = true; | 211 m_isClosed = true; |
| 210 } | 212 } |
| 211 | 213 |
| 212 // Queue a task to fire a simple event named keyadded at the MediaKeySession obj ect. | 214 // Queue a task to fire a simple event named keyadded at the MediaKeySession obj ect. |
| 213 void MediaKeySession::error(MediaKeyErrorCode errorCode, unsigned long systemCod e) | 215 void MediaKeySession::error(MediaKeyErrorCode errorCode, unsigned long systemCod e) |
| 214 { | 216 { |
| 215 WTF_LOG(Media, "MediaKeySession::error: errorCode=%d, systemCode=%lu", error Code, systemCode); | 217 WTF_LOG(Media, "MediaKeySession::error: errorCode=%d, systemCode=%lu", error Code, systemCode); |
| 216 | 218 |
| 217 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | 219 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
| 218 switch (errorCode) { | 220 switch (errorCode) { |
| 219 case UnknownError: | 221 case MediaKeyErrorCodeUnknown: |
| 220 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | 222 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
| 221 break; | 223 break; |
| 222 case ClientError: | 224 case MediaKeyErrorCodeClient: |
| 223 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; | 225 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; |
| 224 break; | 226 break; |
| 225 } | 227 } |
| 226 | 228 |
| 227 // 1. Create a new MediaKeyError object with the following attributes: | 229 // 1. Create a new MediaKeyError object with the following attributes: |
| 228 // code = the appropriate MediaKeyError code | 230 // code = the appropriate MediaKeyError code |
| 229 // systemCode = a Key System-specific value, if provided, and 0 otherwise | 231 // systemCode = a Key System-specific value, if provided, and 0 otherwise |
| 230 // 2. Set the MediaKeySession object's error attribute to the error object c reated in the previous step. | 232 // 2. Set the MediaKeySession object's error attribute to the error object c reated in the previous step. |
| 231 m_error = MediaKeyError::create(mediaKeyErrorCode, systemCode); | 233 m_error = MediaKeyError::create(mediaKeyErrorCode, systemCode); |
| 232 | 234 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 262 m_session.clear(); | 264 m_session.clear(); |
| 263 m_isClosed = true; | 265 m_isClosed = true; |
| 264 | 266 |
| 265 if (m_actionTimer.isActive()) | 267 if (m_actionTimer.isActive()) |
| 266 m_actionTimer.stop(); | 268 m_actionTimer.stop(); |
| 267 m_pendingActions.clear(); | 269 m_pendingActions.clear(); |
| 268 m_asyncEventQueue->close(); | 270 m_asyncEventQueue->close(); |
| 269 } | 271 } |
| 270 | 272 |
| 271 } | 273 } |
| OLD | NEW |