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

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

Issue 2342953002: Update EME errors to use TypeError (Closed)
Patch Set: Created 4 years, 3 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 Member<HTMLMediaElement> m_element; 50 Member<HTMLMediaElement> m_element;
51 Member<MediaKeys> m_newMediaKeys; 51 Member<MediaKeys> m_newMediaKeys;
52 bool m_madeReservation; 52 bool m_madeReservation;
53 Timer<SetMediaKeysHandler> m_timer; 53 Timer<SetMediaKeysHandler> m_timer;
54 }; 54 };
55 55
56 typedef Function<void()> SuccessCallback; 56 typedef Function<void()> SuccessCallback;
57 typedef Function<void(ExceptionCode, const String&)> FailureCallback; 57 typedef Function<void(ExceptionCode, const String&)> FailureCallback;
58 58
59 // Represents the result used when setContentDecryptionModule() is called. 59 // Represents the result used when setContentDecryptionModule() is called.
60 // Calls |success| if result is resolved, |failure| is result is rejected. 60 // Calls |success| if result is resolved, |failure| if result is rejected.
61 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes ult { 61 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes ult {
62 public: 62 public:
63 SetContentDecryptionModuleResult(std::unique_ptr<SuccessCallback> success, s td::unique_ptr<FailureCallback> failure) 63 SetContentDecryptionModuleResult(std::unique_ptr<SuccessCallback> success, s td::unique_ptr<FailureCallback> failure)
64 : m_successCallback(std::move(success)) 64 : m_successCallback(std::move(success))
65 , m_failureCallback(std::move(failure)) 65 , m_failureCallback(std::move(failure))
66 { 66 {
67 } 67 }
68 68
69 // ContentDecryptionModuleResult implementation. 69 // ContentDecryptionModuleResult implementation.
70 void complete() override 70 void complete() override
(...skipping 19 matching lines...) Expand all
90 // is empty, we'll report "Rejected with system code (systemCode)". 90 // is empty, we'll report "Rejected with system code (systemCode)".
91 StringBuilder result; 91 StringBuilder result;
92 result.append(message); 92 result.append(message);
93 if (systemCode != 0) { 93 if (systemCode != 0) {
94 if (result.isEmpty()) 94 if (result.isEmpty())
95 result.append("Rejected with system code"); 95 result.append("Rejected with system code");
96 result.append(" ("); 96 result.append(" (");
97 result.appendNumber(systemCode); 97 result.appendNumber(systemCode);
98 result.append(')'); 98 result.append(')');
99 } 99 }
100
101 // WebContentDecryptionModuleExceptionTypeError should be reported as
102 // a TypeError, not a DOMException. However, there is no need for a
103 // TypeError when setting/clearing the CDM, so verify that it never
104 // happens.
105 DCHECK_NE(WebContentDecryptionModuleExceptionTypeError, code);
ddorwin 2016/09/15 22:43:03 What would happen if we received this? Would the c
jrummell 2016/09/16 23:23:34 Removed now that haraken@ pointed out a better way
106
100 (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), result.toStri ng()); 107 (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), result.toStri ng());
101 } 108 }
102 109
103 private: 110 private:
104 std::unique_ptr<SuccessCallback> m_successCallback; 111 std::unique_ptr<SuccessCallback> m_successCallback;
105 std::unique_ptr<FailureCallback> m_failureCallback; 112 std::unique_ptr<FailureCallback> m_failureCallback;
106 }; 113 };
107 114
108 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys) 115 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys)
109 { 116 {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 417 }
411 418
412 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) 419 DEFINE_TRACE(HTMLMediaElementEncryptedMedia)
413 { 420 {
414 visitor->trace(m_mediaElement); 421 visitor->trace(m_mediaElement);
415 visitor->trace(m_mediaKeys); 422 visitor->trace(m_mediaKeys);
416 Supplement<HTMLMediaElement>::trace(visitor); 423 Supplement<HTMLMediaElement>::trace(visitor);
417 } 424 }
418 425
419 } // namespace blink 426 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698