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

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

Issue 111043004: Update MediaKeySession method names to latest EME spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 30 matching lines...) Expand all
41 { 41 {
42 return adoptRef(new MediaKeySession(context, cdm, keys)); 42 return adoptRef(new MediaKeySession(context, cdm, keys));
43 } 43 }
44 44
45 MediaKeySession::MediaKeySession(ExecutionContext* context, ContentDecryptionMod ule* cdm, MediaKeys* keys) 45 MediaKeySession::MediaKeySession(ExecutionContext* context, ContentDecryptionMod ule* cdm, MediaKeys* keys)
46 : ContextLifecycleObserver(context) 46 : ContextLifecycleObserver(context)
47 , m_keySystem(keys->keySystem()) 47 , m_keySystem(keys->keySystem())
48 , m_asyncEventQueue(GenericEventQueue::create(this)) 48 , m_asyncEventQueue(GenericEventQueue::create(this))
49 , m_session(cdm->createSession(this)) 49 , m_session(cdm->createSession(this))
50 , m_keys(keys) 50 , m_keys(keys)
51 , m_keyRequestTimer(this, &MediaKeySession::keyRequestTimerFired) 51 , m_initializeTimer(this, &MediaKeySession::initializeTimerFired)
ddorwin 2014/01/07 02:41:55 abarth: Is it a requirement that we call these xxx
52 , m_addKeyTimer(this, &MediaKeySession::addKeyTimerFired) 52 , m_addKeyTimer(this, &MediaKeySession::addKeyTimerFired)
53 { 53 {
54 ScriptWrappable::init(this); 54 ScriptWrappable::init(this);
55 } 55 }
56 56
57 MediaKeySession::~MediaKeySession() 57 MediaKeySession::~MediaKeySession()
58 { 58 {
59 close(); 59 release();
60 } 60 }
61 61
62 void MediaKeySession::setError(MediaKeyError* error) 62 void MediaKeySession::setError(MediaKeyError* error)
63 { 63 {
64 m_error = error; 64 m_error = error;
65 } 65 }
66 66
67 void MediaKeySession::close() 67 void MediaKeySession::release()
68 { 68 {
69 ASSERT(!m_keys == !m_session); 69 ASSERT(!m_keys == !m_session);
70 70
71 if (m_session) 71 if (m_session)
72 m_session->close(); 72 m_session->release();
73 m_session.clear(); 73 m_session.clear();
74 m_asyncEventQueue->cancelAllEvents(); 74 m_asyncEventQueue->cancelAllEvents();
75 75
76 // FIXME: Release ref that MediaKeys has by removing it from m_sessions. 76 // FIXME: Release ref that MediaKeys has by removing it from m_sessions.
77 // if (m_keys) m_keys->sessionClosed(this); 77 // if (m_keys) m_keys->sessionClosed(this);
78 m_keys = 0; 78 m_keys = 0;
79 } 79 }
80 80
81 String MediaKeySession::sessionId() const 81 String MediaKeySession::sessionId() const
82 { 82 {
83 return m_session->sessionId(); 83 return m_session->sessionId();
84 } 84 }
85 85
86 void MediaKeySession::generateKeyRequest(const String& mimeType, Uint8Array* ini tData) 86 void MediaKeySession::initialize(const String& mimeType, Uint8Array* initData)
87 { 87 {
88 m_pendingKeyRequests.append(PendingKeyRequest(mimeType, initData)); 88 m_pendingMimeType = mimeType;
89 m_pendingInitData = initData;
89 // FIXME: Eliminate timers. Asynchronicity will be handled in Chromium. 90 // FIXME: Eliminate timers. Asynchronicity will be handled in Chromium.
ddorwin 2014/01/07 02:41:55 I added this comment. I wonder if it is correct (s
xhwang 2014/01/09 01:04:41 Based on abarth@'s response, we should do this acy
90 m_keyRequestTimer.startOneShot(0); 91 m_initializeTimer.startOneShot(0);
91 } 92 }
92 93
93 void MediaKeySession::keyRequestTimerFired(Timer<MediaKeySession>*) 94 void MediaKeySession::initializeTimerFired(Timer<MediaKeySession>*)
94 { 95 {
95 ASSERT(m_pendingKeyRequests.size()); 96 ASSERT(!m_pendingMimeType.isEmpty());
96 if (!m_session) 97 if (!m_session)
ddorwin 2014/01/07 02:41:55 Is this possible?
xhwang 2014/01/09 01:04:41 This is possible when release() is called.
97 return; 98 return;
98 99
99 while (!m_pendingKeyRequests.isEmpty()) { 100 // NOTE: Continued from step 4 in MediaKeys::createSession().
100 PendingKeyRequest request = m_pendingKeyRequests.takeFirst(); 101 // The user agent will asynchronously execute the following steps in the tas k:
101 102
102 // NOTE: Continued from step 5 in MediaKeys::createSession(). 103 // 1. Let request be null.
ddorwin 2014/01/07 02:41:55 These comments aren't very helpful here since all
xhwang 2014/01/09 01:04:41 Added FIXME
103 // The user agent will asynchronously execute the following steps in the task: 104 // 2. Let defaultURL be null.
104 105 // 3. Wait for the MediaKeys constructor task to complete.
ddorwin 2014/01/07 02:41:55 Should we implement steps 3 and 4 in Blink or Chro
xhwang 2014/01/09 01:04:41 Added a FIXME.
ddorwin 2014/01/25 01:49:36 FYI, I made this change: https://dvcs.w3.org/hg/ht
105 // 1. Let cdm be the cdm loaded in the MediaKeys constructor. 106 // 4. If there is a MediaKeyError stored with the MediaKeys object that occu rred because of an error
106 // 2. Let destinationURL be null. 107 // during the loading the MediaKeys constructor task then queue a task to fire a simple event named
107 108 // error at the MediaKeySession object and abort these steps.
108 // 3. Use cdm to generate a key request and follow the steps for the fir st matching condition from the following list: 109 // 5. Let cdm be the cdm loaded in the MediaKeys constructor.
109 m_session->generateKeyRequest(request.mimeType, *request.initData); 110 // 6. Use cdm to execute the following steps:
110 } 111 // 1. Process type and initData.
112 // Note: type should be used to determine how to interpret initData.
113 m_session->initialize(m_pendingMimeType, *m_pendingInitData);
114 m_pendingInitData.clear();
111 } 115 }
112 116
113 void MediaKeySession::update(Uint8Array* key, ExceptionState& exceptionState) 117 void MediaKeySession::update(Uint8Array* key, ExceptionState& exceptionState)
114 { 118 {
115 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-addkey>: 119 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-addkey>:
116 // The addKey(key) method must run the following steps: 120 // The addKey(key) method must run the following steps:
117 // 1. If the first or second argument [sic] is null or an empty array, throw an InvalidAccessError. 121 // 1. If the first or second argument [sic] is null or an empty array, throw an InvalidAccessError.
118 // NOTE: the reference to a "second argument" is a spec bug. 122 // NOTE: the reference to a "second argument" is a spec bug.
119 if (!key || !key->length()) { 123 if (!key || !key->length()) {
120 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 124 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 { 199 {
196 return EventTargetNames::MediaKeySession; 200 return EventTargetNames::MediaKeySession;
197 } 201 }
198 202
199 ExecutionContext* MediaKeySession::executionContext() const 203 ExecutionContext* MediaKeySession::executionContext() const
200 { 204 {
201 return ContextLifecycleObserver::executionContext(); 205 return ContextLifecycleObserver::executionContext();
202 } 206 }
203 207
204 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698