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

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

Issue 606653006: bindings: Adds DOMArrayBuffer, etc. as thin wrappers for ArrayBuffer, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed Win GPU tests (DOMDataView). Created 6 years, 2 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 | Annotate | Revision Log
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 12 matching lines...) Expand all
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "modules/encryptedmedia/MediaKeySession.h" 27 #include "modules/encryptedmedia/MediaKeySession.h"
28 28
29 #include "bindings/core/v8/DOMWrapperWorld.h" 29 #include "bindings/core/v8/DOMWrapperWorld.h"
30 #include "bindings/core/v8/ScriptPromise.h" 30 #include "bindings/core/v8/ScriptPromise.h"
31 #include "bindings/core/v8/ScriptPromiseResolver.h" 31 #include "bindings/core/v8/ScriptPromiseResolver.h"
32 #include "bindings/core/v8/ScriptState.h" 32 #include "bindings/core/v8/ScriptState.h"
33 #include "core/dom/DOMArrayBuffer.h"
34 #include "core/dom/DOMArrayBufferView.h"
33 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
34 #include "core/events/Event.h" 36 #include "core/events/Event.h"
35 #include "core/events/GenericEventQueue.h" 37 #include "core/events/GenericEventQueue.h"
36 #include "core/html/MediaKeyError.h" 38 #include "core/html/MediaKeyError.h"
37 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" 39 #include "modules/encryptedmedia/MediaKeyMessageEvent.h"
38 #include "modules/encryptedmedia/MediaKeys.h" 40 #include "modules/encryptedmedia/MediaKeys.h"
39 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" 41 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h"
40 #include "platform/ContentDecryptionModuleResult.h" 42 #include "platform/ContentDecryptionModuleResult.h"
41 #include "platform/ContentType.h" 43 #include "platform/ContentType.h"
42 #include "platform/Logging.h" 44 #include "platform/Logging.h"
43 #include "platform/MIMETypeRegistry.h" 45 #include "platform/MIMETypeRegistry.h"
44 #include "platform/Timer.h" 46 #include "platform/Timer.h"
45 #include "public/platform/WebContentDecryptionModule.h" 47 #include "public/platform/WebContentDecryptionModule.h"
46 #include "public/platform/WebContentDecryptionModuleException.h" 48 #include "public/platform/WebContentDecryptionModuleException.h"
47 #include "public/platform/WebContentDecryptionModuleSession.h" 49 #include "public/platform/WebContentDecryptionModuleSession.h"
48 #include "public/platform/WebString.h" 50 #include "public/platform/WebString.h"
49 #include "public/platform/WebURL.h" 51 #include "public/platform/WebURL.h"
50 #include "wtf/ArrayBuffer.h"
51 #include "wtf/ArrayBufferView.h"
52 52
53 namespace blink { 53 namespace blink {
54 54
55 static bool isKeySystemSupportedWithInitDataType(const String& keySystem, const String& initDataType) 55 static bool isKeySystemSupportedWithInitDataType(const String& keySystem, const String& initDataType)
56 { 56 {
57 ASSERT(!keySystem.isEmpty()); 57 ASSERT(!keySystem.isEmpty());
58 58
59 // FIXME: initDataType != contentType. Implement this properly. 59 // FIXME: initDataType != contentType. Implement this properly.
60 // http://crbug.com/385874. 60 // http://crbug.com/385874.
61 String contentType = initDataType; 61 String contentType = initDataType;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 String MediaKeySession::sessionId() const 273 String MediaKeySession::sessionId() const
274 { 274 {
275 return m_session->sessionId(); 275 return m_session->sessionId();
276 } 276 }
277 277
278 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) 278 ScriptPromise MediaKeySession::closed(ScriptState* scriptState)
279 { 279 {
280 return m_closedPromise->promise(scriptState->world()); 280 return m_closedPromise->promise(scriptState->world());
281 } 281 }
282 282
283 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataType, ArrayBuffer* initData) 283 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataType, DOMArrayBuffer* initData)
284 { 284 {
285 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->data(), ini tData->byteLength()); 285 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->data(), ini tData->byteLength());
286 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea se()); 286 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea se());
287 } 287 }
288 288
289 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataType, ArrayBufferView* initData) 289 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S tring& initDataType, DOMArrayBufferView* initData)
290 { 290 {
291 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->baseAddress (), initData->byteLength()); 291 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->baseAddress (), initData->byteLength());
292 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea se()); 292 return generateRequestInternal(scriptState, initDataType, initDataCopy.relea se());
293 } 293 }
294 294
295 ScriptPromise MediaKeySession::generateRequestInternal(ScriptState* scriptState, const String& initDataType, PassRefPtr<ArrayBuffer> initData) 295 ScriptPromise MediaKeySession::generateRequestInternal(ScriptState* scriptState, const String& initDataType, PassRefPtr<ArrayBuffer> initData)
296 { 296 {
297 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType .ascii().data()); 297 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType .ascii().data());
298 298
299 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-generaterequest: 299 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-generaterequest:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // 10. Run the following steps asynchronously (documented in 349 // 10. Run the following steps asynchronously (documented in
350 // actionTimerFired()) 350 // actionTimerFired())
351 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initData)); 351 m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initData));
352 ASSERT(!m_actionTimer.isActive()); 352 ASSERT(!m_actionTimer.isActive());
353 m_actionTimer.startOneShot(0, FROM_HERE); 353 m_actionTimer.startOneShot(0, FROM_HERE);
354 354
355 // 11. Return promise. 355 // 11. Return promise.
356 return promise; 356 return promise;
357 } 357 }
358 358
359 ScriptPromise MediaKeySession::update(ScriptState* scriptState, ArrayBuffer* res ponse) 359 ScriptPromise MediaKeySession::update(ScriptState* scriptState, DOMArrayBuffer* response)
360 { 360 {
361 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->data(), res ponse->byteLength()); 361 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->data(), res ponse->byteLength());
362 return updateInternal(scriptState, responseCopy.release()); 362 return updateInternal(scriptState, responseCopy.release());
363 } 363 }
364 364
365 ScriptPromise MediaKeySession::update(ScriptState* scriptState, ArrayBufferView* response) 365 ScriptPromise MediaKeySession::update(ScriptState* scriptState, DOMArrayBufferVi ew* response)
366 { 366 {
367 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->baseAddress (), response->byteLength()); 367 RefPtr<ArrayBuffer> responseCopy = ArrayBuffer::create(response->baseAddress (), response->byteLength());
368 return updateInternal(scriptState, responseCopy.release()); 368 return updateInternal(scriptState, responseCopy.release());
369 } 369 }
370 370
371 ScriptPromise MediaKeySession::updateInternal(ScriptState* scriptState, PassRefP tr<ArrayBuffer> response) 371 ScriptPromise MediaKeySession::updateInternal(ScriptState* scriptState, PassRefP tr<ArrayBuffer> response)
372 { 372 {
373 WTF_LOG(Media, "MediaKeySession(%p)::update", this); 373 WTF_LOG(Media, "MediaKeySession(%p)::update", this);
374 ASSERT(!m_isClosed); 374 ASSERT(!m_isClosed);
375 375
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 void MediaKeySession::message(const unsigned char* message, size_t messageLength , const WebURL& destinationURL) 521 void MediaKeySession::message(const unsigned char* message, size_t messageLength , const WebURL& destinationURL)
522 { 522 {
523 WTF_LOG(Media, "MediaKeySession(%p)::message", this); 523 WTF_LOG(Media, "MediaKeySession(%p)::message", this);
524 524
525 // Verify that 'message' not fired before session initialization is complete . 525 // Verify that 'message' not fired before session initialization is complete .
526 ASSERT(m_isCallable); 526 ASSERT(m_isCallable);
527 527
528 MediaKeyMessageEventInit init; 528 MediaKeyMessageEventInit init;
529 init.bubbles = false; 529 init.bubbles = false;
530 init.cancelable = false; 530 init.cancelable = false;
531 init.message = ArrayBuffer::create(static_cast<const void*>(message), messag eLength); 531 init.message = DOMArrayBuffer::create(static_cast<const void*>(message), mes sageLength);
532 init.destinationURL = destinationURL.string(); 532 init.destinationURL = destinationURL.string();
533 533
534 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat e(EventTypeNames::message, init); 534 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat e(EventTypeNames::message, init);
535 event->setTarget(this); 535 event->setTarget(this);
536 m_asyncEventQueue->enqueueEvent(event.release()); 536 m_asyncEventQueue->enqueueEvent(event.release());
537 } 537 }
538 538
539 void MediaKeySession::ready() 539 void MediaKeySession::ready()
540 { 540 {
541 WTF_LOG(Media, "MediaKeySession(%p)::ready", this); 541 WTF_LOG(Media, "MediaKeySession(%p)::ready", this);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 { 647 {
648 visitor->trace(m_error); 648 visitor->trace(m_error);
649 visitor->trace(m_asyncEventQueue); 649 visitor->trace(m_asyncEventQueue);
650 visitor->trace(m_pendingActions); 650 visitor->trace(m_pendingActions);
651 visitor->trace(m_mediaKeys); 651 visitor->trace(m_mediaKeys);
652 visitor->trace(m_closedPromise); 652 visitor->trace(m_closedPromise);
653 EventTargetWithInlineData::trace(visitor); 653 EventTargetWithInlineData::trace(visitor);
654 } 654 }
655 655
656 } // namespace blink 656 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698