Index: Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
diff --git a/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp b/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
index e998d7df349128f3f308d77d935fbe453366c8bc..e3ad9e40f8ed373297f7981d665936adf851f3a8 100644 |
--- a/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
+++ b/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
@@ -290,8 +290,9 @@ DEFINE_TRACE(SetMediaKeysHandler) |
ScriptPromiseResolver::trace(visitor); |
} |
-HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia() |
- : m_emeMode(EmeModeNotSelected) |
+HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia(HTMLMediaElement& element) |
+ : m_mediaElement(element) |
+ , m_emeMode(EmeModeNotSelected) |
, m_isWaitingForKey(false) |
{ |
} |
@@ -314,7 +315,7 @@ HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl |
{ |
HTMLMediaElementEncryptedMedia* supplement = static_cast<HTMLMediaElementEncryptedMedia*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supplementName())); |
if (!supplement) { |
- supplement = new HTMLMediaElementEncryptedMedia(); |
+ supplement = new HTMLMediaElementEncryptedMedia(element); |
provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); |
} |
return *supplement; |
@@ -329,11 +330,6 @@ bool HTMLMediaElementEncryptedMedia::setEmeMode(EmeMode emeMode) |
return true; |
} |
-WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryptionModule() |
-{ |
- return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; |
-} |
- |
MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) |
{ |
HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element); |
@@ -496,7 +492,7 @@ void HTMLMediaElementEncryptedMedia::cancelKeyRequest(WebMediaPlayer* webMediaPl |
throwExceptionIfMediaKeyExceptionOccurred(keySystem, sessionId, result, exceptionState); |
} |
-void HTMLMediaElementEncryptedMedia::keyAdded(HTMLMediaElement& element, const String& keySystem, const String& sessionId) |
+void HTMLMediaElementEncryptedMedia::keyAdded(const WebString& keySystem, const WebString& sessionId) |
{ |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyAdded"); |
@@ -505,32 +501,32 @@ void HTMLMediaElementEncryptedMedia::keyAdded(HTMLMediaElement& element, const S |
initializer.setSessionId(sessionId); |
RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyadded, initializer); |
- event->setTarget(&element); |
- element.scheduleEvent(event.release()); |
+ event->setTarget(&m_mediaElement); |
+ m_mediaElement.scheduleEvent(event.release()); |
} |
-void HTMLMediaElementEncryptedMedia::keyError(HTMLMediaElement& element, const String& keySystem, const String& sessionId, WebMediaPlayerClient::MediaKeyErrorCode errorCode, unsigned short systemCode) |
+void HTMLMediaElementEncryptedMedia::keyError(const WebString& keySystem, const WebString& sessionId, WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCode errorCode, unsigned short systemCode) |
{ |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyError: sessionID=%s, errorCode=%d, systemCode=%d", sessionId.utf8().data(), errorCode, systemCode); |
MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
switch (errorCode) { |
- case WebMediaPlayerClient::MediaKeyErrorCodeUnknown: |
+ case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeUnknown: |
mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
break; |
- case WebMediaPlayerClient::MediaKeyErrorCodeClient: |
+ case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeClient: |
mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; |
break; |
- case WebMediaPlayerClient::MediaKeyErrorCodeService: |
+ case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeService: |
mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_SERVICE; |
break; |
- case WebMediaPlayerClient::MediaKeyErrorCodeOutput: |
+ case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeOutput: |
mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_OUTPUT; |
break; |
- case WebMediaPlayerClient::MediaKeyErrorCodeHardwareChange: |
+ case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeHardwareChange: |
mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_HARDWARECHANGE; |
break; |
- case WebMediaPlayerClient::MediaKeyErrorCodeDomain: |
+ case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeDomain: |
mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_DOMAIN; |
break; |
} |
@@ -542,11 +538,11 @@ void HTMLMediaElementEncryptedMedia::keyError(HTMLMediaElement& element, const S |
initializer.setSystemCode(systemCode); |
RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyerror, initializer); |
- event->setTarget(&element); |
- element.scheduleEvent(event.release()); |
+ event->setTarget(&m_mediaElement); |
+ m_mediaElement.scheduleEvent(event.release()); |
} |
-void HTMLMediaElementEncryptedMedia::keyMessage(HTMLMediaElement& element, const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL) |
+void HTMLMediaElementEncryptedMedia::keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL) |
{ |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyMessage: sessionID=%s", sessionId.utf8().data()); |
@@ -557,18 +553,18 @@ void HTMLMediaElementEncryptedMedia::keyMessage(HTMLMediaElement& element, const |
initializer.setDefaultURL(KURL(defaultURL)); |
RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeymessage, initializer); |
- event->setTarget(&element); |
- element.scheduleEvent(event.release()); |
+ event->setTarget(&m_mediaElement); |
+ m_mediaElement.scheduleEvent(event.release()); |
} |
-void HTMLMediaElementEncryptedMedia::encrypted(HTMLMediaElement& element, WebEncryptedMediaInitDataType initDataType, const unsigned char* initData, unsigned initDataLength) |
+void HTMLMediaElementEncryptedMedia::encrypted(WebEncryptedMediaInitDataType initDataType, const unsigned char* initData, unsigned initDataLength) |
{ |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::encrypted"); |
if (RuntimeEnabledFeatures::encryptedMediaEnabled()) { |
// Send event for WD EME. |
RefPtrWillBeRawPtr<Event> event; |
- if (element.isMediaDataCORSSameOrigin(element.executionContext()->securityOrigin())) { |
+ if (m_mediaElement.isMediaDataCORSSameOrigin(m_mediaElement.executionContext()->securityOrigin())) { |
event = createEncryptedEvent(initDataType, initData, initDataLength); |
} else { |
// Current page is not allowed to see content from the media file, |
@@ -576,19 +572,19 @@ void HTMLMediaElementEncryptedMedia::encrypted(HTMLMediaElement& element, WebEnc |
event = createEncryptedEvent(WebEncryptedMediaInitDataType::Unknown, nullptr, 0); |
} |
- event->setTarget(&element); |
- element.scheduleEvent(event.release()); |
+ event->setTarget(&m_mediaElement); |
+ m_mediaElement.scheduleEvent(event.release()); |
} |
if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { |
// Send event for v0.1b EME. |
RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(initData, initDataLength); |
- event->setTarget(&element); |
- element.scheduleEvent(event.release()); |
+ event->setTarget(&m_mediaElement); |
+ m_mediaElement.scheduleEvent(event.release()); |
} |
} |
-void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey(HTMLMediaElement& element) |
+void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey() |
{ |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey"); |
@@ -598,38 +594,36 @@ void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey(HTMLMediaElem |
// FIXME: Is this really required? |
// 1. Let the media element be the specified HTMLMediaElement object. |
- HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element); |
+ // This is nothing but |this| element. |
ddorwin
2015/07/06 20:43:01
nit: This could be more concise. However, you coul
philipj_slow
2015/07/06 20:51:17
Isn't the comment incorrect? |this| will be a HTML
ddorwin
2015/07/06 20:53:41
Yes. I should have included that in my comment, bu
Srirama
2015/07/09 15:19:37
Removed it.
|
// 2. If the media element's waiting for key value is false, queue a task |
// to fire a simple event named waitingforkey at the media element. |
- if (!thisElement.m_isWaitingForKey) { |
+ if (!m_isWaitingForKey) { |
RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::waitingforkey); |
- event->setTarget(&element); |
- element.scheduleEvent(event.release()); |
+ event->setTarget(&m_mediaElement); |
+ m_mediaElement.scheduleEvent(event.release()); |
} |
// 3. Set the media element's waiting for key value to true. |
- thisElement.m_isWaitingForKey = true; |
+ m_isWaitingForKey = true; |
// 4. Suspend playback. |
// (Already done on the Chromium side by the decryptors.) |
} |
-void HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey(HTMLMediaElement& element) |
+void HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey() |
{ |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey"); |
// Logic is on the Chromium side to attempt to resume playback when a new |
// key is available. However, |m_isWaitingForKey| needs to be cleared so |
// that a later waitingForKey() call can generate the event. |
- HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element); |
- thisElement.m_isWaitingForKey = false; |
+ m_isWaitingForKey = false; |
} |
-WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryptionModule(HTMLMediaElement& element) |
+WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryptionModule() |
{ |
- HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element); |
- return thisElement.contentDecryptionModule(); |
+ return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; |
} |
DEFINE_TRACE(HTMLMediaElementEncryptedMedia) |