Make AudioContext suspendable when it is not rendering
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2015 15:58:47 +0000 (15:58 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2015 15:58:47 +0000 (15:58 +0000)
commitc9de57914d8ddd1e29e47228fda34efc4ac73141
tree35ae39c97fea7cd1eab5281e1b4ff6e662f5735c
parentff8ee1670f679b6e5fcc908242a20c0d9a29bf8a
Make AudioContext suspendable when it is not rendering
https://bugs.webkit.org/show_bug.cgi?id=142210
<rdar://problem/19923085>

Reviewed by Eric Carlson.

Source/WebCore:

Make AudioContext suspendable when it is not rendering to increase the
likelihood of entering the PageCache for pages using WebAudio.

This patch adds a state member to AudioContext with 3 possible states:
Suspended / Running / Closed, as defined in the specification:
http://webaudio.github.io/web-audio-api/#widl-AudioContext-state

This state is used to decide if we can suspend the page or not. We
can safely suspend if the AudioContext's state is suspended (did not
start rendering) or closed (Stopped rendering).

Note that this patch does not expose the AudioContext's state to the
Web yet, even though it is exposed in the latest specification.

Tests: fast/history/page-cache-closed-audiocontext.html
       fast/history/page-cache-running-audiocontext.html
       fast/history/page-cache-suspended-audiocontext.html

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::AudioContext):
(WebCore::AudioContext::uninitialize):
(WebCore::AudioContext::canSuspend):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::fireCompletionEvent):
* Modules/webaudio/AudioContext.h:

LayoutTests:

Add layout tests to check cases where an AudioContext should or should
not prevent pages from entering the page cache.

* fast/history/page-cache-closed-audiocontext-expected.txt: Added.
* fast/history/page-cache-closed-audiocontext.html: Added.
* fast/history/page-cache-running-audiocontext-expected.txt: Added.
* fast/history/page-cache-running-audiocontext.html: Added.
* fast/history/page-cache-suspended-audiocontext-expected.txt: Added.
* fast/history/page-cache-suspended-audiocontext.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/history/page-cache-closed-audiocontext-expected.txt [new file with mode: 0644]
LayoutTests/fast/history/page-cache-closed-audiocontext.html [new file with mode: 0644]
LayoutTests/fast/history/page-cache-running-audiocontext-expected.txt [new file with mode: 0644]
LayoutTests/fast/history/page-cache-running-audiocontext.html [new file with mode: 0644]
LayoutTests/fast/history/page-cache-suspended-audiocontext-expected.txt [new file with mode: 0644]
LayoutTests/fast/history/page-cache-suspended-audiocontext.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioContext.h