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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 #include "public/platform/WebContentDecryptionModule.h" | 46 #include "public/platform/WebContentDecryptionModule.h" |
| 47 #include "public/platform/WebContentDecryptionModuleException.h" | 47 #include "public/platform/WebContentDecryptionModuleException.h" |
| 48 #include "public/platform/WebContentDecryptionModuleSession.h" | 48 #include "public/platform/WebContentDecryptionModuleSession.h" |
| 49 #include "public/platform/WebEncryptedMediaKeyInformation.h" | 49 #include "public/platform/WebEncryptedMediaKeyInformation.h" |
| 50 #include "public/platform/WebString.h" | 50 #include "public/platform/WebString.h" |
| 51 #include "public/platform/WebURL.h" | 51 #include "public/platform/WebURL.h" |
| 52 #include "wtf/ASCIICType.h" | 52 #include "wtf/ASCIICType.h" |
| 53 #include <cmath> | 53 #include <cmath> |
| 54 #include <limits> | 54 #include <limits> |
| 55 | 55 |
| 56 #define MEDIA_KEY_SESSION_LOG_LEVEL 3 | |
| 57 | |
| 56 namespace { | 58 namespace { |
| 57 | 59 |
| 58 // Minimum and maximum length for session ids. | 60 // Minimum and maximum length for session ids. |
| 59 enum { | 61 enum { |
| 60 MinSessionIdLength = 1, | 62 MinSessionIdLength = 1, |
| 61 MaxSessionIdLength = 512 | 63 MaxSessionIdLength = 512 |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 } // namespace | 66 } // namespace |
| 65 | 67 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 95 case WebEncryptedMediaKeyInformation::KeyStatus::OutputRestricted: | 97 case WebEncryptedMediaKeyInformation::KeyStatus::OutputRestricted: |
| 96 return "output-restricted"; | 98 return "output-restricted"; |
| 97 case WebEncryptedMediaKeyInformation::KeyStatus::OutputDownscaled: | 99 case WebEncryptedMediaKeyInformation::KeyStatus::OutputDownscaled: |
| 98 return "output-downscaled"; | 100 return "output-downscaled"; |
| 99 case WebEncryptedMediaKeyInformation::KeyStatus::StatusPending: | 101 case WebEncryptedMediaKeyInformation::KeyStatus::StatusPending: |
| 100 return "status-pending"; | 102 return "status-pending"; |
| 101 case WebEncryptedMediaKeyInformation::KeyStatus::InternalError: | 103 case WebEncryptedMediaKeyInformation::KeyStatus::InternalError: |
| 102 return "internal-error"; | 104 return "internal-error"; |
| 103 } | 105 } |
| 104 | 106 |
| 105 ASSERT_NOT_REACHED(); | 107 NOTREACHED(); |
| 106 return "internal-error"; | 108 return "internal-error"; |
| 107 } | 109 } |
| 108 | 110 |
| 109 static ScriptPromise CreateRejectedPromiseNotCallable(ScriptState* scriptState) | 111 static ScriptPromise CreateRejectedPromiseNotCallable(ScriptState* scriptState) |
| 110 { | 112 { |
| 111 return ScriptPromise::rejectWithDOMException( | 113 return ScriptPromise::rejectWithDOMException( |
| 112 scriptState, DOMException::create(InvalidStateError, "The session is not callable.")); | 114 scriptState, DOMException::create(InvalidStateError, "The session is not callable.")); |
| 113 } | 115 } |
| 114 | 116 |
| 115 static ScriptPromise CreateRejectedPromiseAlreadyInitialized(ScriptState* script State) | 117 static ScriptPromise CreateRejectedPromiseAlreadyInitialized(ScriptState* script State) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 131 | 133 |
| 132 Type getType() const { return m_type; } | 134 Type getType() const { return m_type; } |
| 133 | 135 |
| 134 const Persistent<ContentDecryptionModuleResult> result() const | 136 const Persistent<ContentDecryptionModuleResult> result() const |
| 135 { | 137 { |
| 136 return m_result; | 138 return m_result; |
| 137 } | 139 } |
| 138 | 140 |
| 139 DOMArrayBuffer* data() const | 141 DOMArrayBuffer* data() const |
| 140 { | 142 { |
| 141 ASSERT(m_type == GenerateRequest || m_type == Update); | 143 DCHECK(m_type == GenerateRequest || m_type == Update); |
| 142 return m_data; | 144 return m_data; |
| 143 } | 145 } |
| 144 | 146 |
| 145 WebEncryptedMediaInitDataType initDataType() const | 147 WebEncryptedMediaInitDataType initDataType() const |
| 146 { | 148 { |
| 147 ASSERT(m_type == GenerateRequest); | 149 DCHECK_EQ(m_type, GenerateRequest); |
|
jrummell
2016/05/23 22:53:56
Typically the expected value is first, the variabl
Srirama
2016/05/24 16:24:04
Done.
| |
| 148 return m_initDataType; | 150 return m_initDataType; |
| 149 } | 151 } |
| 150 | 152 |
| 151 const String& sessionId() const | 153 const String& sessionId() const |
| 152 { | 154 { |
| 153 ASSERT(m_type == Load); | 155 DCHECK_EQ(m_type, Load); |
| 154 return m_stringData; | 156 return m_stringData; |
| 155 } | 157 } |
| 156 | 158 |
| 157 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe sult* result, WebEncryptedMediaInitDataType initDataType, DOMArrayBuffer* initDa ta) | 159 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe sult* result, WebEncryptedMediaInitDataType initDataType, DOMArrayBuffer* initDa ta) |
| 158 { | 160 { |
| 159 ASSERT(result); | 161 DCHECK(result); |
| 160 ASSERT(initData); | 162 DCHECK(initData); |
| 161 return new PendingAction(GenerateRequest, result, initDataType, initData , String()); | 163 return new PendingAction(GenerateRequest, result, initDataType, initData , String()); |
| 162 } | 164 } |
| 163 | 165 |
| 164 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult * result, const String& sessionId) | 166 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult * result, const String& sessionId) |
| 165 { | 167 { |
| 166 ASSERT(result); | 168 DCHECK(result); |
| 167 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un known, nullptr, sessionId); | 169 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un known, nullptr, sessionId); |
| 168 } | 170 } |
| 169 | 171 |
| 170 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res ult, DOMArrayBuffer* data) | 172 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res ult, DOMArrayBuffer* data) |
| 171 { | 173 { |
| 172 ASSERT(result); | 174 DCHECK(result); |
| 173 ASSERT(data); | 175 DCHECK(data); |
| 174 return new PendingAction(Update, result, WebEncryptedMediaInitDataType:: Unknown, data, String()); | 176 return new PendingAction(Update, result, WebEncryptedMediaInitDataType:: Unknown, data, String()); |
| 175 } | 177 } |
| 176 | 178 |
| 177 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu lt) | 179 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu lt) |
| 178 { | 180 { |
| 179 ASSERT(result); | 181 DCHECK(result); |
| 180 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U nknown, nullptr, String()); | 182 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U nknown, nullptr, String()); |
| 181 } | 183 } |
| 182 | 184 |
| 183 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res ult) | 185 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res ult) |
| 184 { | 186 { |
| 185 ASSERT(result); | 187 DCHECK(result); |
| 186 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType:: Unknown, nullptr, String()); | 188 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType:: Unknown, nullptr, String()); |
| 187 } | 189 } |
| 188 | 190 |
| 189 ~PendingAction() | 191 ~PendingAction() |
| 190 { | 192 { |
| 191 } | 193 } |
| 192 | 194 |
| 193 DEFINE_INLINE_TRACE() | 195 DEFINE_INLINE_TRACE() |
| 194 { | 196 { |
| 195 visitor->trace(m_result); | 197 visitor->trace(m_result); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } | 229 } |
| 228 | 230 |
| 229 ~NewSessionResultPromise() override | 231 ~NewSessionResultPromise() override |
| 230 { | 232 { |
| 231 } | 233 } |
| 232 | 234 |
| 233 // ContentDecryptionModuleResult implementation. | 235 // ContentDecryptionModuleResult implementation. |
| 234 void completeWithSession(WebContentDecryptionModuleResult::SessionStatus sta tus) override | 236 void completeWithSession(WebContentDecryptionModuleResult::SessionStatus sta tus) override |
| 235 { | 237 { |
| 236 if (status != WebContentDecryptionModuleResult::NewSession) { | 238 if (status != WebContentDecryptionModuleResult::NewSession) { |
| 237 ASSERT_NOT_REACHED(); | 239 NOTREACHED(); |
| 238 reject(InvalidStateError, "Unexpected completion."); | 240 reject(InvalidStateError, "Unexpected completion."); |
| 239 } | 241 } |
| 240 | 242 |
| 241 m_session->finishGenerateRequest(); | 243 m_session->finishGenerateRequest(); |
| 242 resolve(); | 244 resolve(); |
| 243 } | 245 } |
| 244 | 246 |
| 245 DEFINE_INLINE_TRACE() | 247 DEFINE_INLINE_TRACE() |
| 246 { | 248 { |
| 247 visitor->trace(m_session); | 249 visitor->trace(m_session); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 276 case WebContentDecryptionModuleResult::NewSession: | 278 case WebContentDecryptionModuleResult::NewSession: |
| 277 m_session->finishLoad(); | 279 m_session->finishLoad(); |
| 278 resolve(true); | 280 resolve(true); |
| 279 return; | 281 return; |
| 280 | 282 |
| 281 case WebContentDecryptionModuleResult::SessionNotFound: | 283 case WebContentDecryptionModuleResult::SessionNotFound: |
| 282 resolve(false); | 284 resolve(false); |
| 283 return; | 285 return; |
| 284 | 286 |
| 285 case WebContentDecryptionModuleResult::SessionAlreadyExists: | 287 case WebContentDecryptionModuleResult::SessionAlreadyExists: |
| 286 ASSERT_NOT_REACHED(); | 288 NOTREACHED(); |
| 287 reject(InvalidStateError, "Unexpected completion."); | 289 reject(InvalidStateError, "Unexpected completion."); |
| 288 return; | 290 return; |
| 289 } | 291 } |
| 290 | 292 |
| 291 ASSERT_NOT_REACHED(); | 293 NOTREACHED(); |
| 292 } | 294 } |
| 293 | 295 |
| 294 DEFINE_INLINE_TRACE() | 296 DEFINE_INLINE_TRACE() |
| 295 { | 297 { |
| 296 visitor->trace(m_session); | 298 visitor->trace(m_session); |
| 297 ContentDecryptionModuleResultPromise::trace(visitor); | 299 ContentDecryptionModuleResultPromise::trace(visitor); |
| 298 } | 300 } |
| 299 | 301 |
| 300 private: | 302 private: |
| 301 Member<MediaKeySession> m_session; | 303 Member<MediaKeySession> m_session; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 315 , m_mediaKeys(mediaKeys) | 317 , m_mediaKeys(mediaKeys) |
| 316 , m_sessionType(sessionType) | 318 , m_sessionType(sessionType) |
| 317 , m_expiration(std::numeric_limits<double>::quiet_NaN()) | 319 , m_expiration(std::numeric_limits<double>::quiet_NaN()) |
| 318 , m_keyStatusesMap(new MediaKeyStatusMap()) | 320 , m_keyStatusesMap(new MediaKeyStatusMap()) |
| 319 , m_isUninitialized(true) | 321 , m_isUninitialized(true) |
| 320 , m_isCallable(false) | 322 , m_isCallable(false) |
| 321 , m_isClosed(false) | 323 , m_isClosed(false) |
| 322 , m_closedPromise(new ClosedPromise(scriptState->getExecutionContext(), this , ClosedPromise::Closed)) | 324 , m_closedPromise(new ClosedPromise(scriptState->getExecutionContext(), this , ClosedPromise::Closed)) |
| 323 , m_actionTimer(this, &MediaKeySession::actionTimerFired) | 325 , m_actionTimer(this, &MediaKeySession::actionTimerFired) |
| 324 { | 326 { |
| 325 WTF_LOG(Media, "MediaKeySession(%p)::MediaKeySession", this); | 327 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "MediaKeySession(" << this << ")"; |
|
jrummell
2016/05/23 22:53:56
To keep the message consistent I think this needs
Srirama
2016/05/24 16:24:04
DVLOG already prints filename and line number, so
jrummell
2016/05/24 18:07:11
Acknowledged.
| |
| 326 ThreadState::current()->registerPreFinalizer(this); | 328 ThreadState::current()->registerPreFinalizer(this); |
| 327 | 329 |
| 328 // Create the matching Chromium object. It will not be usable until | 330 // Create the matching Chromium object. It will not be usable until |
| 329 // initializeNewSession() is called in response to the user calling | 331 // initializeNewSession() is called in response to the user calling |
| 330 // generateRequest(). | 332 // generateRequest(). |
| 331 WebContentDecryptionModule* cdm = mediaKeys->contentDecryptionModule(); | 333 WebContentDecryptionModule* cdm = mediaKeys->contentDecryptionModule(); |
| 332 m_session = adoptPtr(cdm->createSession()); | 334 m_session = adoptPtr(cdm->createSession()); |
| 333 m_session->setClientInterface(this); | 335 m_session->setClientInterface(this); |
| 334 | 336 |
| 335 // From https://w3c.github.io/encrypted-media/#createSession: | 337 // From https://w3c.github.io/encrypted-media/#createSession: |
| 336 // MediaKeys::createSession(), step 3. | 338 // MediaKeys::createSession(), step 3. |
| 337 // 3.1 Let the sessionId attribute be the empty string. | 339 // 3.1 Let the sessionId attribute be the empty string. |
| 338 ASSERT(sessionId().isEmpty()); | 340 DCHECK(sessionId().isEmpty()); |
| 339 | 341 |
| 340 // 3.2 Let the expiration attribute be NaN. | 342 // 3.2 Let the expiration attribute be NaN. |
| 341 ASSERT(std::isnan(m_expiration)); | 343 DCHECK(std::isnan(m_expiration)); |
| 342 | 344 |
| 343 // 3.3 Let the closed attribute be a new promise. | 345 // 3.3 Let the closed attribute be a new promise. |
| 344 ASSERT(!closed(scriptState).isUndefinedOrNull()); | 346 DCHECK(!closed(scriptState).isUndefinedOrNull()); |
| 345 | 347 |
| 346 // 3.4 Let the keyStatuses attribute be empty. | 348 // 3.4 Let the keyStatuses attribute be empty. |
| 347 ASSERT(m_keyStatusesMap->size() == 0); | 349 DCHECK_EQ(m_keyStatusesMap->size(), 0u); |
| 348 | 350 |
| 349 // 3.5 Let the session type be sessionType. | 351 // 3.5 Let the session type be sessionType. |
| 350 ASSERT(m_sessionType != WebEncryptedMediaSessionType::Unknown); | 352 DCHECK(m_sessionType != WebEncryptedMediaSessionType::Unknown); |
| 351 | 353 |
| 352 // 3.6 Let uninitialized be true. | 354 // 3.6 Let uninitialized be true. |
| 353 ASSERT(m_isUninitialized); | 355 DCHECK(m_isUninitialized); |
| 354 | 356 |
| 355 // 3.7 Let callable be false. | 357 // 3.7 Let callable be false. |
| 356 ASSERT(!m_isCallable); | 358 DCHECK(!m_isCallable); |
| 357 | 359 |
| 358 // 3.8 Let the use distinctive identifier value be this object's | 360 // 3.8 Let the use distinctive identifier value be this object's |
| 359 // use distinctive identifier. | 361 // use distinctive identifier. |
| 360 // FIXME: Implement this (http://crbug.com/448922). | 362 // FIXME: Implement this (http://crbug.com/448922). |
| 361 | 363 |
| 362 // 3.9 Let the cdm implementation value be this object's cdm implementation. | 364 // 3.9 Let the cdm implementation value be this object's cdm implementation. |
| 363 // 3.10 Let the cdm instance value be this object's cdm instance. | 365 // 3.10 Let the cdm instance value be this object's cdm instance. |
| 364 } | 366 } |
| 365 | 367 |
| 366 MediaKeySession::~MediaKeySession() | 368 MediaKeySession::~MediaKeySession() |
| 367 { | 369 { |
| 368 WTF_LOG(Media, "MediaKeySession(%p)::~MediaKeySession", this); | 370 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "~MediaKeySession(" << this << ")"; |
| 369 } | 371 } |
| 370 | 372 |
| 371 void MediaKeySession::dispose() | 373 void MediaKeySession::dispose() |
| 372 { | 374 { |
| 373 // Promptly clears a raw reference from content/ to an on-heap object | 375 // Promptly clears a raw reference from content/ to an on-heap object |
| 374 // so that content/ doesn't access it in a lazy sweeping phase. | 376 // so that content/ doesn't access it in a lazy sweeping phase. |
| 375 m_session.clear(); | 377 m_session.clear(); |
| 376 } | 378 } |
| 377 | 379 |
| 378 String MediaKeySession::sessionId() const | 380 String MediaKeySession::sessionId() const |
| 379 { | 381 { |
| 380 return m_session->sessionId(); | 382 return m_session->sessionId(); |
| 381 } | 383 } |
| 382 | 384 |
| 383 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) | 385 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) |
| 384 { | 386 { |
| 385 return m_closedPromise->promise(scriptState->world()); | 387 return m_closedPromise->promise(scriptState->world()); |
| 386 } | 388 } |
| 387 | 389 |
| 388 MediaKeyStatusMap* MediaKeySession::keyStatuses() | 390 MediaKeyStatusMap* MediaKeySession::keyStatuses() |
| 389 { | 391 { |
| 390 return m_keyStatusesMap; | 392 return m_keyStatusesMap; |
| 391 } | 393 } |
| 392 | 394 |
| 393 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataTypeString, const DOMArrayPiece& initData) | 395 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataTypeString, const DOMArrayPiece& initData) |
| 394 { | 396 { |
| 395 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType String.ascii().data()); | 397 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "generateRequest(" << this << ") " << initDataTypeString; |
| 396 | 398 |
| 397 // From https://w3c.github.io/encrypted-media/#generateRequest: | 399 // From https://w3c.github.io/encrypted-media/#generateRequest: |
| 398 // Generates a request based on the initData. When this method is invoked, | 400 // Generates a request based on the initData. When this method is invoked, |
| 399 // the user agent must run the following steps: | 401 // the user agent must run the following steps: |
| 400 | 402 |
| 401 // 1. If this object's uninitialized value is false, return a promise | 403 // 1. If this object's uninitialized value is false, return a promise |
| 402 // rejected with a new DOMException whose name is "InvalidStateError". | 404 // rejected with a new DOMException whose name is "InvalidStateError". |
| 403 if (!m_isUninitialized) | 405 if (!m_isUninitialized) |
| 404 return CreateRejectedPromiseAlreadyInitialized(scriptState); | 406 return CreateRejectedPromiseAlreadyInitialized(scriptState); |
| 405 | 407 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 // 7. Let session type be this object's session type. | 442 // 7. Let session type be this object's session type. |
| 441 // (Done in constructor.) | 443 // (Done in constructor.) |
| 442 | 444 |
| 443 // 8. Let promise be a new promise. | 445 // 8. Let promise be a new promise. |
| 444 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his); | 446 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his); |
| 445 ScriptPromise promise = result->promise(); | 447 ScriptPromise promise = result->promise(); |
| 446 | 448 |
| 447 // 9. Run the following steps asynchronously (documented in | 449 // 9. Run the following steps asynchronously (documented in |
| 448 // actionTimerFired()) | 450 // actionTimerFired()) |
| 449 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initDataBuffer)); | 451 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initDataBuffer)); |
| 450 ASSERT(!m_actionTimer.isActive()); | 452 DCHECK(!m_actionTimer.isActive()); |
| 451 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 453 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 452 | 454 |
| 453 // 10. Return promise. | 455 // 10. Return promise. |
| 454 return promise; | 456 return promise; |
| 455 } | 457 } |
| 456 | 458 |
| 457 ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess ionId) | 459 ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess ionId) |
| 458 { | 460 { |
| 459 WTF_LOG(Media, "MediaKeySession(%p)::load %s", this, sessionId.ascii().data( )); | 461 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "load(" << this << ") " << sessionId; |
| 460 | 462 |
| 461 // From https://w3c.github.io/encrypted-media/#load: | 463 // From https://w3c.github.io/encrypted-media/#load: |
| 462 // Loads the data stored for the specified session into this object. When | 464 // Loads the data stored for the specified session into this object. When |
| 463 // this method is invoked, the user agent must run the following steps: | 465 // this method is invoked, the user agent must run the following steps: |
| 464 | 466 |
| 465 // 1. If this object's uninitialized value is false, return a promise | 467 // 1. If this object's uninitialized value is false, return a promise |
| 466 // rejected with a new DOMException whose name is "InvalidStateError". | 468 // rejected with a new DOMException whose name is "InvalidStateError". |
| 467 if (!m_isUninitialized) | 469 if (!m_isUninitialized) |
| 468 return CreateRejectedPromiseAlreadyInitialized(scriptState); | 470 return CreateRejectedPromiseAlreadyInitialized(scriptState); |
| 469 | 471 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 494 // 6. Let origin be the origin of this object's Document. | 496 // 6. Let origin be the origin of this object's Document. |
| 495 // (Available as getExecutionContext()->getSecurityOrigin() anytime.) | 497 // (Available as getExecutionContext()->getSecurityOrigin() anytime.) |
| 496 | 498 |
| 497 // 7. Let promise be a new promise. | 499 // 7. Let promise be a new promise. |
| 498 LoadSessionResultPromise* result = new LoadSessionResultPromise(scriptState, this); | 500 LoadSessionResultPromise* result = new LoadSessionResultPromise(scriptState, this); |
| 499 ScriptPromise promise = result->promise(); | 501 ScriptPromise promise = result->promise(); |
| 500 | 502 |
| 501 // 8. Run the following steps asynchronously (documented in | 503 // 8. Run the following steps asynchronously (documented in |
| 502 // actionTimerFired()) | 504 // actionTimerFired()) |
| 503 m_pendingActions.append(PendingAction::CreatePendingLoadRequest(result, sess ionId)); | 505 m_pendingActions.append(PendingAction::CreatePendingLoadRequest(result, sess ionId)); |
| 504 ASSERT(!m_actionTimer.isActive()); | 506 DCHECK(!m_actionTimer.isActive()); |
| 505 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 507 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 506 | 508 |
| 507 // 9. Return promise. | 509 // 9. Return promise. |
| 508 return promise; | 510 return promise; |
| 509 } | 511 } |
| 510 | 512 |
| 511 ScriptPromise MediaKeySession::update(ScriptState* scriptState, const DOMArrayPi ece& response) | 513 ScriptPromise MediaKeySession::update(ScriptState* scriptState, const DOMArrayPi ece& response) |
| 512 { | 514 { |
| 513 WTF_LOG(Media, "MediaKeySession(%p)::update", this); | 515 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "update(" << this << ")"; |
| 514 ASSERT(!m_isClosed); | 516 DCHECK(!m_isClosed); |
| 515 | 517 |
| 516 // From https://w3c.github.io/encrypted-media/#update: | 518 // From https://w3c.github.io/encrypted-media/#update: |
| 517 // Provides messages, including licenses, to the CDM. When this method is | 519 // Provides messages, including licenses, to the CDM. When this method is |
| 518 // invoked, the user agent must run the following steps: | 520 // invoked, the user agent must run the following steps: |
| 519 | 521 |
| 520 // 1. If this object's callable value is false, return a promise rejected | 522 // 1. If this object's callable value is false, return a promise rejected |
| 521 // with a new DOMException whose name is InvalidStateError. | 523 // with a new DOMException whose name is InvalidStateError. |
| 522 if (!m_isCallable) | 524 if (!m_isCallable) |
| 523 return CreateRejectedPromiseNotCallable(scriptState); | 525 return CreateRejectedPromiseNotCallable(scriptState); |
| 524 | 526 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 541 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC opy)); | 543 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC opy)); |
| 542 if (!m_actionTimer.isActive()) | 544 if (!m_actionTimer.isActive()) |
| 543 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 545 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 544 | 546 |
| 545 // 6. Return promise. | 547 // 6. Return promise. |
| 546 return promise; | 548 return promise; |
| 547 } | 549 } |
| 548 | 550 |
| 549 ScriptPromise MediaKeySession::close(ScriptState* scriptState) | 551 ScriptPromise MediaKeySession::close(ScriptState* scriptState) |
| 550 { | 552 { |
| 551 WTF_LOG(Media, "MediaKeySession(%p)::close", this); | 553 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "close(" << this << ")"; |
| 552 | 554 |
| 553 // From https://w3c.github.io/encrypted-media/#close: | 555 // From https://w3c.github.io/encrypted-media/#close: |
| 554 // Indicates that the application no longer needs the session and the CDM | 556 // Indicates that the application no longer needs the session and the CDM |
| 555 // should release any resources associated with this object and close it. | 557 // should release any resources associated with this object and close it. |
| 556 // When this method is invoked, the user agent must run the following steps: | 558 // When this method is invoked, the user agent must run the following steps: |
| 557 | 559 |
| 558 // 1. If this object's callable value is false, return a promise rejected | 560 // 1. If this object's callable value is false, return a promise rejected |
| 559 // with a new DOMException whose name is "InvalidStateError". | 561 // with a new DOMException whose name is "InvalidStateError". |
| 560 if (!m_isCallable) | 562 if (!m_isCallable) |
| 561 return CreateRejectedPromiseNotCallable(scriptState); | 563 return CreateRejectedPromiseNotCallable(scriptState); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 574 m_pendingActions.append(PendingAction::CreatePendingClose(result)); | 576 m_pendingActions.append(PendingAction::CreatePendingClose(result)); |
| 575 if (!m_actionTimer.isActive()) | 577 if (!m_actionTimer.isActive()) |
| 576 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 578 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 577 | 579 |
| 578 // 5. Return promise. | 580 // 5. Return promise. |
| 579 return promise; | 581 return promise; |
| 580 } | 582 } |
| 581 | 583 |
| 582 ScriptPromise MediaKeySession::remove(ScriptState* scriptState) | 584 ScriptPromise MediaKeySession::remove(ScriptState* scriptState) |
| 583 { | 585 { |
| 584 WTF_LOG(Media, "MediaKeySession(%p)::remove", this); | 586 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "remove(" << this << ")"; |
| 585 | 587 |
| 586 // From https://w3c.github.io/encrypted-media/#remove: | 588 // From https://w3c.github.io/encrypted-media/#remove: |
| 587 // Removes stored session data associated with this object. When this | 589 // Removes stored session data associated with this object. When this |
| 588 // method is invoked, the user agent must run the following steps: | 590 // method is invoked, the user agent must run the following steps: |
| 589 | 591 |
| 590 // 1. If this object's callable value is false, return a promise rejected | 592 // 1. If this object's callable value is false, return a promise rejected |
| 591 // with a new DOMException whose name is "InvalidStateError". | 593 // with a new DOMException whose name is "InvalidStateError". |
| 592 if (!m_isCallable) | 594 if (!m_isCallable) |
| 593 return CreateRejectedPromiseNotCallable(scriptState); | 595 return CreateRejectedPromiseNotCallable(scriptState); |
| 594 | 596 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 617 m_pendingActions.append(PendingAction::CreatePendingRemove(result)); | 619 m_pendingActions.append(PendingAction::CreatePendingRemove(result)); |
| 618 if (!m_actionTimer.isActive()) | 620 if (!m_actionTimer.isActive()) |
| 619 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); | 621 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| 620 | 622 |
| 621 // 6. Return promise. | 623 // 6. Return promise. |
| 622 return promise; | 624 return promise; |
| 623 } | 625 } |
| 624 | 626 |
| 625 void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) | 627 void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| 626 { | 628 { |
| 627 ASSERT(m_pendingActions.size()); | 629 DCHECK(m_pendingActions.size()); |
| 628 | 630 |
| 629 // Resolving promises now run synchronously and may result in additional | 631 // Resolving promises now run synchronously and may result in additional |
| 630 // actions getting added to the queue. As a result, swap the queue to | 632 // actions getting added to the queue. As a result, swap the queue to |
| 631 // a local copy to avoid problems if this happens. | 633 // a local copy to avoid problems if this happens. |
| 632 HeapDeque<Member<PendingAction>> pendingActions; | 634 HeapDeque<Member<PendingAction>> pendingActions; |
| 633 pendingActions.swap(m_pendingActions); | 635 pendingActions.swap(m_pendingActions); |
| 634 | 636 |
| 635 while (!pendingActions.isEmpty()) { | 637 while (!pendingActions.isEmpty()) { |
| 636 PendingAction* action = pendingActions.takeFirst(); | 638 PendingAction* action = pendingActions.takeFirst(); |
| 637 | 639 |
| 638 switch (action->getType()) { | 640 switch (action->getType()) { |
| 639 case PendingAction::GenerateRequest: | 641 case PendingAction::GenerateRequest: |
| 640 // NOTE: Continue step 9 of MediaKeySession::generateRequest(). | 642 // NOTE: Continue step 9 of MediaKeySession::generateRequest(). |
| 641 WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: GenerateReque st", this); | 643 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") GenerateRequest"; |
| 642 | 644 |
| 643 // initializeNewSession() in Chromium will execute steps 9.1 to 9.7. | 645 // initializeNewSession() in Chromium will execute steps 9.1 to 9.7. |
| 644 m_session->initializeNewSession(action->initDataType(), static_cast< unsigned char*>(action->data()->data()), action->data()->byteLength(), m_session Type, action->result()->result()); | 646 m_session->initializeNewSession(action->initDataType(), static_cast< unsigned char*>(action->data()->data()), action->data()->byteLength(), m_session Type, action->result()->result()); |
| 645 | 647 |
| 646 // Remaining steps (from 9.8) executed in finishGenerateRequest(), | 648 // Remaining steps (from 9.8) executed in finishGenerateRequest(), |
| 647 // called when |result| is resolved. | 649 // called when |result| is resolved. |
| 648 break; | 650 break; |
| 649 | 651 |
| 650 case PendingAction::Load: | 652 case PendingAction::Load: |
| 651 // NOTE: Continue step 8 of MediaKeySession::load(). | 653 // NOTE: Continue step 8 of MediaKeySession::load(). |
| 652 WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Load", this); | 654 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Load"; |
| 653 | 655 |
| 654 // 8.1 Let sanitized session ID be a validated and/or sanitized | 656 // 8.1 Let sanitized session ID be a validated and/or sanitized |
| 655 // version of sessionId. The user agent should thoroughly | 657 // version of sessionId. The user agent should thoroughly |
| 656 // validate the sessionId value before passing it to the CDM. | 658 // validate the sessionId value before passing it to the CDM. |
| 657 // At a minimum, this should include checking that the length | 659 // At a minimum, this should include checking that the length |
| 658 // and value (e.g. alphanumeric) are reasonable. | 660 // and value (e.g. alphanumeric) are reasonable. |
| 659 // 8.2 If the previous step failed, reject promise with a new | 661 // 8.2 If the previous step failed, reject promise with a new |
| 660 // DOMException whose name is "InvalidAccessError". | 662 // DOMException whose name is "InvalidAccessError". |
| 661 if (!isValidSessionId(action->sessionId())) { | 663 if (!isValidSessionId(action->sessionId())) { |
| 662 action->result()->completeWithError(WebContentDecryptionModuleEx ceptionInvalidAccessError, 0, "Invalid sessionId"); | 664 action->result()->completeWithError(WebContentDecryptionModuleEx ceptionInvalidAccessError, 0, "Invalid sessionId"); |
| 663 return; | 665 return; |
| 664 } | 666 } |
| 665 | 667 |
| 666 // 8.3 If there is an unclosed session in the object's Document | 668 // 8.3 If there is an unclosed session in the object's Document |
| 667 // whose sessionId attribute is sanitized session ID, reject | 669 // whose sessionId attribute is sanitized session ID, reject |
| 668 // promise with a new DOMException whose name is | 670 // promise with a new DOMException whose name is |
| 669 // QuotaExceededError. In other words, do not create a session | 671 // QuotaExceededError. In other words, do not create a session |
| 670 // if a non-closed session, regardless of type, already exists | 672 // if a non-closed session, regardless of type, already exists |
| 671 // for this sanitized session ID in this browsing context. | 673 // for this sanitized session ID in this browsing context. |
| 672 // (Done in the CDM.) | 674 // (Done in the CDM.) |
| 673 | 675 |
| 674 // 8.4 Let expiration time be NaN. | 676 // 8.4 Let expiration time be NaN. |
| 675 // (Done in the constructor.) | 677 // (Done in the constructor.) |
| 676 ASSERT(std::isnan(m_expiration)); | 678 DCHECK(std::isnan(m_expiration)); |
| 677 | 679 |
| 678 // load() in Chromium will execute steps 8.5 through 8.8. | 680 // load() in Chromium will execute steps 8.5 through 8.8. |
| 679 m_session->load(action->sessionId(), action->result()->result()); | 681 m_session->load(action->sessionId(), action->result()->result()); |
| 680 | 682 |
| 681 // Remaining steps (from 8.9) executed in finishLoad(), called | 683 // Remaining steps (from 8.9) executed in finishLoad(), called |
| 682 // when |result| is resolved. | 684 // when |result| is resolved. |
| 683 break; | 685 break; |
| 684 | 686 |
| 685 case PendingAction::Update: | 687 case PendingAction::Update: |
| 686 // NOTE: Continue step 5 of MediaKeySession::update(). | 688 // NOTE: Continue step 5 of MediaKeySession::update(). |
| 687 WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Update", this ); | 689 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Update"; |
| 688 | 690 |
| 689 // update() in Chromium will execute steps 5.1 through 5.8. | 691 // update() in Chromium will execute steps 5.1 through 5.8. |
| 690 m_session->update(static_cast<unsigned char*>(action->data()->data() ), action->data()->byteLength(), action->result()->result()); | 692 m_session->update(static_cast<unsigned char*>(action->data()->data() ), action->data()->byteLength(), action->result()->result()); |
| 691 | 693 |
| 692 // Last step (5.9 Resolve promise) will be done when |result| is | 694 // Last step (5.9 Resolve promise) will be done when |result| is |
| 693 // resolved. | 695 // resolved. |
| 694 break; | 696 break; |
| 695 | 697 |
| 696 case PendingAction::Close: | 698 case PendingAction::Close: |
| 697 // NOTE: Continue step 4 of MediaKeySession::close(). | 699 // NOTE: Continue step 4 of MediaKeySession::close(). |
| 698 WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Close", this) ; | 700 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Close"; |
| 699 | 701 |
| 700 // close() in Chromium will execute steps 4.1 through 4.2. | 702 // close() in Chromium will execute steps 4.1 through 4.2. |
| 701 m_session->close(action->result()->result()); | 703 m_session->close(action->result()->result()); |
| 702 | 704 |
| 703 // Last step (4.3 Resolve promise) will be done when |result| is | 705 // Last step (4.3 Resolve promise) will be done when |result| is |
| 704 // resolved. | 706 // resolved. |
| 705 break; | 707 break; |
| 706 | 708 |
| 707 case PendingAction::Remove: | 709 case PendingAction::Remove: |
| 708 // NOTE: Continue step 5 of MediaKeySession::remove(). | 710 // NOTE: Continue step 5 of MediaKeySession::remove(). |
| 709 WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Remove", this ); | 711 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Remove"; |
| 710 | 712 |
| 711 // remove() in Chromium will execute steps 5.1 through 5.3. | 713 // remove() in Chromium will execute steps 5.1 through 5.3. |
| 712 m_session->remove(action->result()->result()); | 714 m_session->remove(action->result()->result()); |
| 713 | 715 |
| 714 // Last step (5.3.3 Resolve promise) will be done when |result| is | 716 // Last step (5.3.3 Resolve promise) will be done when |result| is |
| 715 // resolved. | 717 // resolved. |
| 716 break; | 718 break; |
| 717 } | 719 } |
| 718 } | 720 } |
| 719 } | 721 } |
| 720 | 722 |
| 721 void MediaKeySession::finishGenerateRequest() | 723 void MediaKeySession::finishGenerateRequest() |
| 722 { | 724 { |
| 723 // 9.8 If any of the preceding steps failed, reject promise with a | 725 // 9.8 If any of the preceding steps failed, reject promise with a |
| 724 // new DOMException whose name is the appropriate error name. | 726 // new DOMException whose name is the appropriate error name. |
| 725 // (Done by CDM calling result.completeWithError() as appropriate.) | 727 // (Done by CDM calling result.completeWithError() as appropriate.) |
| 726 | 728 |
| 727 // 9.9 Set the sessionId attribute to session id. | 729 // 9.9 Set the sessionId attribute to session id. |
| 728 ASSERT(!sessionId().isEmpty()); | 730 DCHECK(!sessionId().isEmpty()); |
| 729 | 731 |
| 730 // 9.10 Let this object's callable be true. | 732 // 9.10 Let this object's callable be true. |
| 731 m_isCallable = true; | 733 m_isCallable = true; |
| 732 | 734 |
| 733 // 9.11 Run the queue a "message" event algorithm on the session, | 735 // 9.11 Run the queue a "message" event algorithm on the session, |
| 734 // providing "license-request" and message. | 736 // providing "license-request" and message. |
| 735 // (Done by the CDM.) | 737 // (Done by the CDM.) |
| 736 | 738 |
| 737 // 9.12 Resolve promise. | 739 // 9.12 Resolve promise. |
| 738 // (Done by NewSessionResultPromise.) | 740 // (Done by NewSessionResultPromise.) |
| 739 } | 741 } |
| 740 | 742 |
| 741 void MediaKeySession::finishLoad() | 743 void MediaKeySession::finishLoad() |
| 742 { | 744 { |
| 743 // 8.9 If any of the preceding steps failed, reject promise with a new | 745 // 8.9 If any of the preceding steps failed, reject promise with a new |
| 744 // DOMException whose name is the appropriate error name. | 746 // DOMException whose name is the appropriate error name. |
| 745 // (Done by CDM calling result.completeWithError() as appropriate.) | 747 // (Done by CDM calling result.completeWithError() as appropriate.) |
| 746 | 748 |
| 747 // 8.10 Set the sessionId attribute to sanitized session ID. | 749 // 8.10 Set the sessionId attribute to sanitized session ID. |
| 748 ASSERT(!sessionId().isEmpty()); | 750 DCHECK(!sessionId().isEmpty()); |
| 749 | 751 |
| 750 // 8.11 Let this object's callable be true. | 752 // 8.11 Let this object's callable be true. |
| 751 m_isCallable = true; | 753 m_isCallable = true; |
| 752 | 754 |
| 753 // 8.12 If the loaded session contains information about any keys (there | 755 // 8.12 If the loaded session contains information about any keys (there |
| 754 // are known keys), run the update key statuses algorithm on the | 756 // are known keys), run the update key statuses algorithm on the |
| 755 // session, providing each key's key ID along with the appropriate | 757 // session, providing each key's key ID along with the appropriate |
| 756 // MediaKeyStatus. Should additional processing be necessary to | 758 // MediaKeyStatus. Should additional processing be necessary to |
| 757 // determine with certainty the status of a key, use the non-"usable" | 759 // determine with certainty the status of a key, use the non-"usable" |
| 758 // MediaKeyStatus value that corresponds to the reason for the | 760 // MediaKeyStatus value that corresponds to the reason for the |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 769 // on the session, providing message type and message. | 771 // on the session, providing message type and message. |
| 770 // (Done by the CDM.) | 772 // (Done by the CDM.) |
| 771 | 773 |
| 772 // 8.15 Resolve promise with true. | 774 // 8.15 Resolve promise with true. |
| 773 // (Done by LoadSessionResultPromise.) | 775 // (Done by LoadSessionResultPromise.) |
| 774 } | 776 } |
| 775 | 777 |
| 776 // Queue a task to fire a simple event named keymessage at the new object. | 778 // Queue a task to fire a simple event named keymessage at the new object. |
| 777 void MediaKeySession::message(MessageType messageType, const unsigned char* mess age, size_t messageLength) | 779 void MediaKeySession::message(MessageType messageType, const unsigned char* mess age, size_t messageLength) |
| 778 { | 780 { |
| 779 WTF_LOG(Media, "MediaKeySession(%p)::message", this); | 781 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "message(" << this << ")"; |
| 780 | 782 |
| 781 // Verify that 'message' not fired before session initialization is complete . | 783 // Verify that 'message' not fired before session initialization is complete . |
| 782 ASSERT(m_isCallable); | 784 DCHECK(m_isCallable); |
| 783 | 785 |
| 784 // From https://w3c.github.io/encrypted-media/#queue-message: | 786 // From https://w3c.github.io/encrypted-media/#queue-message: |
| 785 // The following steps are run: | 787 // The following steps are run: |
| 786 // 1. Let the session be the specified MediaKeySession object. | 788 // 1. Let the session be the specified MediaKeySession object. |
| 787 // 2. Queue a task to fire a simple event named message at the session. | 789 // 2. Queue a task to fire a simple event named message at the session. |
| 788 // The event is of type MediaKeyMessageEvent and has: | 790 // The event is of type MediaKeyMessageEvent and has: |
| 789 // -> messageType = the specified message type | 791 // -> messageType = the specified message type |
| 790 // -> message = the specified message | 792 // -> message = the specified message |
| 791 | 793 |
| 792 MediaKeyMessageEventInit init; | 794 MediaKeyMessageEventInit init; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 803 } | 805 } |
| 804 init.setMessage(DOMArrayBuffer::create(static_cast<const void*>(message), me ssageLength)); | 806 init.setMessage(DOMArrayBuffer::create(static_cast<const void*>(message), me ssageLength)); |
| 805 | 807 |
| 806 MediaKeyMessageEvent* event = MediaKeyMessageEvent::create(EventTypeNames::m essage, init); | 808 MediaKeyMessageEvent* event = MediaKeyMessageEvent::create(EventTypeNames::m essage, init); |
| 807 event->setTarget(this); | 809 event->setTarget(this); |
| 808 m_asyncEventQueue->enqueueEvent(event); | 810 m_asyncEventQueue->enqueueEvent(event); |
| 809 } | 811 } |
| 810 | 812 |
| 811 void MediaKeySession::close() | 813 void MediaKeySession::close() |
| 812 { | 814 { |
| 813 WTF_LOG(Media, "MediaKeySession(%p)::close", this); | 815 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "close(" << this << ")"; |
| 814 | 816 |
| 815 // From https://w3c.github.io/encrypted-media/#session-close: | 817 // From https://w3c.github.io/encrypted-media/#session-close: |
| 816 // The following steps are run: | 818 // The following steps are run: |
| 817 // 1. Let the session be the associated MediaKeySession object. | 819 // 1. Let the session be the associated MediaKeySession object. |
| 818 // 2. Let promise be the closed attribute of the session. | 820 // 2. Let promise be the closed attribute of the session. |
| 819 // 3. Resolve promise. | 821 // 3. Resolve promise. |
| 820 m_closedPromise->resolve(ToV8UndefinedGenerator()); | 822 m_closedPromise->resolve(ToV8UndefinedGenerator()); |
| 821 | 823 |
| 822 // Once closed, the session can no longer be the target of events from | 824 // Once closed, the session can no longer be the target of events from |
| 823 // the CDM so this object can be garbage collected. | 825 // the CDM so this object can be garbage collected. |
| 824 m_isClosed = true; | 826 m_isClosed = true; |
| 825 } | 827 } |
| 826 | 828 |
| 827 void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) | 829 void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) |
| 828 { | 830 { |
| 829 WTF_LOG(Media, "MediaKeySession(%p)::expirationChanged %f", this, updatedExp iryTimeInMS); | 831 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "expirationChanged(" << this << ") " < < updatedExpiryTimeInMS; |
| 830 | 832 |
| 831 // From https://w3c.github.io/encrypted-media/#update-expiration: | 833 // From https://w3c.github.io/encrypted-media/#update-expiration: |
| 832 // The following steps are run: | 834 // The following steps are run: |
| 833 // 1. Let the session be the associated MediaKeySession object. | 835 // 1. Let the session be the associated MediaKeySession object. |
| 834 // 2. Let expiration time be NaN. | 836 // 2. Let expiration time be NaN. |
| 835 double expirationTime = std::numeric_limits<double>::quiet_NaN(); | 837 double expirationTime = std::numeric_limits<double>::quiet_NaN(); |
| 836 | 838 |
| 837 // 3. If the new expiration time is not NaN, let expiration time be the | 839 // 3. If the new expiration time is not NaN, let expiration time be the |
| 838 // new expiration time in milliseconds since 01 January 1970 UTC. | 840 // new expiration time in milliseconds since 01 January 1970 UTC. |
| 839 // (Note that Chromium actually passes 0 to indicate no expiry.) | 841 // (Note that Chromium actually passes 0 to indicate no expiry.) |
| 840 // FIXME: Get Chromium to pass NaN. | 842 // FIXME: Get Chromium to pass NaN. |
| 841 if (!std::isnan(updatedExpiryTimeInMS) && updatedExpiryTimeInMS != 0.0) | 843 if (!std::isnan(updatedExpiryTimeInMS) && updatedExpiryTimeInMS != 0.0) |
| 842 expirationTime = updatedExpiryTimeInMS; | 844 expirationTime = updatedExpiryTimeInMS; |
| 843 | 845 |
| 844 // 4. Set the session's expiration attribute to expiration time. | 846 // 4. Set the session's expiration attribute to expiration time. |
| 845 m_expiration = expirationTime; | 847 m_expiration = expirationTime; |
| 846 } | 848 } |
| 847 | 849 |
| 848 void MediaKeySession::keysStatusesChange(const WebVector<WebEncryptedMediaKeyInf ormation>& keys, bool hasAdditionalUsableKey) | 850 void MediaKeySession::keysStatusesChange(const WebVector<WebEncryptedMediaKeyInf ormation>& keys, bool hasAdditionalUsableKey) |
| 849 { | 851 { |
| 850 WTF_LOG(Media, "MediaKeySession(%p)::keysStatusesChange with %zu keys and ha sAdditionalUsableKey is %s", this, keys.size(), hasAdditionalUsableKey ? "true" : "false"); | 852 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "keysStatusesChange(" << this << ") wi th " << keys.size() << " keys and hasAdditionalUsableKey is " << (hasAdditionalU sableKey ? "true" : "false"); |
| 851 | 853 |
| 852 // From https://w3c.github.io/encrypted-media/#update-key-statuses: | 854 // From https://w3c.github.io/encrypted-media/#update-key-statuses: |
| 853 // The following steps are run: | 855 // The following steps are run: |
| 854 // 1. Let the session be the associated MediaKeySession object. | 856 // 1. Let the session be the associated MediaKeySession object. |
| 855 // 2. Let the input statuses be the sequence of pairs key ID and | 857 // 2. Let the input statuses be the sequence of pairs key ID and |
| 856 // associated MediaKeyStatus pairs. | 858 // associated MediaKeyStatus pairs. |
| 857 // 3. Let the statuses be session's keyStatuses attribute. | 859 // 3. Let the statuses be session's keyStatuses attribute. |
| 858 | 860 |
| 859 // 4. Run the following steps to replace the contents of statuses: | 861 // 4. Run the following steps to replace the contents of statuses: |
| 860 // 4.1 Empty statuses. | 862 // 4.1 Empty statuses. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 890 | 892 |
| 891 ExecutionContext* MediaKeySession::getExecutionContext() const | 893 ExecutionContext* MediaKeySession::getExecutionContext() const |
| 892 { | 894 { |
| 893 return ActiveDOMObject::getExecutionContext(); | 895 return ActiveDOMObject::getExecutionContext(); |
| 894 } | 896 } |
| 895 | 897 |
| 896 bool MediaKeySession::hasPendingActivity() const | 898 bool MediaKeySession::hasPendingActivity() const |
| 897 { | 899 { |
| 898 // Remain around if there are pending events or MediaKeys is still around | 900 // Remain around if there are pending events or MediaKeys is still around |
| 899 // and we're not closed. | 901 // and we're not closed. |
| 900 WTF_LOG(Media, "MediaKeySession(%p)::hasPendingActivity %s%s%s", this, | 902 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "hasPendingActivity(" << this << ") " |
| 901 !m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "", | 903 << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") |
| 902 m_asyncEventQueue->hasPendingEvents() ? " m_asyncEventQueue->hasPendingE vents()" : "", | 904 << (m_asyncEventQueue->hasPendingEvents() ? " m_asyncEventQueue->hasPend ingEvents()" : "") |
| 903 (m_mediaKeys && !m_isClosed) ? " m_mediaKeys && !m_isClosed" : ""); | 905 << ((m_mediaKeys && !m_isClosed) ? " m_mediaKeys && !m_isClosed" : ""); |
| 904 | 906 |
| 905 return !m_pendingActions.isEmpty() | 907 return !m_pendingActions.isEmpty() |
| 906 || m_asyncEventQueue->hasPendingEvents() | 908 || m_asyncEventQueue->hasPendingEvents() |
| 907 || (m_mediaKeys && !m_isClosed); | 909 || (m_mediaKeys && !m_isClosed); |
| 908 } | 910 } |
| 909 | 911 |
| 910 void MediaKeySession::stop() | 912 void MediaKeySession::stop() |
| 911 { | 913 { |
| 912 // Stop the CDM from firing any more events for this session. | 914 // Stop the CDM from firing any more events for this session. |
| 913 m_session.clear(); | 915 m_session.clear(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 924 visitor->trace(m_asyncEventQueue); | 926 visitor->trace(m_asyncEventQueue); |
| 925 visitor->trace(m_pendingActions); | 927 visitor->trace(m_pendingActions); |
| 926 visitor->trace(m_mediaKeys); | 928 visitor->trace(m_mediaKeys); |
| 927 visitor->trace(m_keyStatusesMap); | 929 visitor->trace(m_keyStatusesMap); |
| 928 visitor->trace(m_closedPromise); | 930 visitor->trace(m_closedPromise); |
| 929 EventTargetWithInlineData::trace(visitor); | 931 EventTargetWithInlineData::trace(visitor); |
| 930 ActiveDOMObject::trace(visitor); | 932 ActiveDOMObject::trace(visitor); |
| 931 } | 933 } |
| 932 | 934 |
| 933 } // namespace blink | 935 } // namespace blink |
| OLD | NEW |