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

Unified Diff: Source/modules/encryptedmedia/MediaKeys.cpp

Issue 950813005: Change initDataType and sessionType to be enums (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: android compile issues Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/encryptedmedia/MediaKeys.cpp
diff --git a/Source/modules/encryptedmedia/MediaKeys.cpp b/Source/modules/encryptedmedia/MediaKeys.cpp
index c898ab9acce156a4bd644e20d3e06aad57110ae0..1524b94f1be0a31de3b124bcaa64bb81a1050f6e 100644
--- a/Source/modules/encryptedmedia/MediaKeys.cpp
+++ b/Source/modules/encryptedmedia/MediaKeys.cpp
@@ -80,7 +80,7 @@ private:
const RefPtr<DOMArrayBuffer> m_data;
};
-MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, const blink::WebVector<blink::WebString>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm)
+MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, const blink::WebVector<WebEncryptedMediaSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm)
: ContextLifecycleObserver(context)
, m_keySystem(keySystem)
, m_supportedSessionTypes(supportedSessionTypes)
@@ -99,7 +99,7 @@ MediaKeys::~MediaKeys()
WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this);
}
-MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String& sessionType, ExceptionState& exceptionState)
+MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String& sessionTypeString, ExceptionState& exceptionState)
{
WTF_LOG(Media, "MediaKeys(%p)::createSession", this);
@@ -114,14 +114,8 @@ MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String
// 2. If the Key System implementation represented by this object's cdm
// implementation value does not support sessionType, throw a new
// DOMException whose name is NotSupportedError.
- bool found = false;
- for (size_t i = 0; i < m_supportedSessionTypes.size(); i++) {
- if (m_supportedSessionTypes[i] == blink::WebString(sessionType)) {
- found = true;
- break;
- }
- }
- if (!found)
+ WebEncryptedMediaSessionType sessionType = MediaKeySession::convertSessionType(sessionTypeString);
+ if (!sessionTypeSupported(sessionType))
exceptionState.throwDOMException(NotSupportedError, "Unsupported session type.");
// 3. Let session be a new MediaKeySession object, and initialize it as
@@ -166,6 +160,16 @@ ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO
return promise;
}
+bool MediaKeys::sessionTypeSupported(WebEncryptedMediaSessionType sessionType)
+{
+ for (size_t i = 0; i < m_supportedSessionTypes.size(); i++) {
+ if (m_supportedSessionTypes[i] == sessionType)
+ return true;
+ }
+
+ return false;
+}
+
void MediaKeys::timerFired(Timer<MediaKeys>*)
{
ASSERT(m_pendingActions.size());
« no previous file with comments | « Source/modules/encryptedmedia/MediaKeys.h ('k') | Source/platform/exported/WebContentDecryptionModuleSession.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698