Source/WebCore/ChangeLog

 12015-05-06 Daniel Bates <dabates@apple.com>
 2
 3 [iOS][WK2] Pause/resume database thread when UIProcess enters/leaves the background
 4 https://bugs.webkit.org/show_bug.cgi?id=144657
 5 <rdar://problem/18894598>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Export WebCore functionality to pause and resume the database thread so that we can
 10 make use of this functionality from WebKit2.
 11
 12 * Modules/webdatabase/AbstractDatabaseServer.h:
 13 * Modules/webdatabase/DatabaseManager.cpp:
 14 (WebCore::DatabaseManager::setPauseAllDatabases): Added; turns around and calls DatabaseServer::setPauseAllDatabases().
 15 * Modules/webdatabase/DatabaseManager.h:
 16 * Modules/webdatabase/DatabaseServer.cpp:
 17 (WebCore::DatabaseServer::setPauseAllDatabases): Added; turns around and calls
 18 DatabaseTracker::tracker().setDatabasesPaused() to pause or resume the database thread.
 19 For now, we guard this call with PLATFORM(IOS). We'll look to remove this guard once
 20 we fix <https://bugs.webkit.org/show_bug.cgi?id=144660>.
 21 * Modules/webdatabase/DatabaseServer.h:
 22
1232015-05-04 Javier Fernandez <jfernandez@igalia.com>
224
325 [CSS Box Alignment] Upgrade justify-content parsing to CSS3 Box Alignment spec.

Source/WebKit2/ChangeLog

 12015-05-06 Daniel Bates <dabates@apple.com>
 2
 3 [iOS][WK2] Pause/resume database thread when UIProcess enters/leaves the background
 4 https://bugs.webkit.org/show_bug.cgi?id=144657
 5 <rdar://problem/18894598>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Pause and resume the database thread when the UIProcess enters and leaves the background,
 10 respectively, so that we avoid WebProcess termination due to holding a locked SQLite
 11 database file when the WebProcess is suspended. This behavior matches the analagous
 12 behavior in Legacy WebKit.
 13
 14 * UIProcess/WebPageProxy.h:
 15 * UIProcess/ios/WKContentView.mm:
 16 (-[WKContentView _applicationDidEnterBackground:]): Call WebPageProxy::applicationDidEnterBackground()
 17 when the UIProcess enters the background.
 18 * UIProcess/ios/WebPageProxyIOS.mm:
 19 (WebKit::WebPageProxy::applicationDidEnterBackground): Added; notify the WebProcess to pause the database thread.
 20 We temporarily take out background assertion on the WebProcess before sending this notification to ensure that the
 21 WebProcess is running to receive it. We'll release this assertion when the WebProcess replies that it received the
 22 notification.
 23 * WebProcess/WebCoreSupport/WebDatabaseManager.cpp:
 24 (WebKit::WebDatabaseManager::setPauseAllDatabases): Added; turns around and calls DatabaseManager::setPauseAllDatabases().
 25 * WebProcess/WebCoreSupport/WebDatabaseManager.h:
 26 * WebProcess/WebPage/WebPage.h:
 27 * WebProcess/WebPage/WebPage.messages.in: Add message ApplicationDidEnterBackground(). Also,
 28 add empty lines to help demarcate this message and the other UIKit application lifecycle-related
 29 messages from the rest of the list of messages.
 30 * WebProcess/WebPage/ios/WebPageIOS.mm:
 31 (WebKit::WebPage::applicationWillEnterForeground): Resume the database thread.
 32 (WebKit::WebPage::applicationDidEnterBackground): Pause the database thread.
 33
1342015-05-04 Zan Dobersek <zdobersek@igalia.com>
235
336 [WTF] Remove Functional.h inclusions

Source/WebCore/Modules/webdatabase/AbstractDatabaseServer.h

@@public:
7171 virtual bool deleteOrigin(SecurityOrigin*) = 0;
7272 virtual bool deleteDatabase(SecurityOrigin*, const String& name) = 0;
7373
 74 virtual void setPauseAllDatabases(bool) = 0;
 75
7476 virtual void interruptAllDatabasesForContext(const DatabaseContext*) = 0;
7577
7678protected:

Source/WebCore/Modules/webdatabase/DatabaseManager.cpp

@@bool DatabaseManager::deleteDatabase(SecurityOrigin* origin, const String& name)
397397 return m_server->deleteDatabase(origin, name);
398398}
399399
 400void DatabaseManager::setPauseAllDatabases(bool pauseAllDatabases)
 401{
 402 m_server->setPauseAllDatabases(pauseAllDatabases);
 403}
 404
400405void DatabaseManager::interruptAllDatabasesForContext(ScriptExecutionContext* context)
401406{
402407 RefPtr<DatabaseContext> databaseContext = existingDatabaseContextFor(context);

Source/WebCore/Modules/webdatabase/DatabaseManager.h

@@public:
103103 WEBCORE_EXPORT bool deleteOrigin(SecurityOrigin*);
104104 WEBCORE_EXPORT bool deleteDatabase(SecurityOrigin*, const String& name);
105105
 106 WEBCORE_EXPORT void setPauseAllDatabases(bool);
 107
106108 void interruptAllDatabasesForContext(ScriptExecutionContext*);
107109
108110private:

Source/WebCore/Modules/webdatabase/DatabaseServer.cpp

@@bool DatabaseServer::deleteDatabase(SecurityOrigin* origin, const String& name)
108108 return DatabaseTracker::tracker().deleteDatabase(origin, name);
109109}
110110
 111void DatabaseServer::setPauseAllDatabases(bool pauseAllDatabases)
 112{
 113#if PLATFORM(IOS)
 114 DatabaseTracker::tracker().setDatabasesPaused(pauseAllDatabases);
 115#else
 116 UNUSED_PARAM(pauseAllDatabases);
 117#endif
 118}
 119
111120void DatabaseServer::interruptAllDatabasesForContext(const DatabaseContext* context)
112121{
113122 DatabaseTracker::tracker().interruptAllDatabasesForContext(context);

Source/WebCore/Modules/webdatabase/DatabaseServer.h

@@public:
6060 virtual bool deleteOrigin(SecurityOrigin*);
6161 virtual bool deleteDatabase(SecurityOrigin*, const String& name);
6262
 63 void setPauseAllDatabases(bool) override;
 64
6365 virtual void interruptAllDatabasesForContext(const DatabaseContext*);
6466
6567protected:

Source/WebKit2/UIProcess/WebPageProxy.h

@@public:
493493 void setAssistedNodeValue(const String&);
494494 void setAssistedNodeValueAsNumber(double);
495495 void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection = false);
 496
496497 void applicationWillEnterForeground();
 498 void applicationDidEnterBackground();
497499 void applicationWillResignActive();
498500 void applicationDidBecomeActive();
 501
499502 void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
500503 void commitPotentialTapFailed();
501504 void didNotHandleTapAsClick(const WebCore::IntPoint&);

Source/WebKit2/UIProcess/ios/WKContentView.mm

@@- (void)_applicationWillResignActive:(NSNotification*)notification
551551- (void)_applicationDidEnterBackground:(NSNotification*)notification
552552{
553553 _isBackground = YES;
 554 _page->applicationDidEnterBackground();
554555 _page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow);
555556}
556557

Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

@@void WebPageProxy::applicationWillEnterForeground()
598598 m_process->send(Messages::WebPage::ApplicationWillEnterForeground(), m_pageID);
599599}
600600
 601void WebPageProxy::applicationDidEnterBackground()
 602{
 603 uint64_t callbackID = m_callbacks.put(std::function<void (CallbackBase::Error)>(), m_process->throttler().backgroundActivityToken());
 604 m_process->send(Messages::WebPage::ApplicationDidEnterBackground(callbackID), m_pageID);
 605}
 606
601607void WebPageProxy::applicationWillResignActive()
602608{
603609 m_process->send(Messages::WebPage::ApplicationWillResignActive(), m_pageID);

Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp

@@void WebDatabaseManager::deleteAllDatabases() const
137137 DatabaseManager::singleton().deleteAllDatabases();
138138}
139139
 140void WebDatabaseManager::setPauseAllDatabases(bool pauseAllDatabases)
 141{
 142 DatabaseManager::singleton().setPauseAllDatabases(pauseAllDatabases);
 143}
 144
140145void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const
141146{
142147 // If the quota is set to a value lower than the current usage, that quota will

Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h

@@public:
4646 void setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const;
4747 void deleteAllDatabases() const;
4848
 49 void setPauseAllDatabases(bool = true);
 50
4951private:
5052 // WebProcessSupplement
5153 virtual void initialize(const WebProcessCreationParameters&) override;

Source/WebKit2/WebProcess/WebPage/WebPage.h

@@public:
783783 void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, double oldestTimestamp);
784784 bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
785785 void willStartUserTriggeredZooming();
 786
786787 void applicationWillResignActive();
787788 void applicationWillEnterForeground();
 789 void applicationDidEnterBackground(uint64_t callbackID);
788790 void applicationDidBecomeActive();
 791
789792 void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
790793 void completePendingSyntheticClickForContentChangeObserver();
791794#endif

Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

@@messages -> WebPage LegacyReceiver {
8787 SetAssistedNodeValue(String value)
8888 SetAssistedNodeValueAsNumber(double value)
8989 SetAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection)
 90
9091 ApplicationWillResignActive()
9192 ApplicationWillEnterForeground()
 93 ApplicationDidEnterBackground(uint64_t callbackID)
9294 ApplicationDidBecomeActive()
 95
9396 ContentSizeCategoryDidChange(String contentSizeCategory)
9497 ExecuteEditCommandWithCallback(String name, uint64_t callbackID)
9598 GetLookupContextAtPoint(WebCore::IntPoint point, uint64_t callbackID)

Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

4242#import "WKAccessibilityWebPageObjectIOS.h"
4343#import "WebChromeClient.h"
4444#import "WebCoreArgumentCoders.h"
 45#import "WebDatabaseManager.h"
4546#import "WebFrame.h"
4647#import "WebImage.h"
4748#import "WebKitSystemInterface.h"

@@void WebPage::applicationWillResignActive()
27172718
27182719void WebPage::applicationWillEnterForeground()
27192720{
 2721 WebProcess::singleton().supplement<WebDatabaseManager>()->setPauseAllDatabases(false);
27202722 [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillEnterForegroundNotification object:nil];
27212723}
27222724
 2725void WebPage::applicationDidEnterBackground(uint64_t callbackID)
 2726{
 2727 WebProcess::singleton().supplement<WebDatabaseManager>()->setPauseAllDatabases();
 2728 send(Messages::WebPageProxy::VoidCallback(callbackID));
 2729}
 2730
27232731void WebPage::applicationDidBecomeActive()
27242732{
27252733 [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidBecomeActiveNotification object:nil];