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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 namespace { | 56 namespace { |
| 57 | 57 |
| 58 // The list of possible values for |sessionType|. | |
| 59 const char kTemporary[] = "temporary"; | |
| 60 const char kPersistentLicense[] = "persistent-license"; | |
| 61 const char kPersistentReleaseMessage[] = "persistent-release-message"; | |
| 62 | |
| 63 // The list of possible values for |messageType|. | 58 // The list of possible values for |messageType|. |
|
ddorwin
2015/02/25 21:38:51
Unrelated to this CL, but should these move too?
jrummell
2015/02/25 21:52:38
Sure.
| |
| 64 const char kLicenseRequest[] = "license-request"; | 59 const char kLicenseRequest[] = "license-request"; |
| 65 const char kLicenseRenewal[] = "license-renewal"; | 60 const char kLicenseRenewal[] = "license-renewal"; |
| 66 const char kLicenseRelease[] = "license-release"; | 61 const char kLicenseRelease[] = "license-release"; |
| 67 | 62 |
| 68 // Minimum and maximum length for session ids. | 63 // Minimum and maximum length for session ids. |
| 69 enum { | 64 enum { |
| 70 MinSessionIdLength = 1, | 65 MinSessionIdLength = 1, |
| 71 MaxSessionIdLength = 512 | 66 MaxSessionIdLength = 512 |
| 72 }; | 67 }; |
| 73 | 68 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 86 | 81 |
| 87 // Check that the sessionId only contains alphanumeric characters. | 82 // Check that the sessionId only contains alphanumeric characters. |
| 88 for (unsigned i = 0; i < sessionId.length(); ++i) { | 83 for (unsigned i = 0; i < sessionId.length(); ++i) { |
| 89 if (!isASCIIAlphanumeric(sessionId[i])) | 84 if (!isASCIIAlphanumeric(sessionId[i])) |
| 90 return false; | 85 return false; |
| 91 } | 86 } |
| 92 | 87 |
| 93 return true; | 88 return true; |
| 94 } | 89 } |
| 95 | 90 |
| 96 // Checks that |initDataType| is a registered Initialization Data Type. | |
| 97 static bool isRegisteredInitDataType(const String& initDataType) | |
| 98 { | |
| 99 // List from https://w3c.github.io/encrypted-media/initdata-format-registry. html | |
| 100 return initDataType == "cenc" || initDataType == "keyids" || initDataType == "webm"; | |
| 101 } | |
| 102 | |
| 103 static String ConvertKeyStatusToString(const WebEncryptedMediaKeyInformation::Ke yStatus status) | 91 static String ConvertKeyStatusToString(const WebEncryptedMediaKeyInformation::Ke yStatus status) |
| 104 { | 92 { |
| 105 switch (status) { | 93 switch (status) { |
| 106 case WebEncryptedMediaKeyInformation::KeyStatus::Usable: | 94 case WebEncryptedMediaKeyInformation::KeyStatus::Usable: |
| 107 return "usable"; | 95 return "usable"; |
| 108 case WebEncryptedMediaKeyInformation::KeyStatus::Expired: | 96 case WebEncryptedMediaKeyInformation::KeyStatus::Expired: |
| 109 return "expired"; | 97 return "expired"; |
| 110 case WebEncryptedMediaKeyInformation::KeyStatus::OutputNotAllowed: | 98 case WebEncryptedMediaKeyInformation::KeyStatus::OutputNotAllowed: |
| 111 return "output-not-allowed"; | 99 return "output-not-allowed"; |
| 112 case WebEncryptedMediaKeyInformation::KeyStatus::InternalError: | 100 case WebEncryptedMediaKeyInformation::KeyStatus::InternalError: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 { | 134 { |
| 147 return m_result; | 135 return m_result; |
| 148 } | 136 } |
| 149 | 137 |
| 150 const PassRefPtr<DOMArrayBuffer> data() const | 138 const PassRefPtr<DOMArrayBuffer> data() const |
| 151 { | 139 { |
| 152 ASSERT(m_type == GenerateRequest || m_type == Update); | 140 ASSERT(m_type == GenerateRequest || m_type == Update); |
| 153 return m_data; | 141 return m_data; |
| 154 } | 142 } |
| 155 | 143 |
| 156 const String& initDataType() const | 144 WebEncryptedMediaInitDataType initDataType() const |
| 157 { | 145 { |
| 158 ASSERT(m_type == GenerateRequest); | 146 ASSERT(m_type == GenerateRequest); |
| 159 return m_stringData; | 147 return m_initDataType; |
| 160 } | 148 } |
| 161 | 149 |
| 162 const String& sessionId() const | 150 const String& sessionId() const |
| 163 { | 151 { |
| 164 ASSERT(m_type == Load); | 152 ASSERT(m_type == Load); |
| 165 return m_stringData; | 153 return m_stringData; |
| 166 } | 154 } |
| 167 | 155 |
| 168 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe sult* result, const String& initDataType, PassRefPtr<DOMArrayBuffer> initData) | 156 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe sult* result, WebEncryptedMediaInitDataType initDataType, PassRefPtr<DOMArrayBuf fer> initData) |
| 169 { | 157 { |
| 170 ASSERT(result); | 158 ASSERT(result); |
| 171 ASSERT(initData); | 159 ASSERT(initData); |
| 172 return new PendingAction(GenerateRequest, result, initDataType, initData ); | 160 return new PendingAction(GenerateRequest, result, initDataType, initData , String()); |
| 173 } | 161 } |
| 174 | 162 |
| 175 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult * result, const String& sessionId) | 163 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult * result, const String& sessionId) |
| 176 { | 164 { |
| 177 ASSERT(result); | 165 ASSERT(result); |
| 178 return new PendingAction(Load, result, sessionId, PassRefPtr<DOMArrayBuf fer>()); | 166 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un known, PassRefPtr<DOMArrayBuffer>(), sessionId); |
| 179 } | 167 } |
| 180 | 168 |
| 181 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res ult, PassRefPtr<DOMArrayBuffer> data) | 169 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res ult, PassRefPtr<DOMArrayBuffer> data) |
| 182 { | 170 { |
| 183 ASSERT(result); | 171 ASSERT(result); |
| 184 ASSERT(data); | 172 ASSERT(data); |
| 185 return new PendingAction(Update, result, String(), data); | 173 return new PendingAction(Update, result, WebEncryptedMediaInitDataType:: Unknown, data, String()); |
| 186 } | 174 } |
| 187 | 175 |
| 188 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu lt) | 176 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu lt) |
| 189 { | 177 { |
| 190 ASSERT(result); | 178 ASSERT(result); |
| 191 return new PendingAction(Close, result, String(), PassRefPtr<DOMArrayBuf fer>()); | 179 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U nknown, PassRefPtr<DOMArrayBuffer>(), String()); |
| 192 } | 180 } |
| 193 | 181 |
| 194 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res ult) | 182 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res ult) |
| 195 { | 183 { |
| 196 ASSERT(result); | 184 ASSERT(result); |
| 197 return new PendingAction(Remove, result, String(), PassRefPtr<DOMArrayBu ffer>()); | 185 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType:: Unknown, PassRefPtr<DOMArrayBuffer>(), String()); |
| 198 } | 186 } |
| 199 | 187 |
| 200 ~PendingAction() | 188 ~PendingAction() |
| 201 { | 189 { |
| 202 } | 190 } |
| 203 | 191 |
| 204 DEFINE_INLINE_TRACE() | 192 DEFINE_INLINE_TRACE() |
| 205 { | 193 { |
| 206 visitor->trace(m_result); | 194 visitor->trace(m_result); |
| 207 } | 195 } |
| 208 | 196 |
| 209 private: | 197 private: |
| 210 PendingAction(Type type, ContentDecryptionModuleResult* result, const String & stringData, PassRefPtr<DOMArrayBuffer> data) | 198 PendingAction(Type type, ContentDecryptionModuleResult* result, WebEncrypted MediaInitDataType initDataType, PassRefPtr<DOMArrayBuffer> data, const String& s tringData) |
| 211 : m_type(type) | 199 : m_type(type) |
| 212 , m_result(result) | 200 , m_result(result) |
| 201 , m_initDataType(initDataType) | |
| 202 , m_data(data) | |
| 213 , m_stringData(stringData) | 203 , m_stringData(stringData) |
| 214 , m_data(data) | |
| 215 { | 204 { |
| 216 } | 205 } |
| 217 | 206 |
| 218 const Type m_type; | 207 const Type m_type; |
| 219 const Member<ContentDecryptionModuleResult> m_result; | 208 const Member<ContentDecryptionModuleResult> m_result; |
| 209 const WebEncryptedMediaInitDataType m_initDataType; | |
| 210 const RefPtr<DOMArrayBuffer> m_data; | |
| 220 const String m_stringData; | 211 const String m_stringData; |
| 221 const RefPtr<DOMArrayBuffer> m_data; | |
| 222 }; | 212 }; |
| 223 | 213 |
| 224 // This class wraps the promise resolver used when initializing a new session | 214 // This class wraps the promise resolver used when initializing a new session |
| 225 // and is passed to Chromium to fullfill the promise. This implementation of | 215 // and is passed to Chromium to fullfill the promise. This implementation of |
| 226 // completeWithSession() will resolve the promise with void, while | 216 // completeWithSession() will resolve the promise with void, while |
| 227 // completeWithError() will reject the promise with an exception. complete() | 217 // completeWithError() will reject the promise with an exception. complete() |
| 228 // is not expected to be called, and will reject the promise. | 218 // is not expected to be called, and will reject the promise. |
| 229 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise { | 219 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise { |
| 230 public: | 220 public: |
| 231 NewSessionResultPromise(ScriptState* scriptState, MediaKeySession* session) | 221 NewSessionResultPromise(ScriptState* scriptState, MediaKeySession* session) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 DEFINE_INLINE_TRACE() | 293 DEFINE_INLINE_TRACE() |
| 304 { | 294 { |
| 305 visitor->trace(m_session); | 295 visitor->trace(m_session); |
| 306 ContentDecryptionModuleResultPromise::trace(visitor); | 296 ContentDecryptionModuleResultPromise::trace(visitor); |
| 307 } | 297 } |
| 308 | 298 |
| 309 private: | 299 private: |
| 310 Member<MediaKeySession> m_session; | 300 Member<MediaKeySession> m_session; |
| 311 }; | 301 }; |
| 312 | 302 |
| 313 MediaKeySession* MediaKeySession::create(ScriptState* scriptState, MediaKeys* me diaKeys, const String& sessionType) | 303 MediaKeySession* MediaKeySession::create(ScriptState* scriptState, MediaKeys* me diaKeys, WebEncryptedMediaSessionType sessionType) |
| 314 { | 304 { |
| 315 ASSERT(isValidSessionType(sessionType)); | |
| 316 RefPtrWillBeRawPtr<MediaKeySession> session = new MediaKeySession(scriptStat e, mediaKeys, sessionType); | 305 RefPtrWillBeRawPtr<MediaKeySession> session = new MediaKeySession(scriptStat e, mediaKeys, sessionType); |
| 317 session->suspendIfNeeded(); | 306 session->suspendIfNeeded(); |
| 318 return session.get(); | 307 return session.get(); |
| 319 } | 308 } |
| 320 | 309 |
| 321 bool MediaKeySession::isValidSessionType(const String& sessionType) | 310 WebEncryptedMediaInitDataType MediaKeySession::convertInitDataType(const String& initDataType) |
| 322 { | 311 { |
| 323 return (sessionType == kTemporary || sessionType == kPersistentLicense || se ssionType == kPersistentReleaseMessage); | 312 if (initDataType == "cenc") |
| 313 return WebEncryptedMediaInitDataType::Cenc; | |
| 314 if (initDataType == "keyids") | |
| 315 return WebEncryptedMediaInitDataType::Keyids; | |
| 316 if (initDataType == "webm") | |
| 317 return WebEncryptedMediaInitDataType::Webm; | |
| 318 | |
| 319 // |initDataType| is not restricted in the idl, so anything is possible. | |
| 320 return WebEncryptedMediaInitDataType::Unknown; | |
| 324 } | 321 } |
| 325 | 322 |
| 326 MediaKeySession::MediaKeySession(ScriptState* scriptState, MediaKeys* mediaKeys, const String& sessionType) | 323 WebEncryptedMediaSessionType MediaKeySession::convertSessionType(const String& s essionType) |
| 324 { | |
| 325 if (sessionType == "temporary") | |
| 326 return WebEncryptedMediaSessionType::Temporary; | |
| 327 if (sessionType == "persistent-license") | |
| 328 return WebEncryptedMediaSessionType::PersistentLicense; | |
| 329 if (sessionType == "persistent-release-message") | |
| 330 return WebEncryptedMediaSessionType::PersistentReleaseMessage; | |
| 331 | |
| 332 ASSERT_NOT_REACHED(); | |
| 333 return WebEncryptedMediaSessionType::Unknown; | |
| 334 } | |
| 335 | |
| 336 MediaKeySession::MediaKeySession(ScriptState* scriptState, MediaKeys* mediaKeys, WebEncryptedMediaSessionType sessionType) | |
| 327 : ActiveDOMObject(scriptState->executionContext()) | 337 : ActiveDOMObject(scriptState->executionContext()) |
| 328 , m_keySystem(mediaKeys->keySystem()) | 338 , m_keySystem(mediaKeys->keySystem()) |
| 329 , m_asyncEventQueue(GenericEventQueue::create(this)) | 339 , m_asyncEventQueue(GenericEventQueue::create(this)) |
| 330 , m_mediaKeys(mediaKeys) | 340 , m_mediaKeys(mediaKeys) |
| 331 , m_sessionType(sessionType) | 341 , m_sessionType(sessionType) |
| 332 , m_expiration(std::numeric_limits<double>::quiet_NaN()) | 342 , m_expiration(std::numeric_limits<double>::quiet_NaN()) |
| 333 , m_keyStatusesMap(new MediaKeyStatusMap()) | 343 , m_keyStatusesMap(new MediaKeyStatusMap()) |
| 334 , m_isUninitialized(true) | 344 , m_isUninitialized(true) |
| 335 , m_isCallable(false) | 345 , m_isCallable(false) |
| 336 , m_isClosed(false) | 346 , m_isClosed(false) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 354 // 3.2 Let the expiration attribute be NaN. | 364 // 3.2 Let the expiration attribute be NaN. |
| 355 ASSERT(std::isnan(m_expiration)); | 365 ASSERT(std::isnan(m_expiration)); |
| 356 | 366 |
| 357 // 3.3 Let the closed attribute be a new promise. | 367 // 3.3 Let the closed attribute be a new promise. |
| 358 ASSERT(!closed(scriptState).isUndefinedOrNull()); | 368 ASSERT(!closed(scriptState).isUndefinedOrNull()); |
| 359 | 369 |
| 360 // 3.4 Let the keyStatuses attribute be empty. | 370 // 3.4 Let the keyStatuses attribute be empty. |
| 361 ASSERT(m_keyStatusesMap->size() == 0); | 371 ASSERT(m_keyStatusesMap->size() == 0); |
| 362 | 372 |
| 363 // 3.5 Let the session type be sessionType. | 373 // 3.5 Let the session type be sessionType. |
| 364 ASSERT(isValidSessionType(m_sessionType)); | 374 ASSERT(m_sessionType != WebEncryptedMediaSessionType::Unknown); |
| 365 | 375 |
| 366 // 3.6 Let uninitialized be true. | 376 // 3.6 Let uninitialized be true. |
| 367 ASSERT(m_isUninitialized); | 377 ASSERT(m_isUninitialized); |
| 368 | 378 |
| 369 // 3.7 Let callable be false. | 379 // 3.7 Let callable be false. |
| 370 ASSERT(!m_isCallable); | 380 ASSERT(!m_isCallable); |
| 371 | 381 |
| 372 // 3.8 Let the use distinctive identifier value be this object's | 382 // 3.8 Let the use distinctive identifier value be this object's |
| 373 // use distinctive identifier. | 383 // use distinctive identifier. |
| 374 // FIXME: Implement this (http://crbug.com/448922). | 384 // FIXME: Implement this (http://crbug.com/448922). |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 397 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) | 407 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) |
| 398 { | 408 { |
| 399 return m_closedPromise->promise(scriptState->world()); | 409 return m_closedPromise->promise(scriptState->world()); |
| 400 } | 410 } |
| 401 | 411 |
| 402 MediaKeyStatusMap* MediaKeySession::keyStatuses() | 412 MediaKeyStatusMap* MediaKeySession::keyStatuses() |
| 403 { | 413 { |
| 404 return m_keyStatusesMap; | 414 return m_keyStatusesMap; |
| 405 } | 415 } |
| 406 | 416 |
| 407 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataType, const DOMArrayPiece& initData) | 417 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataTypeString, const DOMArrayPiece& initData) |
| 408 { | 418 { |
| 409 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType .ascii().data()); | 419 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType String.ascii().data()); |
| 410 | 420 |
| 411 // From https://w3c.github.io/encrypted-media/#generateRequest: | 421 // From https://w3c.github.io/encrypted-media/#generateRequest: |
| 412 // Generates a request based on the initData. When this method is invoked, | 422 // Generates a request based on the initData. When this method is invoked, |
| 413 // the user agent must run the following steps: | 423 // the user agent must run the following steps: |
| 414 | 424 |
| 415 // 1. If this object's uninitialized value is false, return a promise | 425 // 1. If this object's uninitialized value is false, return a promise |
| 416 // rejected with a new DOMException whose name is "InvalidStateError". | 426 // rejected with a new DOMException whose name is "InvalidStateError". |
| 417 if (!m_isUninitialized) | 427 if (!m_isUninitialized) |
| 418 return CreateRejectedPromiseAlreadyInitialized(scriptState); | 428 return CreateRejectedPromiseAlreadyInitialized(scriptState); |
| 419 | 429 |
| 420 // 2. Let this object's uninitialized be false. | 430 // 2. Let this object's uninitialized be false. |
| 421 m_isUninitialized = false; | 431 m_isUninitialized = false; |
| 422 | 432 |
| 423 // 3. If initDataType is an empty string, return a promise rejected with a | 433 // 3. If initDataType is an empty string, return a promise rejected with a |
| 424 // new DOMException whose name is "InvalidAccessError". | 434 // new DOMException whose name is "InvalidAccessError". |
| 425 if (initDataType.isEmpty()) { | 435 if (initDataTypeString.isEmpty()) { |
| 426 return ScriptPromise::rejectWithDOMException( | 436 return ScriptPromise::rejectWithDOMException( |
| 427 scriptState, DOMException::create(InvalidAccessError, "The initDataT ype parameter is empty.")); | 437 scriptState, DOMException::create(InvalidAccessError, "The initDataT ype parameter is empty.")); |
| 428 } | 438 } |
| 429 | 439 |
| 430 // 4. If initData is an empty array, return a promise rejected with a new | 440 // 4. If initData is an empty array, return a promise rejected with a new |
| 431 // DOMException whose name is"InvalidAccessError". | 441 // DOMException whose name is"InvalidAccessError". |
| 432 if (!initData.byteLength()) { | 442 if (!initData.byteLength()) { |
| 433 return ScriptPromise::rejectWithDOMException( | 443 return ScriptPromise::rejectWithDOMException( |
| 434 scriptState, DOMException::create(InvalidAccessError, "The initData parameter is empty.")); | 444 scriptState, DOMException::create(InvalidAccessError, "The initData parameter is empty.")); |
| 435 } | 445 } |
| 436 | 446 |
| 437 // 5. If the Key System implementation represented by this object's cdm | 447 // 5. If the Key System implementation represented by this object's cdm |
| 438 // implementation value does not support initDataType as an | 448 // implementation value does not support initDataType as an |
| 439 // Initialization Data Type, return a promise rejected with a new | 449 // Initialization Data Type, return a promise rejected with a new |
| 440 // DOMException whose name is NotSupportedError. String comparison | 450 // DOMException whose name is NotSupportedError. String comparison |
| 441 // is case-sensitive. | 451 // is case-sensitive. |
| 442 // (blink side doesn't know what the CDM supports, so the proper check | 452 // (blink side doesn't know what the CDM supports, so the proper check |
| 443 // will be done on the Chromium side. However, we can verify that | 453 // will be done on the Chromium side. However, we can verify that |
| 444 // |initDataType| is one of the registered values.) | 454 // |initDataType| is one of the registered values.) |
| 445 if (!isRegisteredInitDataType(initDataType)) { | 455 WebEncryptedMediaInitDataType initDataType = convertInitDataType(initDataTyp eString); |
| 456 if (initDataType == WebEncryptedMediaInitDataType::Unknown) { | |
| 446 return ScriptPromise::rejectWithDOMException( | 457 return ScriptPromise::rejectWithDOMException( |
| 447 scriptState, DOMException::create(NotSupportedError, "The initializa tion data type '" + initDataType + "' is not a registered Initialization Data Ty pe.")); | 458 scriptState, DOMException::create(NotSupportedError, "The initializa tion data type '" + initDataTypeString + "' is not supported.")); |
| 448 } | 459 } |
| 449 | 460 |
| 450 // 6. Let init data be a copy of the contents of the initData parameter. | 461 // 6. Let init data be a copy of the contents of the initData parameter. |
| 451 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::create(initData.data (), initData.byteLength()); | 462 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::create(initData.data (), initData.byteLength()); |
| 452 | 463 |
| 453 // 7. Let session type be this object's session type. | 464 // 7. Let session type be this object's session type. |
| 454 // (Done in constructor.) | 465 // (Done in constructor.) |
| 455 | 466 |
| 456 // 8. Let promise be a new promise. | 467 // 8. Let promise be a new promise. |
| 457 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his); | 468 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 486 // 3. If sessionId is an empty string, return a promise rejected with a | 497 // 3. If sessionId is an empty string, return a promise rejected with a |
| 487 // new DOMException whose name is "InvalidAccessError". | 498 // new DOMException whose name is "InvalidAccessError". |
| 488 if (sessionId.isEmpty()) { | 499 if (sessionId.isEmpty()) { |
| 489 return ScriptPromise::rejectWithDOMException( | 500 return ScriptPromise::rejectWithDOMException( |
| 490 scriptState, DOMException::create(InvalidAccessError, "The sessionId parameter is empty.")); | 501 scriptState, DOMException::create(InvalidAccessError, "The sessionId parameter is empty.")); |
| 491 } | 502 } |
| 492 | 503 |
| 493 // 4. If this object's session type is not "persistent-license" or | 504 // 4. If this object's session type is not "persistent-license" or |
| 494 // "persistent-release-message", return a promise rejected with a | 505 // "persistent-release-message", return a promise rejected with a |
| 495 // new DOMException whose name is InvalidAccessError. | 506 // new DOMException whose name is InvalidAccessError. |
| 496 if (m_sessionType != kPersistentLicense && m_sessionType != kPersistentRelea seMessage) { | 507 if (m_sessionType != WebEncryptedMediaSessionType::PersistentLicense && m_se ssionType != WebEncryptedMediaSessionType::PersistentReleaseMessage) { |
| 497 return ScriptPromise::rejectWithDOMException( | 508 return ScriptPromise::rejectWithDOMException( |
| 498 scriptState, DOMException::create(InvalidAccessError, "The session t ype is not persistent.")); | 509 scriptState, DOMException::create(InvalidAccessError, "The session t ype is not persistent.")); |
| 499 } | 510 } |
| 500 | 511 |
| 501 // 5. If the Key System implementation represented by this object's cdm | 512 // 5. If the Key System implementation represented by this object's cdm |
| 502 // implementation value does not support loading previous sessions, | 513 // implementation value does not support loading previous sessions, |
| 503 // return a promise rejected with a new DOMException whose name is | 514 // return a promise rejected with a new DOMException whose name is |
| 504 // NotSupportedError. | 515 // NotSupportedError. |
| 505 // FIXME: Implement this (http://crbug.com/448922). | 516 // FIXME: Implement this (http://crbug.com/448922). |
| 506 | 517 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 // method is invoked, the user agent must run the following steps: | 612 // method is invoked, the user agent must run the following steps: |
| 602 | 613 |
| 603 // 1. If this object's callable value is false, return a promise rejected | 614 // 1. If this object's callable value is false, return a promise rejected |
| 604 // with a new DOMException whose name is "InvalidStateError". | 615 // with a new DOMException whose name is "InvalidStateError". |
| 605 if (!m_isCallable) | 616 if (!m_isCallable) |
| 606 return CreateRejectedPromiseNotCallable(scriptState); | 617 return CreateRejectedPromiseNotCallable(scriptState); |
| 607 | 618 |
| 608 // 2. If this object's session type is not "persistent-license" or | 619 // 2. If this object's session type is not "persistent-license" or |
| 609 // "persistent-release-message", return a promise rejected with a | 620 // "persistent-release-message", return a promise rejected with a |
| 610 // new DOMException whose name is InvalidAccessError. | 621 // new DOMException whose name is InvalidAccessError. |
| 611 if (m_sessionType != kPersistentLicense && m_sessionType != kPersistentRelea seMessage) { | 622 if (m_sessionType != WebEncryptedMediaSessionType::PersistentLicense && m_se ssionType != WebEncryptedMediaSessionType::PersistentReleaseMessage) { |
| 612 return ScriptPromise::rejectWithDOMException( | 623 return ScriptPromise::rejectWithDOMException( |
| 613 scriptState, DOMException::create(InvalidAccessError, "The session t ype is not persistent.")); | 624 scriptState, DOMException::create(InvalidAccessError, "The session t ype is not persistent.")); |
| 614 } | 625 } |
| 615 | 626 |
| 616 // 3. If the Session Close algorithm has been run on this object, return a | 627 // 3. If the Session Close algorithm has been run on this object, return a |
| 617 // promise rejected with a new DOMException whose name is | 628 // promise rejected with a new DOMException whose name is |
| 618 // "InvalidStateError". | 629 // "InvalidStateError". |
| 619 if (m_isClosed) { | 630 if (m_isClosed) { |
| 620 return ScriptPromise::rejectWithDOMException( | 631 return ScriptPromise::rejectWithDOMException( |
| 621 scriptState, DOMException::create(InvalidStateError, "The session is already closed.")); | 632 scriptState, DOMException::create(InvalidStateError, "The session is already closed.")); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 visitor->trace(m_asyncEventQueue); | 950 visitor->trace(m_asyncEventQueue); |
| 940 visitor->trace(m_pendingActions); | 951 visitor->trace(m_pendingActions); |
| 941 visitor->trace(m_mediaKeys); | 952 visitor->trace(m_mediaKeys); |
| 942 visitor->trace(m_keyStatusesMap); | 953 visitor->trace(m_keyStatusesMap); |
| 943 visitor->trace(m_closedPromise); | 954 visitor->trace(m_closedPromise); |
| 944 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace( visitor); | 955 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace( visitor); |
| 945 ActiveDOMObject::trace(visitor); | 956 ActiveDOMObject::trace(visitor); |
| 946 } | 957 } |
| 947 | 958 |
| 948 } // namespace blink | 959 } // namespace blink |
| OLD | NEW |