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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 return adoptRef(new MediaKeySession(context, cdm, keys)); | 42 return adoptRef(new MediaKeySession(context, cdm, keys)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 MediaKeySession::MediaKeySession(ExecutionContext* context, ContentDecryptionMod ule* cdm, MediaKeys* keys) | 45 MediaKeySession::MediaKeySession(ExecutionContext* context, ContentDecryptionMod ule* cdm, MediaKeys* keys) |
| 46 : ContextLifecycleObserver(context) | 46 : ContextLifecycleObserver(context) |
| 47 , m_keySystem(keys->keySystem()) | 47 , m_keySystem(keys->keySystem()) |
| 48 , m_asyncEventQueue(GenericEventQueue::create(this)) | 48 , m_asyncEventQueue(GenericEventQueue::create(this)) |
| 49 , m_session(cdm->createSession(this)) | 49 , m_session(cdm->createSession(this)) |
| 50 , m_keys(keys) | 50 , m_keys(keys) |
| 51 , m_keyRequestTimer(this, &MediaKeySession::keyRequestTimerFired) | 51 , m_keyRequestTimer(this, &MediaKeySession::keyRequestTimerFired) |
| 52 , m_addKeyTimer(this, &MediaKeySession::addKeyTimerFired) | 52 , m_updateTimer(this, &MediaKeySession::updateTimerFired) |
| 53 { | 53 { |
| 54 ScriptWrappable::init(this); | 54 ScriptWrappable::init(this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 MediaKeySession::~MediaKeySession() | 57 MediaKeySession::~MediaKeySession() |
| 58 { | 58 { |
| 59 close(); | 59 close(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void MediaKeySession::setError(MediaKeyError* error) | 62 void MediaKeySession::setError(MediaKeyError* error) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 // The user agent will asynchronously execute the following steps in the task: | 103 // The user agent will asynchronously execute the following steps in the task: |
| 104 | 104 |
| 105 // 1. Let cdm be the cdm loaded in the MediaKeys constructor. | 105 // 1. Let cdm be the cdm loaded in the MediaKeys constructor. |
| 106 // 2. Let destinationURL be null. | 106 // 2. Let destinationURL be null. |
| 107 | 107 |
| 108 // 3. Use cdm to generate a key request and follow the steps for the fir st matching condition from the following list: | 108 // 3. Use cdm to generate a key request and follow the steps for the fir st matching condition from the following list: |
| 109 m_session->generateKeyRequest(request.mimeType, *request.initData); | 109 m_session->generateKeyRequest(request.mimeType, *request.initData); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 void MediaKeySession::update(Uint8Array* key, ExceptionState& exceptionState) | 113 void MediaKeySession::update(Uint8Array* response, ExceptionState& exceptionStat e) |
| 114 { | 114 { |
| 115 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-addkey>: | 115 // From <https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/ encrypted-media.html#dom-update>: |
| 116 // The addKey(key) method must run the following steps: | 116 // The update(response) method must run the following steps: |
| 117 // 1. If the first or second argument [sic] is null or an empty array, throw an InvalidAccessError. | 117 // 1. If the argument is null or an empty array, throw an INVALID_ACCESS_ERR . |
| 118 // NOTE: the reference to a "second argument" is a spec bug. | 118 if (!response || !response->length()) { |
| 119 if (!key || !key->length()) { | |
| 120 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); | 119 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); |
| 121 return; | 120 return; |
| 122 } | 121 } |
| 123 | 122 |
| 124 // 2. Schedule a task to handle the call, providing key. | 123 // 2. If the session is not in the PENDING state, throw an INVALID_STATE_ERR . |
| 125 m_pendingKeys.append(key); | 124 // FIXME: Implement states in MediaKeySession. |
| 126 m_addKeyTimer.startOneShot(0); | 125 |
| 126 // 3. Schedule a task to handle the call, providing response. | |
| 127 m_pendingKeys.append(response); | |
| 128 m_updateTimer.startOneShot(0); | |
|
ddorwin
2014/01/07 01:10:43
abarth: Is it preferable to use Blink timers to "S
ddorwin
2014/01/07 02:41:21
Looking at the steps in the algorithm, there may n
xhwang
2014/01/07 17:33:53
I like posting the task here so that:
* Blink impl
| |
| 127 } | 129 } |
| 128 | 130 |
| 129 void MediaKeySession::addKeyTimerFired(Timer<MediaKeySession>*) | 131 void MediaKeySession::updateTimerFired(Timer<MediaKeySession>*) |
| 130 { | 132 { |
| 131 ASSERT(m_pendingKeys.size()); | 133 ASSERT(m_pendingKeys.size()); |
| 132 if (!m_session) | 134 if (!m_session) |
| 133 return; | 135 return; |
| 134 | 136 |
| 135 while (!m_pendingKeys.isEmpty()) { | 137 while (!m_pendingKeys.isEmpty()) { |
| 136 RefPtr<Uint8Array> pendingKey = m_pendingKeys.takeFirst(); | 138 RefPtr<Uint8Array> pendingKey = m_pendingKeys.takeFirst(); |
| 137 | 139 |
| 138 // NOTE: Continued from step 2. of MediaKeySession::update() | 140 // NOTE: Continued from step 2. of MediaKeySession::update() |
| 139 // 2.1. Let cdm be the cdm loaded in the MediaKeys constructor. | 141 // 2.1. Let cdm be the cdm loaded in the MediaKeys constructor. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 { | 197 { |
| 196 return EventTargetNames::MediaKeySession; | 198 return EventTargetNames::MediaKeySession; |
| 197 } | 199 } |
| 198 | 200 |
| 199 ExecutionContext* MediaKeySession::executionContext() const | 201 ExecutionContext* MediaKeySession::executionContext() const |
| 200 { | 202 { |
| 201 return ContextLifecycleObserver::executionContext(); | 203 return ContextLifecycleObserver::executionContext(); |
| 202 } | 204 } |
| 203 | 205 |
| 204 } | 206 } |
| OLD | NEW |