Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp

Issue 1964183004: Revert of Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Remove 129 Remove
130 }; 130 };
131 131
132 Type getType() const { return m_type; } 132 Type getType() const { return m_type; }
133 133
134 const Persistent<ContentDecryptionModuleResult> result() const 134 const Persistent<ContentDecryptionModuleResult> result() const
135 { 135 {
136 return m_result; 136 return m_result;
137 } 137 }
138 138
139 DOMArrayBuffer* data() const 139 const PassRefPtr<DOMArrayBuffer> data() const
140 { 140 {
141 ASSERT(m_type == GenerateRequest || m_type == Update); 141 ASSERT(m_type == GenerateRequest || m_type == Update);
142 return m_data; 142 return m_data;
143 } 143 }
144 144
145 WebEncryptedMediaInitDataType initDataType() const 145 WebEncryptedMediaInitDataType initDataType() const
146 { 146 {
147 ASSERT(m_type == GenerateRequest); 147 ASSERT(m_type == GenerateRequest);
148 return m_initDataType; 148 return m_initDataType;
149 } 149 }
150 150
151 const String& sessionId() const 151 const String& sessionId() const
152 { 152 {
153 ASSERT(m_type == Load); 153 ASSERT(m_type == Load);
154 return m_stringData; 154 return m_stringData;
155 } 155 }
156 156
157 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe sult* result, WebEncryptedMediaInitDataType initDataType, DOMArrayBuffer* initDa ta) 157 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe sult* result, WebEncryptedMediaInitDataType initDataType, PassRefPtr<DOMArrayBuf fer> initData)
158 { 158 {
159 ASSERT(result); 159 ASSERT(result);
160 ASSERT(initData); 160 ASSERT(initData);
161 return new PendingAction(GenerateRequest, result, initDataType, initData , String()); 161 return new PendingAction(GenerateRequest, result, initDataType, initData , String());
162 } 162 }
163 163
164 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult * result, const String& sessionId) 164 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult * result, const String& sessionId)
165 { 165 {
166 ASSERT(result); 166 ASSERT(result);
167 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un known, nullptr, sessionId); 167 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un known, PassRefPtr<DOMArrayBuffer>(), sessionId);
168 } 168 }
169 169
170 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res ult, DOMArrayBuffer* data) 170 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res ult, PassRefPtr<DOMArrayBuffer> data)
171 { 171 {
172 ASSERT(result); 172 ASSERT(result);
173 ASSERT(data); 173 ASSERT(data);
174 return new PendingAction(Update, result, WebEncryptedMediaInitDataType:: Unknown, data, String()); 174 return new PendingAction(Update, result, WebEncryptedMediaInitDataType:: Unknown, data, String());
175 } 175 }
176 176
177 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu lt) 177 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu lt)
178 { 178 {
179 ASSERT(result); 179 ASSERT(result);
180 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U nknown, nullptr, String()); 180 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U nknown, PassRefPtr<DOMArrayBuffer>(), String());
181 } 181 }
182 182
183 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res ult) 183 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res ult)
184 { 184 {
185 ASSERT(result); 185 ASSERT(result);
186 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType:: Unknown, nullptr, String()); 186 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType:: Unknown, PassRefPtr<DOMArrayBuffer>(), String());
187 } 187 }
188 188
189 ~PendingAction() 189 ~PendingAction()
190 { 190 {
191 } 191 }
192 192
193 DEFINE_INLINE_TRACE() 193 DEFINE_INLINE_TRACE()
194 { 194 {
195 visitor->trace(m_result); 195 visitor->trace(m_result);
196 visitor->trace(m_data);
197 } 196 }
198 197
199 private: 198 private:
200 PendingAction(Type type, ContentDecryptionModuleResult* result, WebEncrypted MediaInitDataType initDataType, DOMArrayBuffer* data, const String& stringData) 199 PendingAction(Type type, ContentDecryptionModuleResult* result, WebEncrypted MediaInitDataType initDataType, PassRefPtr<DOMArrayBuffer> data, const String& s tringData)
201 : m_type(type) 200 : m_type(type)
202 , m_result(result) 201 , m_result(result)
203 , m_initDataType(initDataType) 202 , m_initDataType(initDataType)
204 , m_data(data) 203 , m_data(data)
205 , m_stringData(stringData) 204 , m_stringData(stringData)
206 { 205 {
207 } 206 }
208 207
209 const Type m_type; 208 const Type m_type;
210 const Member<ContentDecryptionModuleResult> m_result; 209 const Member<ContentDecryptionModuleResult> m_result;
211 const WebEncryptedMediaInitDataType m_initDataType; 210 const WebEncryptedMediaInitDataType m_initDataType;
212 const Member<DOMArrayBuffer> m_data; 211 const RefPtr<DOMArrayBuffer> m_data;
213 const String m_stringData; 212 const String m_stringData;
214 }; 213 };
215 214
216 // This class wraps the promise resolver used when initializing a new session 215 // This class wraps the promise resolver used when initializing a new session
217 // and is passed to Chromium to fullfill the promise. This implementation of 216 // and is passed to Chromium to fullfill the promise. This implementation of
218 // completeWithSession() will resolve the promise with void, while 217 // completeWithSession() will resolve the promise with void, while
219 // completeWithError() will reject the promise with an exception. complete() 218 // completeWithError() will reject the promise with an exception. complete()
220 // is not expected to be called, and will reject the promise. 219 // is not expected to be called, and will reject the promise.
221 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise { 220 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise {
222 public: 221 public:
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // (blink side doesn't know what the CDM supports, so the proper check 426 // (blink side doesn't know what the CDM supports, so the proper check
428 // will be done on the Chromium side. However, we can verify that 427 // will be done on the Chromium side. However, we can verify that
429 // |initDataType| is one of the registered values.) 428 // |initDataType| is one of the registered values.)
430 WebEncryptedMediaInitDataType initDataType = EncryptedMediaUtils::convertToI nitDataType(initDataTypeString); 429 WebEncryptedMediaInitDataType initDataType = EncryptedMediaUtils::convertToI nitDataType(initDataTypeString);
431 if (initDataType == WebEncryptedMediaInitDataType::Unknown) { 430 if (initDataType == WebEncryptedMediaInitDataType::Unknown) {
432 return ScriptPromise::rejectWithDOMException( 431 return ScriptPromise::rejectWithDOMException(
433 scriptState, DOMException::create(NotSupportedError, "The initializa tion data type '" + initDataTypeString + "' is not supported.")); 432 scriptState, DOMException::create(NotSupportedError, "The initializa tion data type '" + initDataTypeString + "' is not supported."));
434 } 433 }
435 434
436 // 6. Let init data be a copy of the contents of the initData parameter. 435 // 6. Let init data be a copy of the contents of the initData parameter.
437 DOMArrayBuffer* initDataBuffer = DOMArrayBuffer::create(initData.data(), ini tData.byteLength()); 436 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::create(initData.data (), initData.byteLength());
438 437
439 // 7. Let session type be this object's session type. 438 // 7. Let session type be this object's session type.
440 // (Done in constructor.) 439 // (Done in constructor.)
441 440
442 // 8. Let promise be a new promise. 441 // 8. Let promise be a new promise.
443 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his); 442 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his);
444 ScriptPromise promise = result->promise(); 443 ScriptPromise promise = result->promise();
445 444
446 // 9. Run the following steps asynchronously (documented in 445 // 9. Run the following steps asynchronously (documented in
447 // actionTimerFired()) 446 // actionTimerFired())
448 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initDataBuffer)); 447 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initDataBuffer.release()));
449 ASSERT(!m_actionTimer.isActive()); 448 ASSERT(!m_actionTimer.isActive());
450 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); 449 m_actionTimer.startOneShot(0, BLINK_FROM_HERE);
451 450
452 // 10. Return promise. 451 // 10. Return promise.
453 return promise; 452 return promise;
454 } 453 }
455 454
456 ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess ionId) 455 ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess ionId)
457 { 456 {
458 WTF_LOG(Media, "MediaKeySession(%p)::load %s", this, sessionId.ascii().data( )); 457 WTF_LOG(Media, "MediaKeySession(%p)::load %s", this, sessionId.ascii().data( ));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 return CreateRejectedPromiseNotCallable(scriptState); 521 return CreateRejectedPromiseNotCallable(scriptState);
523 522
524 // 2. If response is an empty array, return a promise rejected with a 523 // 2. If response is an empty array, return a promise rejected with a
525 // new DOMException whose name is InvalidAccessError. 524 // new DOMException whose name is InvalidAccessError.
526 if (!response.byteLength()) { 525 if (!response.byteLength()) {
527 return ScriptPromise::rejectWithDOMException( 526 return ScriptPromise::rejectWithDOMException(
528 scriptState, DOMException::create(InvalidAccessError, "The response parameter is empty.")); 527 scriptState, DOMException::create(InvalidAccessError, "The response parameter is empty."));
529 } 528 }
530 529
531 // 3. Let response copy be a copy of the contents of the response parameter. 530 // 3. Let response copy be a copy of the contents of the response parameter.
532 DOMArrayBuffer* responseCopy = DOMArrayBuffer::create(response.data(), respo nse.byteLength()); 531 RefPtr<DOMArrayBuffer> responseCopy = DOMArrayBuffer::create(response.data() , response.byteLength());
533 532
534 // 4. Let promise be a new promise. 533 // 4. Let promise be a new promise.
535 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp tionModuleResultPromise(scriptState); 534 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp tionModuleResultPromise(scriptState);
536 ScriptPromise promise = result->promise(); 535 ScriptPromise promise = result->promise();
537 536
538 // 5. Run the following steps asynchronously (documented in 537 // 5. Run the following steps asynchronously (documented in
539 // actionTimerFired()) 538 // actionTimerFired())
540 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC opy)); 539 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC opy.release()));
541 if (!m_actionTimer.isActive()) 540 if (!m_actionTimer.isActive())
542 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); 541 m_actionTimer.startOneShot(0, BLINK_FROM_HERE);
543 542
544 // 6. Return promise. 543 // 6. Return promise.
545 return promise; 544 return promise;
546 } 545 }
547 546
548 ScriptPromise MediaKeySession::close(ScriptState* scriptState) 547 ScriptPromise MediaKeySession::close(ScriptState* scriptState)
549 { 548 {
550 WTF_LOG(Media, "MediaKeySession(%p)::close", this); 549 WTF_LOG(Media, "MediaKeySession(%p)::close", this);
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 visitor->trace(m_asyncEventQueue); 922 visitor->trace(m_asyncEventQueue);
924 visitor->trace(m_pendingActions); 923 visitor->trace(m_pendingActions);
925 visitor->trace(m_mediaKeys); 924 visitor->trace(m_mediaKeys);
926 visitor->trace(m_keyStatusesMap); 925 visitor->trace(m_keyStatusesMap);
927 visitor->trace(m_closedPromise); 926 visitor->trace(m_closedPromise);
928 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace( visitor); 927 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace( visitor);
929 ActiveDOMObject::trace(visitor); 928 ActiveDOMObject::trace(visitor);
930 } 929 }
931 930
932 } // namespace blink 931 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698