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

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

Issue 1916283003: [K6] Replace bind() + GCed pointers with retainedRef() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_5c
Patch Set: Rebase 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" 5 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // 5.2.1 If the user agent or CDM do not support removing the 159 // 5.2.1 If the user agent or CDM do not support removing the
160 // association, let this object's attaching media keys 160 // association, let this object's attaching media keys
161 // value be false and reject promise with a NotSupportedError. 161 // value be false and reject promise with a NotSupportedError.
162 // 5.2.2 If the association cannot currently be removed, 162 // 5.2.2 If the association cannot currently be removed,
163 // let this object's attaching media keys value be false 163 // let this object's attaching media keys value be false
164 // and reject promise with an InvalidStateError. 164 // and reject promise with an InvalidStateError.
165 // 5.2.3 Stop using the CDM instance represented by the mediaKeys 165 // 5.2.3 Stop using the CDM instance represented by the mediaKeys
166 // attribute to decrypt media data and remove the association 166 // attribute to decrypt media data and remove the association
167 // with the media element. 167 // with the media element.
168 // (All 3 steps handled as needed in Chromium.) 168 // (All 3 steps handled as needed in Chromium.)
169 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler: :setNewMediaKeys, this); 169 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler: :setNewMediaKeys, retainedRef(this));
170 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const String&>(&SetMediaKeysHandler::clearFailed, this); 170 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const String&>(&SetMediaKeysHandler::clearFailed, retainedRef(this));
171 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback.release(), failureCallback.release()); 171 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback.release(), failureCallback.release());
172 mediaPlayer->setContentDecryptionModule(nullptr, result->result()); 172 mediaPlayer->setContentDecryptionModule(nullptr, result->result());
173 173
174 // Don't do anything more until |result| is resolved (or rejected). 174 // Don't do anything more until |result| is resolved (or rejected).
175 return; 175 return;
176 } 176 }
177 } 177 }
178 178
179 // MediaKeys not currently set or no player connected, so continue on. 179 // MediaKeys not currently set or no player connected, so continue on.
180 setNewMediaKeys(); 180 setNewMediaKeys();
181 } 181 }
182 182
183 void SetMediaKeysHandler::setNewMediaKeys() 183 void SetMediaKeysHandler::setNewMediaKeys()
184 { 184 {
185 WTF_LOG(Media, "SetMediaKeysHandler::setNewMediaKeys"); 185 WTF_LOG(Media, "SetMediaKeysHandler::setNewMediaKeys");
186 186
187 // 5.3 If mediaKeys is not null, run the following steps: 187 // 5.3 If mediaKeys is not null, run the following steps:
188 if (m_newMediaKeys) { 188 if (m_newMediaKeys) {
189 // 5.3.1 Associate the CDM instance represented by mediaKeys with the 189 // 5.3.1 Associate the CDM instance represented by mediaKeys with the
190 // media element for decrypting media data. 190 // media element for decrypting media data.
191 // 5.3.2 If the preceding step failed, run the following steps: 191 // 5.3.2 If the preceding step failed, run the following steps:
192 // (done in setFailed()). 192 // (done in setFailed()).
193 // 5.3.3 Queue a task to run the Attempt to Resume Playback If Necessary 193 // 5.3.3 Queue a task to run the Attempt to Resume Playback If Necessary
194 // algorithm on the media element. 194 // algorithm on the media element.
195 // (Handled in Chromium). 195 // (Handled in Chromium).
196 if (m_element->webMediaPlayer()) { 196 if (m_element->webMediaPlayer()) {
197 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler: :finish, this); 197 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler: :finish, retainedRef(this));
198 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const String&>(&SetMediaKeysHandler::setFailed, this); 198 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const String&>(&SetMediaKeysHandler::setFailed, retainedRef(this));
199 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback.release(), failureCallback.release()); 199 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback.release(), failureCallback.release());
200 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe ys->contentDecryptionModule(), result->result()); 200 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe ys->contentDecryptionModule(), result->result());
201 201
202 // Don't do anything more until |result| is resolved (or rejected). 202 // Don't do anything more until |result| is resolved (or rejected).
203 return; 203 return;
204 } 204 }
205 } 205 }
206 206
207 // MediaKeys doesn't need to be set on the player, so continue on. 207 // MediaKeys doesn't need to be set on the player, so continue on.
208 finish(); 208 finish();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 406 }
407 407
408 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) 408 DEFINE_TRACE(HTMLMediaElementEncryptedMedia)
409 { 409 {
410 visitor->trace(m_mediaElement); 410 visitor->trace(m_mediaElement);
411 visitor->trace(m_mediaKeys); 411 visitor->trace(m_mediaKeys);
412 Supplement<HTMLMediaElement>::trace(visitor); 412 Supplement<HTMLMediaElement>::trace(visitor);
413 } 413 }
414 414
415 } // namespace blink 415 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698