Chromium Code Reviews| Index: Source/modules/webaudio/OfflineAudioContext.h |
| diff --git a/Source/modules/webaudio/OfflineAudioContext.h b/Source/modules/webaudio/OfflineAudioContext.h |
| index 99276e7cbb5e19dc7edf2934b67a726f2eed8d2a..bb903fe1662995139f0fbcabee8c3088902a58cc 100644 |
| --- a/Source/modules/webaudio/OfflineAudioContext.h |
| +++ b/Source/modules/webaudio/OfflineAudioContext.h |
| @@ -31,6 +31,7 @@ |
| namespace blink { |
| class ExceptionState; |
| +class ScheduledSuspendContainer; |
| class MODULES_EXPORT OfflineAudioContext final : public AudioContext { |
| DEFINE_WRAPPERTYPEINFO(); |
| @@ -39,9 +40,75 @@ public: |
| virtual ~OfflineAudioContext(); |
| + DECLARE_TRACE(); |
| + |
| + // Check all the scheduled suspends if the context should suspend at |
| + // currentTime(). Then post tasks to resolve promises on the main thread |
| + // if necessary. |
| + bool shouldSuspendNow(); |
|
yhirano
2015/06/18 13:40:52
+override
ditto for below
hongchan
2015/06/18 18:22:31
Done.
|
| + |
| + // Clear suspensions marked as 'resolved' in the list. |
| + void resolvePendingSuspendPromises(); |
| + |
| + // Fire completion event when the rendering is finished. |
| + void fireCompletionEvent(); |
| + |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(complete); |
| + |
| ScriptPromise startOfflineRendering(ScriptState*); |
| + ScriptPromise suspendOfflineRendering(ScriptState*, double); |
| + ScriptPromise resumeOfflineRendering(ScriptState*); |
| + |
| private: |
| OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate); |
| + |
| + // Resolve pending suspend promises and removes them from the list. |
| + void resolvePendingSuspendPromisesOnMainThread(); |
| + |
| + HeapVector<Member<ScheduledSuspendContainer>> m_scheduledSuspends; |
| + RefPtrWillBeMember<ScriptPromiseResolver> m_completeResolver; |
| + |
| + // This flag is necessary to indicate the rendering has actually started. |
| + // Note that initial state of context is 'Suspended', which is the same |
| + // state when the context is suspended. |
| + bool m_isRenderingStarted; |
| + |
| + // Total render sample length. |
| + size_t m_totalRenderFrames; |
| +}; |
| + |
| +// A container class for a pair of time information and the suspend promise |
| +// resolver. |
| +class ScheduledSuspendContainer : public GarbageCollectedFinalized<ScheduledSuspendContainer> { |
| +public: |
| + static ScheduledSuspendContainer* create(size_t suspendFrame, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>); |
| + ~ScheduledSuspendContainer(); |
| + |
| + DECLARE_TRACE(); |
| + |
| + PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_resolver; } |
| + |
| + // Query if the rendering should be suspended at |whenFrame|. |
| + bool shouldSuspendAt(size_t whenFrame) const; |
| + |
| + // Query if the suspend is pending for the promise resolution. |
| + bool isPending() const; |
| + |
| + // Mark the suspend as pending. Containers with 'pending' flag will |
| + // be collectively resolved when the actual suspension happens. |
| + void markAsPending(); |
| + |
| +private: |
| + ScheduledSuspendContainer(size_t suspendFrame, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>); |
| + |
| + // Suspend time in samples. |
| + size_t m_suspendFrame; |
| + |
| + // Associated promise resolver. |
| + RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; |
| + |
| + // A pending marker for the safe batch removal. |
| + bool m_isPending; |
| }; |
| } // namespace blink |