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

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: comments addressed or FIXME added 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_initializeNewSessionTimer(this, &MediaKeySession::initializeNewSessionTi merFired)
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();
ddorwin 2014/01/09 01:35:31 We should NOT call release(). We may, however, wan
xhwang 2014/01/09 02:32:17 Done.
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);
ddorwin 2014/01/09 01:35:31 This probably doesn't make sense anymore given the
xhwang 2014/01/09 02:32:17 Done.
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();
ddorwin 2014/01/09 01:35:31 I think this line and below should only be in the
xhwang 2014/01/09 02:32:17 Done.
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::initializeNewSession(const String& mimeType, Uint8Array* i nitData)
87 { 87 {
88 m_pendingKeyRequests.append(PendingKeyRequest(mimeType, initData)); 88 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(mimeType, initData));
89 // FIXME: Eliminate timers. Asynchronicity will be handled in Chromium. 89 m_initializeNewSessionTimer.startOneShot(0);
90 m_keyRequestTimer.startOneShot(0);
91 } 90 }
92 91
93 void MediaKeySession::keyRequestTimerFired(Timer<MediaKeySession>*) 92 void MediaKeySession::initializeNewSessionTimerFired(Timer<MediaKeySession>*)
94 { 93 {
95 ASSERT(m_pendingKeyRequests.size()); 94 ASSERT(m_pendingInitializeNewSessionData.size());
96 if (!m_session) 95 if (!m_session)
97 return; 96 return;
ddorwin 2014/01/09 01:35:31 It might be worth noting why this can happen (rele
xhwang 2014/01/09 02:32:17 Now we remove m_session.clear() to the dtor, so we
98 97
99 while (!m_pendingKeyRequests.isEmpty()) { 98 while (!m_pendingInitializeNewSessionData.isEmpty()) {
100 PendingKeyRequest request = m_pendingKeyRequests.takeFirst(); 99 InitializeNewSessionData data = m_pendingInitializeNewSessionData.takeFi rst();
101 100 // FIXME: Refer to the spec to see what needs to be done in blink.
102 // NOTE: Continued from step 5 in MediaKeys::createSession(). 101 m_session->initializeNewSession(data.mimeType, *data.initData);
103 // The user agent will asynchronously execute the following steps in the task:
104
105 // 1. Let cdm be the cdm loaded in the MediaKeys constructor.
106 // 2. Let destinationURL be null.
107
108 // 3. Use cdm to generate a key request and follow the steps for the fir st matching condition from the following list:
109 m_session->generateKeyRequest(request.mimeType, *request.initData);
110 } 102 }
111 } 103 }
112 104
113 void MediaKeySession::update(Uint8Array* key, ExceptionState& exceptionState) 105 void MediaKeySession::update(Uint8Array* key, ExceptionState& exceptionState)
114 { 106 {
115 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-addkey>: 107 // 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: 108 // 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. 109 // 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. 110 // NOTE: the reference to a "second argument" is a spec bug.
119 if (!key || !key->length()) { 111 if (!key || !key->length()) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 { 187 {
196 return EventTargetNames::MediaKeySession; 188 return EventTargetNames::MediaKeySession;
197 } 189 }
198 190
199 ExecutionContext* MediaKeySession::executionContext() const 191 ExecutionContext* MediaKeySession::executionContext() const
200 { 192 {
201 return ContextLifecycleObserver::executionContext(); 193 return ContextLifecycleObserver::executionContext();
202 } 194 }
203 195
204 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698