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

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

Issue 705003002: Change the return type of WTF::bind() to |OwnPtr<Function>| (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reflect comments from yhirano Created 6 years, 1 month 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
« no previous file with comments | « Source/core/workers/WorkerThread.cpp ('k') | Source/modules/filesystem/LocalFileSystem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 Timer<SetMediaKeysHandler> m_timer; 70 Timer<SetMediaKeysHandler> m_timer;
71 }; 71 };
72 72
73 typedef Function<void()> SuccessCallback; 73 typedef Function<void()> SuccessCallback;
74 typedef Function<void(ExceptionCode, const String&)> FailureCallback; 74 typedef Function<void(ExceptionCode, const String&)> FailureCallback;
75 75
76 // Represents the result used when setContentDecryptionModule() is called. 76 // Represents the result used when setContentDecryptionModule() is called.
77 // Calls |success| if result is resolved, |failure| is result is rejected. 77 // Calls |success| if result is resolved, |failure| is result is rejected.
78 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes ult { 78 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes ult {
79 public: 79 public:
80 SetContentDecryptionModuleResult(SuccessCallback success, FailureCallback fa ilure) 80 SetContentDecryptionModuleResult(PassOwnPtr<SuccessCallback> success, PassOw nPtr<FailureCallback> failure)
81 : m_successCallback(success) 81 : m_successCallback(success)
82 , m_failureCallback(failure) 82 , m_failureCallback(failure)
83 { 83 {
84 } 84 }
85 85
86 // ContentDecryptionModuleResult implementation. 86 // ContentDecryptionModuleResult implementation.
87 virtual void complete() override 87 virtual void complete() override
88 { 88 {
89 m_successCallback(); 89 (*m_successCallback)();
90 } 90 }
91 91
92 virtual void completeWithSession(blink::WebContentDecryptionModuleResult::Se ssionStatus status) override 92 virtual void completeWithSession(blink::WebContentDecryptionModuleResult::Se ssionStatus status) override
93 { 93 {
94 ASSERT_NOT_REACHED(); 94 ASSERT_NOT_REACHED();
95 m_failureCallback(InvalidStateError, "Unexpected completion."); 95 (*m_failureCallback)(InvalidStateError, "Unexpected completion.");
96 } 96 }
97 97
98 virtual void completeWithError(blink::WebContentDecryptionModuleException co de, unsigned long systemCode, const blink::WebString& message) override 98 virtual void completeWithError(blink::WebContentDecryptionModuleException co de, unsigned long systemCode, const blink::WebString& message) override
99 { 99 {
100 m_failureCallback(WebCdmExceptionToExceptionCode(code), message); 100 (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), message);
101 } 101 }
102 102
103 private: 103 private:
104 SuccessCallback m_successCallback; 104 OwnPtr<SuccessCallback> m_successCallback;
105 FailureCallback m_failureCallback; 105 OwnPtr<FailureCallback> m_failureCallback;
106 }; 106 };
107 107
108 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys) 108 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys)
109 { 109 {
110 RefPtr<SetMediaKeysHandler> handler = adoptRef(new SetMediaKeysHandler(scrip tState, element, mediaKeys)); 110 RefPtr<SetMediaKeysHandler> handler = adoptRef(new SetMediaKeysHandler(scrip tState, element, mediaKeys));
111 handler->suspendIfNeeded(); 111 handler->suspendIfNeeded();
112 handler->keepAliveWhilePending(); 112 handler->keepAliveWhilePending();
113 return handler->promise(); 113 return handler->promise();
114 } 114 }
115 115
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // 3.3.1 Associate the CDM instance represented by mediaKeys with the 181 // 3.3.1 Associate the CDM instance represented by mediaKeys with the
182 // media element for decrypting media data. 182 // media element for decrypting media data.
183 // 3.3.2 If the preceding step failed, run the following steps: 183 // 3.3.2 If the preceding step failed, run the following steps:
184 // (done in reportSetFailed()). 184 // (done in reportSetFailed()).
185 // 3.3.3 Run the Attempt to Resume Playback If Necessary algorithm on 185 // 3.3.3 Run the Attempt to Resume Playback If Necessary algorithm on
186 // the media element. The user agent may choose to skip this 186 // the media element. The user agent may choose to skip this
187 // step if it knows resuming will fail (i.e. mediaKeys has no 187 // step if it knows resuming will fail (i.e. mediaKeys has no
188 // sessions). 188 // sessions).
189 // (Handled in Chromium). 189 // (Handled in Chromium).
190 if (m_element->webMediaPlayer()) { 190 if (m_element->webMediaPlayer()) {
191 SuccessCallback successCallback = bind(&SetMediaKeysHandler::finish, this); 191 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler: :finish, this);
192 FailureCallback failureCallback = bind<ExceptionCode, const String&> (&SetMediaKeysHandler::reportSetFailed, this); 192 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const String&>(&SetMediaKeysHandler::reportSetFailed, this);
193 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback, failureCallback); 193 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback.release(), failureCallback.release());
194 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe ys->contentDecryptionModule(), result->result()); 194 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe ys->contentDecryptionModule(), result->result());
195 195
196 // Don't do anything more until |result| is resolved (or rejected). 196 // Don't do anything more until |result| is resolved (or rejected).
197 return; 197 return;
198 } 198 }
199 } 199 }
200 200
201 // MediaKeys doesn't need to be set on the player, so continue on. 201 // MediaKeys doesn't need to be set on the player, so continue on.
202 finish(); 202 finish();
203 } 203 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return thisElement.contentDecryptionModule(); 543 return thisElement.contentDecryptionModule();
544 } 544 }
545 545
546 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) 546 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor)
547 { 547 {
548 visitor->trace(m_mediaKeys); 548 visitor->trace(m_mediaKeys);
549 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); 549 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor);
550 } 550 }
551 551
552 } // namespace blink 552 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerThread.cpp ('k') | Source/modules/filesystem/LocalFileSystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698