Make IDBDatabase / IDBRequest suspendable
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 19:24:25 +0000 (19:24 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 19:24:25 +0000 (19:24 +0000)
commit7b88ce5278793dab0232dd997ef33378f3c6e270
treebcbae0bfebfbf7e52c7522591186862f2c7e719b
parentc0f20370b788a3d1353154c6641b9a70632903bd
Make IDBDatabase / IDBRequest suspendable
https://bugs.webkit.org/show_bug.cgi?id=142076
<rdar://problem/19923085>

Reviewed by Andreas Kling.

Source/WebCore:

Make IDBDatabase / IDBRequest suspendable under certain conditions to
make it more likely for pages using indexeddb to enter the PageCache.

IDBDatabase is safely suspendable if the database is closed. IDBRequest
is safely suspendable if the request no longer has any pending activity
(i.e. state is DONE and success / failure handler was called). We may
be able to do better later but this is the bare minimum for now.

Tests: fast/history/page-cache-indexed-closed-db.html
       fast/history/page-cache-indexed-opened-db.html

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::IDBDatabase):
(WebCore::IDBDatabase::closeConnection):
(WebCore::IDBDatabase::enqueueEvent):
(WebCore::IDBDatabase::canSuspend):
* Modules/indexeddb/IDBDatabase.h:
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::canSuspend):
* Modules/indexeddb/IDBRequest.h:

LayoutTests:

Add layout tests to make sure that:
- A page with an open indexeddb database is not page-cacheable
- A page with a closed indexeddb database is page-cacheable

* fast/history/page-cache-indexed-closed-db-expected.txt: Added.
* fast/history/page-cache-indexed-closed-db.html: Added.
* fast/history/page-cache-indexed-opened-db-expected.txt: Added.
* fast/history/page-cache-indexed-opened-db.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180771 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/history/page-cache-indexed-closed-db-expected.txt [new file with mode: 0644]
LayoutTests/fast/history/page-cache-indexed-closed-db.html [new file with mode: 0644]
LayoutTests/fast/history/page-cache-indexed-opened-db-expected.txt [new file with mode: 0644]
LayoutTests/fast/history/page-cache-indexed-opened-db.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.h
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.h