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..969237166d0d0d8f9eeb8bb932b301ecf72988d4 100644 |
| --- a/Source/modules/webaudio/OfflineAudioContext.h |
| +++ b/Source/modules/webaudio/OfflineAudioContext.h |
| @@ -39,9 +39,72 @@ public: |
| virtual ~OfflineAudioContext(); |
| + // 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(); |
| + |
| + // 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); |
| + |
| + // A container class for a pair of time information and the suspend promise |
| + // resolver. |
| + class ScheduledSuspendContainer |
| + : public NoBaseWillBeGarbageCollected<ScheduledSuspendContainer> { |
| + public: |
| + static PassOwnPtr<ScheduledSuspendContainer> create(size_t suspendFrame, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>); |
| + ~ScheduledSuspendContainer(); |
| + 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'. |
|
Raymond Toy
2015/06/12 21:11:37
Describe better what pending means.
hongchan
2015/06/15 18:40:46
Done.
|
| + void markAsPending(); |
| + |
| + DECLARE_TRACE(); |
| + |
| + 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; |
| + }; |
| + |
| + // Resolve pending suspend promises and removes it from the list. |
| + void resolvePendingSuspendPromisesOnMainThread(); |
| + |
| + WillBeHeapVector<OwnPtrWillBeMember<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; |
| }; |
| } // namespace blink |