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

Unified Diff: Source/modules/webaudio/OfflineAudioContext.h

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Promise Resolution Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/webaudio/OfflineAudioContext.h
diff --git a/Source/modules/webaudio/OfflineAudioContext.h b/Source/modules/webaudio/OfflineAudioContext.h
index 99276e7cbb5e19dc7edf2934b67a726f2eed8d2a..0d823ee2e21151b095784c5a51720a7a75d4414e 100644
--- a/Source/modules/webaudio/OfflineAudioContext.h
+++ b/Source/modules/webaudio/OfflineAudioContext.h
@@ -36,12 +36,43 @@ class MODULES_EXPORT OfflineAudioContext final : public AudioContext {
DEFINE_WRAPPERTYPEINFO();
public:
static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&);
-
virtual ~OfflineAudioContext();
+ virtual bool suspendIfNecessary();
+ bool isSuspendScheduled() const;
+
ScriptPromise startOfflineRendering(ScriptState*);
+ ScriptPromise suspendOfflineRendering(ScriptState*, double suspendTime);
+ ScriptPromise resumeOfflineRendering(ScriptState*);
+
private:
OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
+
+ // A container class for pairs of time information and suspend promise.
+ class ScheduledSuspendContainer : public NoBaseWillBeGarbageCollected<ScheduledSuspendContainer> {
+ public:
+ static PassOwnPtr<ScheduledSuspendContainer> create(double, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>);
+ ~ScheduledSuspendContainer();
+ PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_resolver; }
+ bool shouldBeSuspendedNow(double currentTime) const;
Raymond Toy 2015/05/19 22:04:45 Add comment on what this is supposed to do.
hongchan 2015/05/20 22:09:41 Done.
+
+ DECLARE_TRACE();
+
+ private:
+ ScheduledSuspendContainer(double, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>);
+
+ double m_when;
+ RefPtrWillBeMember<ScriptPromiseResolver> m_resolver;
+ };
+
+ void suspendAndResolveOnMainThread(unsigned);
+
+ // Unlike the design of real-time audio context, we keep suspend/resume
Raymond Toy 2015/05/19 22:04:45 This comment is wrong now since we're not using ju
+ // promises in separate two vectors. This is because suspend() accompanies
+ // the timing information whereas resume() resolves when it is actually
+ // called.
+ WillBeHeapVector<OwnPtrWillBeMember<ScheduledSuspendContainer>> m_scheduledSuspends;
+ WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolvers;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698