OLD | NEW |
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/HTMLMediaElementEncryptedMedia.h" | 6 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 ASSERT_NOT_REACHED(); | 46 ASSERT_NOT_REACHED(); |
47 return; | 47 return; |
48 } | 48 } |
49 | 49 |
50 // This class allows MediaKeys to be set asynchronously. | 50 // This class allows MediaKeys to be set asynchronously. |
51 class SetMediaKeysHandler : public ScriptPromiseResolver { | 51 class SetMediaKeysHandler : public ScriptPromiseResolver { |
52 WTF_MAKE_NONCOPYABLE(SetMediaKeysHandler); | 52 WTF_MAKE_NONCOPYABLE(SetMediaKeysHandler); |
53 | 53 |
54 public: | 54 public: |
55 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*); | 55 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*); |
56 virtual ~SetMediaKeysHandler(); | 56 ~SetMediaKeysHandler() override; |
57 | 57 |
58 DECLARE_VIRTUAL_TRACE(); | 58 DECLARE_VIRTUAL_TRACE(); |
59 | 59 |
60 private: | 60 private: |
61 SetMediaKeysHandler(ScriptState*, HTMLMediaElement&, MediaKeys*); | 61 SetMediaKeysHandler(ScriptState*, HTMLMediaElement&, MediaKeys*); |
62 void timerFired(Timer<SetMediaKeysHandler>*); | 62 void timerFired(Timer<SetMediaKeysHandler>*); |
63 | 63 |
64 void clearExistingMediaKeys(); | 64 void clearExistingMediaKeys(); |
65 void setNewMediaKeys(); | 65 void setNewMediaKeys(); |
66 | 66 |
(...skipping 17 matching lines...) Expand all Loading... |
84 // Calls |success| if result is resolved, |failure| is result is rejected. | 84 // Calls |success| if result is resolved, |failure| is result is rejected. |
85 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes
ult { | 85 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes
ult { |
86 public: | 86 public: |
87 SetContentDecryptionModuleResult(PassOwnPtr<SuccessCallback> success, PassOw
nPtr<FailureCallback> failure) | 87 SetContentDecryptionModuleResult(PassOwnPtr<SuccessCallback> success, PassOw
nPtr<FailureCallback> failure) |
88 : m_successCallback(success) | 88 : m_successCallback(success) |
89 , m_failureCallback(failure) | 89 , m_failureCallback(failure) |
90 { | 90 { |
91 } | 91 } |
92 | 92 |
93 // ContentDecryptionModuleResult implementation. | 93 // ContentDecryptionModuleResult implementation. |
94 virtual void complete() override | 94 void complete() override |
95 { | 95 { |
96 (*m_successCallback)(); | 96 (*m_successCallback)(); |
97 } | 97 } |
98 | 98 |
99 virtual void completeWithContentDecryptionModule(WebContentDecryptionModule*
) override | 99 void completeWithContentDecryptionModule(WebContentDecryptionModule*) overri
de |
100 { | 100 { |
101 ASSERT_NOT_REACHED(); | 101 ASSERT_NOT_REACHED(); |
102 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); | 102 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); |
103 } | 103 } |
104 | 104 |
105 virtual void completeWithSession(WebContentDecryptionModuleResult::SessionSt
atus status) override | 105 void completeWithSession(WebContentDecryptionModuleResult::SessionStatus sta
tus) override |
106 { | 106 { |
107 ASSERT_NOT_REACHED(); | 107 ASSERT_NOT_REACHED(); |
108 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); | 108 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); |
109 } | 109 } |
110 | 110 |
111 virtual void completeWithError(WebContentDecryptionModuleException code, uns
igned long systemCode, const WebString& message) override | 111 void completeWithError(WebContentDecryptionModuleException code, unsigned lo
ng systemCode, const WebString& message) override |
112 { | 112 { |
113 // Non-zero |systemCode| is appended to the |message|. If the |message| | 113 // Non-zero |systemCode| is appended to the |message|. If the |message| |
114 // is empty, we'll report "Rejected with system code (systemCode)". | 114 // is empty, we'll report "Rejected with system code (systemCode)". |
115 String errorString = message; | 115 String errorString = message; |
116 if (systemCode != 0) { | 116 if (systemCode != 0) { |
117 if (errorString.isEmpty()) | 117 if (errorString.isEmpty()) |
118 errorString.append("Rejected with system code"); | 118 errorString.append("Rejected with system code"); |
119 errorString.append(" (" + String::number(systemCode) + ")"); | 119 errorString.append(" (" + String::number(systemCode) + ")"); |
120 } | 120 } |
121 (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), errorString); | 121 (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), errorString); |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 return thisElement.contentDecryptionModule(); | 632 return thisElement.contentDecryptionModule(); |
633 } | 633 } |
634 | 634 |
635 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) | 635 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) |
636 { | 636 { |
637 visitor->trace(m_mediaKeys); | 637 visitor->trace(m_mediaKeys); |
638 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 638 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
639 } | 639 } |
640 | 640 |
641 } // namespace blink | 641 } // namespace blink |
OLD | NEW |