Remove database thread pause code
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Aug 2015 00:57:51 +0000 (00:57 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Aug 2015 00:57:51 +0000 (00:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147669

Reviewed by Daniel Bates.

Source/WebCore:

We now grab power assertions while running SQLite transactions,
and this code isn't used at all with modern WebKit so let's just get rid of it.

* Modules/webdatabase/DatabaseContext.cpp:
(WebCore::DatabaseContext::DatabaseContext): Deleted.
(WebCore::DatabaseContext::databaseThread): Deleted.
(WebCore::DatabaseContext::setPaused): Deleted.
* Modules/webdatabase/DatabaseContext.h:
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::Database::DatabaseTransactionTask::shouldPerformWhilePaused): Deleted.
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::DatabaseThread): Deleted.
(WebCore::DatabaseThread::requestTermination): Deleted.
(WebCore::DatabaseUnpauseTask::DatabaseUnpauseTask): Deleted.
(WebCore::DatabaseUnpauseTask::shouldPerformWhilePaused): Deleted.
(WebCore::DatabaseUnpauseTask::doPerformTask): Deleted.
(WebCore::DatabaseUnpauseTask::debugTaskName): Deleted.
(WebCore::DatabaseThread::setPaused): Deleted.
(WebCore::DatabaseThread::handlePausedQueue): Deleted.
(WebCore::DatabaseThread::databaseThread): Deleted.
* Modules/webdatabase/DatabaseThread.h:
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::setDatabasesPaused): Deleted.
* Modules/webdatabase/DatabaseTracker.h:

Source/WebKit/ios:

* Misc/WebUIKitSupport.mm:
(WebKitSetBackgroundAndForegroundNotificationNames):
(applicationDidEnterBackground): Deleted.
(applicationWillEnterForeground): Deleted.

Source/WebKit/mac:

* Storage/WebDatabaseManager.mm:
(WebKitSetWebDatabasePaused): Deleted.
* Storage/WebDatabaseManagerInternal.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187926 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/DatabaseContext.cpp
Source/WebCore/Modules/webdatabase/DatabaseContext.h
Source/WebCore/Modules/webdatabase/DatabaseTask.cpp
Source/WebCore/Modules/webdatabase/DatabaseTask.h
Source/WebCore/Modules/webdatabase/DatabaseThread.cpp
Source/WebCore/Modules/webdatabase/DatabaseThread.h
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.h
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/Misc/WebUIKitSupport.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Storage/WebDatabaseManager.mm
Source/WebKit/mac/Storage/WebDatabaseManagerInternal.h

index a183ef3..3823071 100644 (file)
@@ -1,3 +1,36 @@
+2015-08-04  Anders Carlsson  <andersca@apple.com>
+
+        Remove database thread pause code
+        https://bugs.webkit.org/show_bug.cgi?id=147669
+
+        Reviewed by Daniel Bates.
+
+        We now grab power assertions while running SQLite transactions, 
+        and this code isn't used at all with modern WebKit so let's just get rid of it.
+
+        * Modules/webdatabase/DatabaseContext.cpp:
+        (WebCore::DatabaseContext::DatabaseContext): Deleted.
+        (WebCore::DatabaseContext::databaseThread): Deleted.
+        (WebCore::DatabaseContext::setPaused): Deleted.
+        * Modules/webdatabase/DatabaseContext.h:
+        * Modules/webdatabase/DatabaseTask.cpp:
+        (WebCore::Database::DatabaseTransactionTask::shouldPerformWhilePaused): Deleted.
+        * Modules/webdatabase/DatabaseTask.h:
+        * Modules/webdatabase/DatabaseThread.cpp:
+        (WebCore::DatabaseThread::DatabaseThread): Deleted.
+        (WebCore::DatabaseThread::requestTermination): Deleted.
+        (WebCore::DatabaseUnpauseTask::DatabaseUnpauseTask): Deleted.
+        (WebCore::DatabaseUnpauseTask::shouldPerformWhilePaused): Deleted.
+        (WebCore::DatabaseUnpauseTask::doPerformTask): Deleted.
+        (WebCore::DatabaseUnpauseTask::debugTaskName): Deleted.
+        (WebCore::DatabaseThread::setPaused): Deleted.
+        (WebCore::DatabaseThread::handlePausedQueue): Deleted.
+        (WebCore::DatabaseThread::databaseThread): Deleted.
+        * Modules/webdatabase/DatabaseThread.h:
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::setDatabasesPaused): Deleted.
+        * Modules/webdatabase/DatabaseTracker.h:
+
 2015-08-04  Chris Dumez  <cdumez@apple.com>
 
         Subframes with no current HistoryItem should not prevent page-caching
index 4c184ba..8ac7ece 100644 (file)
@@ -99,9 +99,6 @@ DatabaseContext::DatabaseContext(ScriptExecutionContext* context)
     , m_hasOpenDatabases(false)
     , m_isRegistered(true) // will register on construction below.
     , m_hasRequestedTermination(false)
-#if PLATFORM(IOS)
-    , m_paused(false)
-#endif
 {
     // ActiveDOMObject expects this to be called to set internal flags.
     suspendIfNeeded();
@@ -156,9 +153,6 @@ bool DatabaseContext::canSuspendForPageCache() const
 DatabaseThread* DatabaseContext::databaseThread()
 {
     if (!m_databaseThread && !m_hasOpenDatabases) {
-#if PLATFORM(IOS)
-        MutexLocker lock(m_databaseThreadMutex);
-#endif
         // It's OK to ask for the m_databaseThread after we've requested
         // termination because we're still using it to execute the closing
         // of the database. However, it is NOT OK to create a new thread
@@ -170,27 +164,11 @@ DatabaseThread* DatabaseContext::databaseThread()
         m_databaseThread = DatabaseThread::create();
         if (!m_databaseThread->start())
             m_databaseThread = nullptr;
-
-#if PLATFORM(IOS)
-        if (m_databaseThread)
-            m_databaseThread->setPaused(m_paused);
-#endif
     }
 
     return m_databaseThread.get();
 }
 
-#if PLATFORM(IOS)
-void DatabaseContext::setPaused(bool paused)
-{
-    MutexLocker lock(m_databaseThreadMutex);
-
-    m_paused = paused;
-    if (m_databaseThread)
-        m_databaseThread->setPaused(m_paused);
-}
-#endif // PLATFORM(IOS)
-
 bool DatabaseContext::stopDatabases(DatabaseTaskSynchronizer* synchronizer)
 {
     if (m_isRegistered) {
index 93aa461..54d54e0 100644 (file)
@@ -50,10 +50,6 @@ public:
 
     DatabaseThread* databaseThread();
 
-#if PLATFORM(IOS)
-    void setPaused(bool);
-#endif
-
     void setHasOpenDatabases() { m_hasOpenDatabases = true; }
     bool hasOpenDatabases() const { return m_hasOpenDatabases; }
 
@@ -84,11 +80,6 @@ private:
     bool m_hasRequestedTermination;
 
     friend class DatabaseManager;
-
-#if PLATFORM(IOS)
-    Mutex m_databaseThreadMutex;
-    bool m_paused;
-#endif
 };
 
 } // namespace WebCore
index 385ff9d..43f8571 100644 (file)
@@ -172,13 +172,6 @@ DatabaseBackend::DatabaseTransactionTask::~DatabaseTransactionTask()
         m_transaction->notifyDatabaseThreadIsShuttingDown();
 }
 
-#if PLATFORM(IOS)
-bool Database::DatabaseTransactionTask::shouldPerformWhilePaused() const
-{
-    return m_transaction->shouldPerformWhilePaused();
-}
-#endif
-
 void DatabaseBackend::DatabaseTransactionTask::doPerformTask()
 {
     m_transaction->performNextStep();
index ae2459f..705392e 100644 (file)
@@ -71,10 +71,6 @@ class DatabaseTask {
 public:
     virtual ~DatabaseTask();
 
-#if PLATFORM(IOS)
-    virtual bool shouldPerformWhilePaused() const = 0;
-#endif
-
     void performTask();
 
     DatabaseBackend* database() const { return m_database; }
@@ -102,10 +98,6 @@ class DatabaseBackend::DatabaseOpenTask : public DatabaseTask {
 public:
     DatabaseOpenTask(DatabaseBackend*, bool setVersionInNewDatabase, DatabaseTaskSynchronizer*, DatabaseError&, String& errorMessage, bool& success);
 
-#if PLATFORM(IOS)
-    virtual bool shouldPerformWhilePaused() const override { return true; }
-#endif
-
 private:
     virtual void doPerformTask() override;
 #if !LOG_DISABLED
@@ -122,10 +114,6 @@ class DatabaseBackend::DatabaseCloseTask : public DatabaseTask {
 public:
     DatabaseCloseTask(DatabaseBackend*, DatabaseTaskSynchronizer*);
 
-#if PLATFORM(IOS)
-    virtual bool shouldPerformWhilePaused() const override { return true; }
-#endif
-
 private:
     virtual void doPerformTask() override;
 #if !LOG_DISABLED
@@ -138,10 +126,6 @@ public:
     explicit DatabaseTransactionTask(PassRefPtr<SQLTransactionBackend>);
     virtual ~DatabaseTransactionTask();
 
-#if PLATFORM(IOS)
-    virtual bool shouldPerformWhilePaused() const override;
-#endif
-
     SQLTransactionBackend* transaction() const { return m_transaction.get(); }
 
 private:
@@ -158,10 +142,6 @@ class DatabaseBackend::DatabaseTableNamesTask : public DatabaseTask {
 public:
     DatabaseTableNamesTask(DatabaseBackend*, DatabaseTaskSynchronizer*, Vector<String>& names);
 
-#if PLATFORM(IOS)
-    virtual bool shouldPerformWhilePaused() const override { return true; }
-#endif
-
 private:
     virtual void doPerformTask() override;
 #if !LOG_DISABLED
index aade72c..e4a9ade 100644 (file)
@@ -40,9 +40,6 @@ namespace WebCore {
 
 DatabaseThread::DatabaseThread()
     : m_threadID(0)
-#if PLATFORM(IOS)
-    , m_paused(false)
-#endif
     , m_transactionClient(std::make_unique<SQLTransactionClient>())
     , m_transactionCoordinator(std::make_unique<SQLTransactionCoordinator>())
     , m_cleanupSync(nullptr)
@@ -78,9 +75,6 @@ void DatabaseThread::requestTermination(DatabaseTaskSynchronizer *cleanupSync)
 {
     m_cleanupSync = cleanupSync;
     LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this);
-#if PLATFORM(IOS)
-    m_pausedQueue.kill();
-#endif
     m_queue.kill();
 }
 
@@ -102,75 +96,6 @@ void DatabaseThread::databaseThreadStart(void* vDatabaseThread)
     dbThread->databaseThread();
 }
 
-#if PLATFORM(IOS)
-class DatabaseUnpauseTask : public DatabaseTask {
-public:
-    explicit DatabaseUnpauseTask(DatabaseThread& thread)
-        : DatabaseTask(0, 0)
-        , m_thread(thread)
-    { }
-
-    virtual bool shouldPerformWhilePaused() const 
-    {
-        // Since we're not locking the DatabaseThread::m_paused in the main database thread loop, it's possible that
-        // a DatabaseUnpauseTask might be added to the m_pausedQueue and performed from within ::handlePausedQueue.
-        // To protect against this, we allow it to be performed even if the database is paused.
-        // If the thread is paused when it is being performed, the tasks from the paused queue will simply be
-        // requeued instead of performed.
-        return true;
-    }
-
-private:
-    virtual void doPerformTask()
-    {
-        m_thread.handlePausedQueue();
-    }
-#if !LOG_DISABLED
-    virtual const char* debugTaskName() const { return "DatabaseUnpauseTask"; }
-#endif
-
-    DatabaseThread& m_thread;
-};
-
-
-void DatabaseThread::setPaused(bool paused)
-{
-    if (m_paused == paused)
-        return;
-
-    MutexLocker pausedLocker(m_pausedMutex);
-    m_paused = paused;
-    if (!m_paused)
-        scheduleTask(std::make_unique<DatabaseUnpauseTask>(*this));
-}
-
-void DatabaseThread::handlePausedQueue()
-{
-    Vector<std::unique_ptr<DatabaseTask> > pausedTasks;
-    while (auto task = m_pausedQueue.tryGetMessage())
-        pausedTasks.append(WTF::move(task));
-
-    for (auto& pausedTask : pausedTasks) {
-        AutodrainedPool pool;
-
-        std::unique_ptr<DatabaseTask> task(pausedTask.release());
-        {
-            MutexLocker pausedLocker(m_pausedMutex);
-            if (m_paused) {
-                m_pausedQueue.append(WTF::move(task));
-                continue;
-            }
-        }
-            
-        if (terminationRequested())
-            break;
-    
-        task->performTask();
-    }
-}
-#endif //PLATFORM(IOS)
-
-
 void DatabaseThread::databaseThread()
 {
     {
@@ -182,14 +107,7 @@ void DatabaseThread::databaseThread()
     while (auto task = m_queue.waitForMessage()) {
         AutodrainedPool pool;
 
-#if PLATFORM(IOS)
-        if (!m_paused || task->shouldPerformWhilePaused())
-            task->performTask();
-        else
-            m_pausedQueue.append(WTF::move(task));
-#else
         task->performTask();
-#endif
     }
 
     // Clean up the list of all pending transactions on this database thread
index c1f3f06..dedb5e0 100644 (file)
@@ -66,11 +66,6 @@ public:
     SQLTransactionClient* transactionClient() { return m_transactionClient.get(); }
     SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCoordinator.get(); }
 
-#if PLATFORM(IOS)
-    void setPaused(bool);
-    void handlePausedQueue();
-#endif
-
 private:
     DatabaseThread();
 
@@ -82,11 +77,6 @@ private:
     RefPtr<DatabaseThread> m_selfRef;
 
     MessageQueue<DatabaseTask> m_queue;
-#if PLATFORM(IOS)
-    MessageQueue<DatabaseTask> m_pausedQueue;
-    Mutex m_pausedMutex;
-    volatile bool m_paused;
-#endif
 
     // This set keeps track of the open databases that have been used on this thread.
     typedef HashSet<RefPtr<Database>> DatabaseSet;
index b86f3ad..ac0f422 100644 (file)
@@ -1348,22 +1348,6 @@ void DatabaseTracker::emptyDatabaseFilesRemovalTaskDidFinish()
     openDatabaseMutex().unlock();
 }
 
-void DatabaseTracker::setDatabasesPaused(bool paused)
-{
-    MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
-    if (!m_openDatabaseMap)
-        return;
-
-    // This walking is - sadly - the only reliable way to get at each open database thread.
-    // This will be cleaner once <rdar://problem/5680441> or some other DB thread consolidation takes place.
-    for (auto& databaseNameMap : m_openDatabaseMap->values()) {
-        for (auto& databaseSet : databaseNameMap->values()) {
-            for (auto& database : *databaseSet)
-                database->databaseContext()->setPaused(paused);
-        }
-    }
-}
-
 #endif
 
 void DatabaseTracker::setClient(DatabaseManagerClient* client)
index 18d1fe3..eaaccc7 100644 (file)
@@ -113,8 +113,6 @@ public:
     
     WEBCORE_EXPORT static void emptyDatabaseFilesRemovalTaskWillBeScheduled();
     WEBCORE_EXPORT static void emptyDatabaseFilesRemovalTaskDidFinish();
-    
-    WEBCORE_EXPORT void setDatabasesPaused(bool);
 #endif
     
     void setClient(DatabaseManagerClient*);
index 04469eb..dc31925 100644 (file)
@@ -1,3 +1,15 @@
+2015-08-04  Anders Carlsson  <andersca@apple.com>
+
+        Remove database thread pause code
+        https://bugs.webkit.org/show_bug.cgi?id=147669
+
+        Reviewed by Daniel Bates.
+
+        * Misc/WebUIKitSupport.mm:
+        (WebKitSetBackgroundAndForegroundNotificationNames):
+        (applicationDidEnterBackground): Deleted.
+        (applicationWillEnterForeground): Deleted.
+
 2015-07-21  Tim Horton  <timothy_horton@apple.com>
 
         Expose shrink-wrapping as UIKit support SPI
index e6d476e..02c97a6 100644 (file)
@@ -110,27 +110,9 @@ const char *WebKitPlatformSystemRootDirectory(void)
 #endif
 }
 
-static void applicationDidEnterBackground(CFNotificationCenterRef, void*, CFStringRef, const void *, CFDictionaryRef)
-{
-    WebKitSetWebDatabasePaused(true);
-}
-
-static void applicationWillEnterForeground(CFNotificationCenterRef, void*, CFStringRef, const void*, CFDictionaryRef)
-{
-    WebKitSetWebDatabasePaused(false);
-}
-
 void WebKitSetBackgroundAndForegroundNotificationNames(NSString *didEnterBackgroundName, NSString *willEnterForegroundName)
 {
-    static bool initialized = false;
-    if (initialized)
-        return;
-    initialized = true;
-
-    CFNotificationCenterRef notificationCenter = CFNotificationCenterGetLocalCenter();
-    CFNotificationCenterAddObserver(notificationCenter, 0, applicationDidEnterBackground, (CFStringRef)didEnterBackgroundName, NULL, CFNotificationSuspensionBehaviorCoalesce);
-    CFNotificationCenterAddObserver(notificationCenter, 0, applicationWillEnterForeground, (CFStringRef)willEnterForegroundName, NULL, CFNotificationSuspensionBehaviorCoalesce);
-
+    // FIXME: Remove this function.
 }
 
 static WebBackgroundTaskIdentifier invalidTaskIdentifier = 0;
index 425c6fc..0bb8c11 100644 (file)
@@ -1,3 +1,14 @@
+2015-08-04  Anders Carlsson  <andersca@apple.com>
+
+        Remove database thread pause code
+        https://bugs.webkit.org/show_bug.cgi?id=147669
+
+        Reviewed by Daniel Bates.
+
+        * Storage/WebDatabaseManager.mm:
+        (WebKitSetWebDatabasePaused): Deleted.
+        * Storage/WebDatabaseManagerInternal.h:
+
 2015-08-04  Simon Fraser  <simon.fraser@apple.com>
 
         Fix the build.
index c61e5c0..aa23608 100644 (file)
@@ -291,10 +291,6 @@ static WebBackgroundTaskIdentifier getTransactionBackgroundTaskIdentifier()
 
 @end
 
-void WebKitSetWebDatabasePaused(bool paused)
-{
-    DatabaseTracker::tracker().setDatabasesPaused(paused);
-}
 #endif // PLATFORM(IOS)
 
 static NSString *databasesDirectoryPath()