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

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

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix webusb ScriptPromiseResolver usage Created 5 years, 4 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/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return; 43 return;
44 } 44 }
45 45
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
54 public: 53 public:
55 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*); 54 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*);
56 ~SetMediaKeysHandler() override; 55 ~SetMediaKeysHandler() override;
57 56
58 DECLARE_VIRTUAL_TRACE(); 57 DECLARE_VIRTUAL_TRACE();
59 58
60 private: 59 private:
61 SetMediaKeysHandler(ScriptState*, HTMLMediaElement&, MediaKeys*); 60 SetMediaKeysHandler(ScriptState*, HTMLMediaElement&, MediaKeys*);
62 void timerFired(Timer<SetMediaKeysHandler>*); 61 void timerFired(Timer<SetMediaKeysHandler>*);
63 62
64 void clearExistingMediaKeys(); 63 void clearExistingMediaKeys();
65 void setNewMediaKeys(); 64 void setNewMediaKeys();
66 65
67 void finish(); 66 void finish();
68 void fail(ExceptionCode, const String& errorMessage); 67 void fail(ExceptionCode, const String& errorMessage);
69 68
70 void clearFailed(ExceptionCode, const String& errorMessage); 69 void clearFailed(ExceptionCode, const String& errorMessage);
71 void setFailed(ExceptionCode, const String& errorMessage); 70 void setFailed(ExceptionCode, const String& errorMessage);
72 71
73 // Keep media element alive until promise is fulfilled 72 // Keep media element alive until promise is fulfilled
74 RefPtrWillBeMember<HTMLMediaElement> m_element; 73 RefPtrWillBeMember<HTMLMediaElement> m_element;
75 PersistentWillBeMember<MediaKeys> m_newMediaKeys; 74 Member<MediaKeys> m_newMediaKeys;
76 bool m_tookOwnership; 75 bool m_tookOwnership;
77 Timer<SetMediaKeysHandler> m_timer; 76 Timer<SetMediaKeysHandler> m_timer;
78 }; 77 };
79 78
80 typedef Function<void()> SuccessCallback; 79 typedef Function<void()> SuccessCallback;
81 typedef Function<void(ExceptionCode, const String&)> FailureCallback; 80 typedef Function<void(ExceptionCode, const String&)> FailureCallback;
82 81
83 // Represents the result used when setContentDecryptionModule() is called. 82 // Represents the result used when setContentDecryptionModule() is called.
84 // Calls |success| if result is resolved, |failure| is result is rejected. 83 // Calls |success| if result is resolved, |failure| is result is rejected.
85 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes ult { 84 class SetContentDecryptionModuleResult final : public ContentDecryptionModuleRes ult {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), errorString); 120 (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), errorString);
122 } 121 }
123 122
124 private: 123 private:
125 OwnPtr<SuccessCallback> m_successCallback; 124 OwnPtr<SuccessCallback> m_successCallback;
126 OwnPtr<FailureCallback> m_failureCallback; 125 OwnPtr<FailureCallback> m_failureCallback;
127 }; 126 };
128 127
129 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys) 128 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys)
130 { 129 {
131 RefPtrWillBeRawPtr<SetMediaKeysHandler> handler = adoptRefWillBeNoop(new Set MediaKeysHandler(scriptState, element, mediaKeys)); 130 SetMediaKeysHandler* handler = new SetMediaKeysHandler(scriptState, element, mediaKeys);
132 handler->suspendIfNeeded(); 131 handler->suspendIfNeeded();
133 handler->keepAliveWhilePending(); 132 handler->keepAliveWhilePending();
134 return handler->promise(); 133 return handler->promise();
135 } 134 }
136 135
137 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, HTMLMediaElem ent& element, MediaKeys* mediaKeys) 136 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, HTMLMediaElem ent& element, MediaKeys* mediaKeys)
138 : ScriptPromiseResolver(scriptState) 137 : ScriptPromiseResolver(scriptState)
139 , m_element(element) 138 , m_element(element)
140 , m_newMediaKeys(mediaKeys) 139 , m_newMediaKeys(mediaKeys)
141 , m_tookOwnership(false) 140 , m_tookOwnership(false)
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; 623 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0;
625 } 624 }
626 625
627 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) 626 DEFINE_TRACE(HTMLMediaElementEncryptedMedia)
628 { 627 {
629 visitor->trace(m_mediaKeys); 628 visitor->trace(m_mediaKeys);
630 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); 629 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor);
631 } 630 }
632 631
633 } // namespace blink 632 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698