[iOS][WK2] Pause/resume database thread when UIProcess enters/leaves the background
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2015 03:23:57 +0000 (03:23 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2015 03:23:57 +0000 (03:23 +0000)
commita82facaaef491224e224ce222ea8ec5140e0ea9c
treeba786c491d6e99ef8fb5686d3bbcf5dcb74eb885
parent4165493f3d95626c11a7a96f8c1835f9a9a84881
[iOS][WK2] Pause/resume database thread when UIProcess enters/leaves the background
https://bugs.webkit.org/show_bug.cgi?id=144657
<rdar://problem/18894598>

Reviewed by Andy Estes.

Source/WebCore:

Export WebCore functionality to pause and resume the database thread so that we can
make use of this functionality from WebKit2.

* Modules/webdatabase/AbstractDatabaseServer.h:
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::setPauseAllDatabases): Added; turns around and calls DatabaseServer::setPauseAllDatabases().
* Modules/webdatabase/DatabaseManager.h:
* Modules/webdatabase/DatabaseServer.cpp:
(WebCore::DatabaseServer::setPauseAllDatabases): Added; turns around and calls
DatabaseTracker::tracker().setDatabasesPaused() to pause or resume the database thread.
For now, we guard this call with PLATFORM(IOS). We'll look to remove this guard once
we fix <https://bugs.webkit.org/show_bug.cgi?id=144660>.
* Modules/webdatabase/DatabaseServer.h:

Source/WebKit2:

Pause and resume the database thread when the UIProcess enters and leaves the background,
respectively, so that we avoid WebProcess termination due to holding a locked SQLite
database file when the WebProcess is suspended. This behavior matches the analagous
behavior in Legacy WebKit.

* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _applicationDidEnterBackground:]): Call WebPageProxy::applicationDidEnterBackground()
when the UIProcess enters the background.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::applicationDidEnterBackground): Added; notify the WebProcess to pause the database thread.
We temporarily take out background assertion on the WebProcess before sending this notification to ensure that the
WebProcess is running to receive it. We'll release this assertion when the WebProcess replies that it received the
notification.
* WebProcess/WebCoreSupport/WebDatabaseManager.cpp:
(WebKit::WebDatabaseManager::setPauseAllDatabases): Added; turns around and calls DatabaseManager::setPauseAllDatabases().
* WebProcess/WebCoreSupport/WebDatabaseManager.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: Add message ApplicationDidEnterBackground(). Also,
add empty lines to help demarcate this message and the other UIKit application lifecycle-related
messages from the rest of the list of messages.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::applicationWillEnterForeground): Resume the database thread.
(WebKit::WebPage::applicationDidEnterBackground): Pause the database thread.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183909 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/AbstractDatabaseServer.h
Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
Source/WebCore/Modules/webdatabase/DatabaseManager.h
Source/WebCore/Modules/webdatabase/DatabaseServer.cpp
Source/WebCore/Modules/webdatabase/DatabaseServer.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/WKContentView.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm