Commit 096eaf88 authored by kouhei@chromium.org's avatar kouhei@chromium.org

Remove {,un}setPendingActivity from AudioContext.

This CL removes use of {,un}setPendingActivity from AudioContext. They were used to make the wrappers alive until Document is destroyed. This CL replaces the hack with a |hasPendingActivity()| impl.

Also, this removes ASSERT(m_isStopScheduled) from d-tor. This is never set when OfflineAudioContext::create() fails after creating an instance.

TEST=media/
BUG=354845

Review URL: https://codereview.chromium.org/208493002

git-svn-id: svn://svn.chromium.org/blink/trunk@170015 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0828d5e8
......@@ -114,6 +114,7 @@ PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numbe
AudioContext::AudioContext(Document* document)
: ActiveDOMObject(document)
, m_isStopScheduled(false)
, m_isCleared(false)
, m_isInitialized(false)
, m_isAudioThreadFinished(false)
, m_destinationNode(nullptr)
......@@ -134,6 +135,7 @@ AudioContext::AudioContext(Document* document)
AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
: ActiveDOMObject(document)
, m_isStopScheduled(false)
, m_isCleared(false)
, m_isInitialized(false)
, m_isAudioThreadFinished(false)
, m_destinationNode(nullptr)
......@@ -155,9 +157,6 @@ AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t
void AudioContext::constructCommon()
{
ScriptWrappable::init(this);
// According to spec AudioContext must die only after page navigate.
// Lets mark it as ActiveDOMObject with pending activity and unmark it in clear method.
setPendingActivity(this);
FFTFrame::initialize();
......@@ -171,7 +170,6 @@ AudioContext::~AudioContext()
#endif
// AudioNodes keep a reference to their context, so there should be no way to be in the destructor if there are still AudioNodes around.
ASSERT(!m_isInitialized);
ASSERT(m_isStopScheduled);
ASSERT(!m_nodesToDelete.size());
ASSERT(!m_referencedNodes.size());
ASSERT(!m_finishedNodes.size());
......@@ -218,8 +216,7 @@ void AudioContext::clear()
m_nodesMarkedForDeletion.clear();
} while (m_nodesToDelete.size());
// It was set in constructCommon.
unsetPendingActivity(this);
m_isCleared = true;
}
void AudioContext::uninitialize()
......@@ -276,6 +273,12 @@ void AudioContext::stop()
callOnMainThread(stopDispatch, this);
}
bool AudioContext::hasPendingActivity() const
{
// According to spec AudioContext must die only after page navigates.
return !m_isCleared;
}
PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState)
{
RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate);
......
......@@ -90,6 +90,7 @@ public:
// Document notification
virtual void stop() OVERRIDE FINAL;
virtual bool hasPendingActivity() const OVERRIDE;
AudioDestinationNode* destination() { return m_destinationNode.get(); }
size_t currentSampleFrame() const { return m_destinationNode->currentSampleFrame(); }
......@@ -251,6 +252,7 @@ private:
// We'd like to schedule only one stop action for them.
bool m_isStopScheduled;
static void stopDispatch(void* userData);
bool m_isCleared;
void clear();
void scheduleNodeDeletion();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment