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

Side by Side Diff: Source/modules/encryptedmedia/MediaKeySystemAccess.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 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 "config.h" 5 #include "config.h"
6 #include "modules/encryptedmedia/MediaKeySystemAccess.h" 6 #include "modules/encryptedmedia/MediaKeySystemAccess.h"
7 7
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
11 #include "core/dom/Document.h" 11 #include "core/dom/Document.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" 13 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h"
14 #include "modules/encryptedmedia/MediaKeySession.h"
14 #include "modules/encryptedmedia/MediaKeys.h" 15 #include "modules/encryptedmedia/MediaKeys.h"
15 #include "modules/encryptedmedia/MediaKeysController.h" 16 #include "modules/encryptedmedia/MediaKeysController.h"
16 #include "platform/Logging.h" 17 #include "platform/Logging.h"
17 #include "platform/Timer.h" 18 #include "platform/Timer.h"
18 #include "public/platform/WebContentDecryptionModule.h" 19 #include "public/platform/WebContentDecryptionModule.h"
20 #include "public/platform/WebEncryptedMediaTypes.h"
19 #include "public/platform/WebMediaKeySystemConfiguration.h" 21 #include "public/platform/WebMediaKeySystemConfiguration.h"
20 22
21 namespace blink { 23 namespace blink {
22 24
23 namespace { 25 namespace {
24 26
25 // This class wraps the promise resolver used when creating MediaKeys 27 // This class wraps the promise resolver used when creating MediaKeys
26 // and is passed to Chromium to fullfill the promise. This implementation of 28 // and is passed to Chromium to fullfill the promise. This implementation of
27 // completeWithCdm() will resolve the promise with a new MediaKeys object, 29 // completeWithCdm() will resolve the promise with a new MediaKeys object,
28 // while completeWithError() will reject the promise with an exception. 30 // while completeWithError() will reject the promise with an exception.
29 // All other complete methods are not expected to be called, and will 31 // All other complete methods are not expected to be called, and will
30 // reject the promise. 32 // reject the promise.
31 class NewCdmResultPromise : public ContentDecryptionModuleResultPromise { 33 class NewCdmResultPromise : public ContentDecryptionModuleResultPromise {
32 WTF_MAKE_NONCOPYABLE(NewCdmResultPromise); 34 WTF_MAKE_NONCOPYABLE(NewCdmResultPromise);
33 35
34 public: 36 public:
35 NewCdmResultPromise(ScriptState* scriptState, const String& keySystem, const blink::WebVector<blink::WebString>& supportedSessionTypes) 37 NewCdmResultPromise(ScriptState* scriptState, const String& keySystem, const blink::WebVector<blink::WebString>& supportedSessionTypes)
36 : ContentDecryptionModuleResultPromise(scriptState) 38 : ContentDecryptionModuleResultPromise(scriptState)
37 , m_keySystem(keySystem) 39 , m_keySystem(keySystem)
38 , m_supportedSessionTypes(supportedSessionTypes) 40 , m_supportedSessionTypes(supportedSessionTypes.size())
39 { 41 {
42 // FIXME: WebMediaKeySystemConfiguration should use the enum.
43 for (size_t i = 0; i < supportedSessionTypes.size(); i++)
44 m_supportedSessionTypes[i] = MediaKeySession::convertSessionType(sup portedSessionTypes[i]);
40 } 45 }
41 46
42 virtual ~NewCdmResultPromise() 47 virtual ~NewCdmResultPromise()
43 { 48 {
44 } 49 }
45 50
46 // ContentDecryptionModuleResult implementation. 51 // ContentDecryptionModuleResult implementation.
47 virtual void completeWithContentDecryptionModule(WebContentDecryptionModule* cdm) override 52 virtual void completeWithContentDecryptionModule(WebContentDecryptionModule* cdm) override
48 { 53 {
49 // NOTE: Continued from step 2.8 of createMediaKeys(). 54 // NOTE: Continued from step 2.8 of createMediaKeys().
50 // 2.9. Let media keys be a new MediaKeys object. 55 // 2.9. Let media keys be a new MediaKeys object.
51 MediaKeys* mediaKeys = new MediaKeys(executionContext(), m_keySystem, m_ supportedSessionTypes, adoptPtr(cdm)); 56 MediaKeys* mediaKeys = new MediaKeys(executionContext(), m_keySystem, m_ supportedSessionTypes, adoptPtr(cdm));
52 57
53 // 2.10. Resolve promise with media keys. 58 // 2.10. Resolve promise with media keys.
54 resolve(mediaKeys); 59 resolve(mediaKeys);
55 } 60 }
56 61
57 private: 62 private:
58 const String m_keySystem; 63 const String m_keySystem;
59 const blink::WebVector<blink::WebString> m_supportedSessionTypes; 64 blink::WebVector<blink::WebEncryptedMediaSessionType> m_supportedSessionType s;
60 }; 65 };
61 66
62 // These methods are the inverses of those with the same names in 67 // These methods are the inverses of those with the same names in
63 // NavigatorRequestMediaKeySystemAccess. 68 // NavigatorRequestMediaKeySystemAccess.
64 static Vector<String> convertInitDataTypes(const WebVector<WebString>& initDataT ypes) 69 static Vector<String> convertInitDataTypes(const WebVector<WebString>& initDataT ypes)
65 { 70 {
66 Vector<String> result; 71 Vector<String> result;
67 result.reserveCapacity(initDataTypes.size()); 72 result.reserveCapacity(initDataTypes.size());
68 for (size_t i = 0; i < initDataTypes.size(); i++) 73 for (size_t i = 0; i < initDataTypes.size(); i++)
69 result.append(initDataTypes[i]); 74 result.append(initDataTypes[i]);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 148
144 // 3. Return promise. 149 // 3. Return promise.
145 return promise; 150 return promise;
146 } 151 }
147 152
148 DEFINE_TRACE(MediaKeySystemAccess) 153 DEFINE_TRACE(MediaKeySystemAccess)
149 { 154 {
150 } 155 }
151 156
152 } // namespace blink 157 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/encryptedmedia/MediaKeySession.cpp ('k') | Source/modules/encryptedmedia/MediaKeys.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698