Remove unnecessary network process assertion for IDB close
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2019 15:56:45 +0000 (15:56 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2019 15:56:45 +0000 (15:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196693

Reviewed by Geoffrey Garen.

Source/WebCore:

We already took assertion at WebCore::SQLiteDatabase::close.

* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::create):
(WebCore::IDBServer::IDBServer::IDBServer):
(WebCore::IDBServer::m_quotaManagerGetter): Deleted.
(WebCore::IDBServer::IDBServer::closeDatabase): Deleted.
(WebCore::IDBServer::IDBServer::didCloseDatabase): Deleted.
* Modules/indexeddb/server/IDBServer.h:
(WebCore::IDBServer::IDBServer::create): Deleted.
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
(WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose):
(WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose):
(WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):
(WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete):
(WebCore::IDBServer::UniqueIDBDatabase::notifyServerAboutClose): Deleted.
* Modules/indexeddb/server/UniqueIDBDatabase.h:

Source/WebKit:

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::createIDBServer):
(WebKit::NetworkProcess::notifyHoldingLockedFiles): Deleted.
* NetworkProcess/NetworkProcess.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didClose):
(WebKit::NetworkProcessProxy::setIsIDBDatabaseHoldingLockedFiles): Deleted.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/IDBServer.cpp
Source/WebCore/Modules/indexeddb/server/IDBServer.h
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

index b308ba5..273d232 100644 (file)
@@ -1,3 +1,29 @@
+2019-04-09  Sihui Liu  <sihui_liu@apple.com>
+
+        Remove unnecessary network process assertion for IDB close
+        https://bugs.webkit.org/show_bug.cgi?id=196693
+
+        Reviewed by Geoffrey Garen.
+
+        We already took assertion at WebCore::SQLiteDatabase::close.
+
+        * Modules/indexeddb/server/IDBServer.cpp:
+        (WebCore::IDBServer::IDBServer::create):
+        (WebCore::IDBServer::IDBServer::IDBServer):
+        (WebCore::IDBServer::m_quotaManagerGetter): Deleted.
+        (WebCore::IDBServer::IDBServer::closeDatabase): Deleted.
+        (WebCore::IDBServer::IDBServer::didCloseDatabase): Deleted.
+        * Modules/indexeddb/server/IDBServer.h:
+        (WebCore::IDBServer::IDBServer::create): Deleted.
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
+        (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose):
+        (WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose):
+        (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):
+        (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete):
+        (WebCore::IDBServer::UniqueIDBDatabase::notifyServerAboutClose): Deleted.
+        * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
 2019-04-09  Eike Rathke  <erack@redhat.com>
 
         Initialize trackTypeAsString for call to GST_INFO_OBJECT() in TrackType::Text
index 62f320c..5bf47f2 100644 (file)
 namespace WebCore {
 namespace IDBServer {
 
-Ref<IDBServer> IDBServer::create(PAL::SessionID sessionID, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter, WTF::Function<void(bool)>&& isClosingDatabaseCallback)
+Ref<IDBServer> IDBServer::create(PAL::SessionID sessionID, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter)
 {
-    return adoptRef(*new IDBServer(sessionID, fileHandler, WTFMove(quotaManagerGetter), WTFMove(isClosingDatabaseCallback)));
+    return adoptRef(*new IDBServer(sessionID, fileHandler, WTFMove(quotaManagerGetter)));
 }
 
-Ref<IDBServer> IDBServer::create(PAL::SessionID sessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter, WTF::Function<void(bool)>&& isClosingDatabaseCallback)
+Ref<IDBServer> IDBServer::create(PAL::SessionID sessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter)
 {
-    return adoptRef(*new IDBServer(sessionID, databaseDirectoryPath, fileHandler, WTFMove(quotaManagerGetter), WTFMove(isClosingDatabaseCallback)));
+    return adoptRef(*new IDBServer(sessionID, databaseDirectoryPath, fileHandler, WTFMove(quotaManagerGetter)));
 }
 
-IDBServer::IDBServer(PAL::SessionID sessionID, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter, WTF::Function<void(bool)>&& isClosingDatabaseCallback)
+IDBServer::IDBServer(PAL::SessionID sessionID, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter)
     : CrossThreadTaskHandler("IndexedDatabase Server")
     , m_sessionID(sessionID)
     , m_backingStoreTemporaryFileHandler(fileHandler)
-    , m_isClosingDatabaseCallback(WTFMove(isClosingDatabaseCallback))
-    , m_isClosingDatabaseHysteresis([&](PAL::HysteresisState state) { m_isClosingDatabaseCallback(state == PAL::HysteresisState::Started); })
     , m_quotaManagerGetter(WTFMove(quotaManagerGetter))
 {
 }
 
-IDBServer::IDBServer(PAL::SessionID sessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter, WTF::Function<void(bool)>&& isClosingDatabaseCallback)
+IDBServer::IDBServer(PAL::SessionID sessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter)
     : CrossThreadTaskHandler("IndexedDatabase Server")
     , m_sessionID(sessionID)
     , m_databaseDirectoryPath(databaseDirectoryPath)
     , m_backingStoreTemporaryFileHandler(fileHandler)
-    , m_isClosingDatabaseCallback(WTFMove(isClosingDatabaseCallback))
-    , m_isClosingDatabaseHysteresis([&](PAL::HysteresisState state) { m_isClosingDatabaseCallback(state == PAL::HysteresisState::Started); })
     , m_quotaManagerGetter(WTFMove(quotaManagerGetter))
 {
     LOG(IndexedDB, "IDBServer created at path %s", databaseDirectoryPath.utf8().data());
@@ -702,29 +698,6 @@ void IDBServer::setPerOriginQuota(uint64_t quota)
         database->setQuota(quota);
 }
 
-void IDBServer::closeDatabase(UniqueIDBDatabase* database)
-{
-    ASSERT(isMainThread());
-    if (m_databaseDirectoryPath.isEmpty())
-        return;
-
-    auto addResult = m_uniqueIDBDatabasesInClose.add(database);
-    if (addResult.isNewEntry && m_uniqueIDBDatabasesInClose.size() == 1)
-        m_isClosingDatabaseHysteresis.start();
-}
-
-void IDBServer::didCloseDatabase(UniqueIDBDatabase* database)
-{
-    ASSERT(isMainThread());
-    if (m_databaseDirectoryPath.isEmpty())
-        return;
-
-    if (m_uniqueIDBDatabasesInClose.remove(database)) {
-        if (m_uniqueIDBDatabasesInClose.isEmpty())
-            m_isClosingDatabaseHysteresis.stop();
-    }
-}
-
 IDBServer::QuotaUser::QuotaUser(IDBServer& server, StorageQuotaManager* manager, ClientOrigin&& origin)
     : m_server(server)
     , m_manager(makeWeakPtr(manager))
index 33c3313..0b84687 100644 (file)
@@ -61,8 +61,8 @@ class IDBBackingStoreTemporaryFileHandler;
 class IDBServer : public RefCounted<IDBServer>, public CrossThreadTaskHandler, public CanMakeWeakPtr<IDBServer> {
 public:
     using QuotaManagerGetter = WTF::Function<StorageQuotaManager*(PAL::SessionID, const ClientOrigin&)>;
-    static Ref<IDBServer> create(PAL::SessionID, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&, WTF::Function<void(bool)>&& isClosingDatabaseCallback = [](bool) { });
-    WEBCORE_EXPORT static Ref<IDBServer> create(PAL::SessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&, WTF::Function<void(bool)>&& isClosingDatabaseCallback = [](bool) { });
+    static Ref<IDBServer> create(PAL::SessionID, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&);
+    WEBCORE_EXPORT static Ref<IDBServer> create(PAL::SessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&);
 
     WEBCORE_EXPORT void registerConnection(IDBConnectionToClient&);
     WEBCORE_EXPORT void unregisterConnection(IDBConnectionToClient&);
@@ -116,10 +116,6 @@ public:
     uint64_t perOriginQuota() const { return m_perOriginQuota; }
     WEBCORE_EXPORT void setPerOriginQuota(uint64_t);
 
-    void closeDatabase(UniqueIDBDatabase*);
-    void didCloseDatabase(UniqueIDBDatabase*);
-    void hysteresisUpdated(PAL::HysteresisState);
-
     void requestSpace(const ClientOrigin&, uint64_t taskSize, CompletionHandler<void(StorageQuotaManager::Decision)>&&);
     void increasePotentialSpaceUsed(const ClientOrigin&, uint64_t taskSize);
     void decreasePotentialSpaceUsed(const ClientOrigin&, uint64_t taskSize);
@@ -129,8 +125,8 @@ public:
     void initializeQuotaUser(const ClientOrigin& origin) { ensureQuotaUser(origin); }
 
 private:
-    IDBServer(PAL::SessionID, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&, WTF::Function<void(bool)>&&);
-    IDBServer(PAL::SessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&, WTF::Function<void(bool)>&&);
+    IDBServer(PAL::SessionID, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&);
+    IDBServer(PAL::SessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&);
 
     UniqueIDBDatabase& getOrCreateUniqueIDBDatabase(const IDBDatabaseIdentifier&);
 
@@ -186,7 +182,6 @@ private:
     PAL::SessionID m_sessionID;
     HashMap<uint64_t, RefPtr<IDBConnectionToClient>> m_connectionMap;
     HashMap<IDBDatabaseIdentifier, std::unique_ptr<UniqueIDBDatabase>> m_uniqueIDBDatabaseMap;
-    HashSet<UniqueIDBDatabase*> m_uniqueIDBDatabasesInClose;
 
     HashMap<uint64_t, UniqueIDBDatabaseConnection*> m_databaseConnections;
     HashMap<IDBResourceIdentifier, UniqueIDBDatabaseTransaction*> m_transactions;
@@ -198,9 +193,6 @@ private:
 
     uint64_t m_perOriginQuota { defaultPerOriginQuota };
 
-    WTF::Function<void(bool)> m_isClosingDatabaseCallback;
-    PAL::HysteresisActivity m_isClosingDatabaseHysteresis;
-
     HashMap<ClientOrigin, std::unique_ptr<QuotaUser>> m_quotaUsers;
     QuotaManagerGetter m_quotaManagerGetter;
 };
index 8332503..6b80001 100644 (file)
@@ -330,7 +330,6 @@ void UniqueIDBDatabase::performCurrentDeleteOperation()
             didDeleteBackingStore(0);
         else {
             m_deleteBackingStoreInProgress = true;
-            notifyServerAboutClose(CloseState::Start);
             postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::deleteBackingStore, m_identifier));
         }
     }
@@ -383,7 +382,6 @@ void UniqueIDBDatabase::scheduleShutdownForClose()
     RELEASE_ASSERT(!m_owningPointerForClose);
     m_owningPointerForClose = m_server->closeAndTakeUniqueIDBDatabase(*this);
 
-    notifyServerAboutClose(CloseState::Start);
     postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::shutdownForClose));
 }
 
@@ -411,7 +409,6 @@ void UniqueIDBDatabase::didShutdownForClose()
 {
     ASSERT(m_databaseReplyQueue.isEmpty());
     m_databaseReplyQueue.kill();
-    notifyServerAboutClose(CloseState::Done);
 }
 
 void UniqueIDBDatabase::didDeleteBackingStore(uint64_t deletedVersion)
@@ -447,7 +444,6 @@ void UniqueIDBDatabase::didDeleteBackingStore(uint64_t deletedVersion)
 
     if (m_hardClosedForUserDelete)
         return;
-    notifyServerAboutClose(CloseState::Done);
 
     invokeOperationAndTransactionTimer();
 }
@@ -2221,7 +2217,6 @@ void UniqueIDBDatabase::immediateCloseForUserDelete()
     if (m_owningPointerForClose)
         return;
 
-    notifyServerAboutClose(CloseState::Start);
     // Otherwise, this database is still potentially active.
     // So we'll have it own itself and then perform a clean unconditional delete on the background thread.
     m_owningPointerForClose = m_server->closeAndTakeUniqueIDBDatabase(*this);
@@ -2314,19 +2309,6 @@ void UniqueIDBDatabase::setQuota(uint64_t quota)
         m_backingStore->setQuota(quota);
 }
 
-void UniqueIDBDatabase::notifyServerAboutClose(CloseState state)
-{
-    ASSERT(isMainThread());
-#if PLATFORM(IOS_FAMILY)
-    if (state == CloseState::Start) 
-        m_server->closeDatabase(this);
-    else
-        m_server->didCloseDatabase(this);
-#else
-    UNUSED_PARAM(state);
-#endif
-}
-
 } // namespace IDBServer
 } // namespace WebCore
 
index bce6745..e3a7b1b 100644 (file)
@@ -128,8 +128,6 @@ public:
     void setQuota(uint64_t);
 
 private:
-    enum class CloseState { Start, Done };
-
     void handleDatabaseOperations();
     void handleCurrentOperation();
     void performCurrentOpenOperation();
@@ -251,8 +249,6 @@ private:
     void maybeFinishHardClose();
     bool isDoneWithHardClose();
 
-    void notifyServerAboutClose(CloseState);
-
     void requestSpace(uint64_t taskSize, const char* errorMessage, CompletionHandler<void(Optional<IDBError>&&)>&&);
     void waitForRequestSpaceCompletion(CompletionHandler<void(Optional<IDBError>&&)>&&);
     void updateSpaceUsedIfNeeded(uint64_t callbackIdentifier);
index da9752a..83feb8d 100644 (file)
@@ -1,3 +1,20 @@
+2019-04-09  Sihui Liu  <sihui_liu@apple.com>
+
+        Remove unnecessary network process assertion for IDB close
+        https://bugs.webkit.org/show_bug.cgi?id=196693
+
+        Reviewed by Geoffrey Garen.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::createIDBServer):
+        (WebKit::NetworkProcess::notifyHoldingLockedFiles): Deleted.
+        * NetworkProcess/NetworkProcess.h:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::didClose):
+        (WebKit::NetworkProcessProxy::setIsIDBDatabaseHoldingLockedFiles): Deleted.
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+
 2019-04-09  Chris Dumez  <cdumez@apple.com>
 
         Loads using loadHTMLString() cause flashing when process-swapping
index 1cb4b67..fca0972 100644 (file)
@@ -2122,10 +2122,6 @@ Ref<IDBServer::IDBServer> NetworkProcess::createIDBServer(PAL::SessionID session
         if (!weakThis)
             return nullptr;
         return &this->storageQuotaManager(sessionID, origin);
-    }, [this, weakThis = makeWeakPtr(this)](bool isHoldingLockedFiles) {
-        if (!weakThis)
-            return;
-        this->notifyHoldingLockedFiles(isHoldingLockedFiles);
     });
     server->setPerOriginQuota(m_idbPerOriginQuota);
     return server;
@@ -2503,9 +2499,4 @@ void NetworkProcess::clearAdClickAttribution(PAL::SessionID sessionID, Completio
     completionHandler();
 }
 
-void NetworkProcess::notifyHoldingLockedFiles(bool isIDBDatabaseHoldingLockedFiles)
-{
-    parentProcessConnection()->send(Messages::NetworkProcessProxy::SetIsIDBDatabaseHoldingLockedFiles(isIDBDatabaseHoldingLockedFiles), 0);
-}
-
 } // namespace WebKit
index 6347c18..7ec329e 100644 (file)
@@ -407,7 +407,6 @@ private:
     void syncAllCookies();
     void didSyncAllCookies();
 
-    void notifyHoldingLockedFiles(bool isIDBDatabaseHoldingLockedFiles);
 #if USE(SOUP)
     void setIgnoreTLSErrors(bool);
     void userPreferredLanguagesChanged(const Vector<String>&);
index 2d8dbc5..c6b020c 100644 (file)
@@ -279,7 +279,6 @@ void NetworkProcessProxy::didClose(IPC::Connection&)
 #endif
 
     m_tokenForHoldingLockedFiles = nullptr;
-    m_tokenForIDBDatabaseHoldingLockedFiles = nullptr;
     
     m_syncAllCookiesToken = nullptr;
     m_syncAllCookiesCounter = 0;
@@ -1058,19 +1057,6 @@ void NetworkProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles)
     }
 }
 
-void NetworkProcessProxy::setIsIDBDatabaseHoldingLockedFiles(bool isIDBDatabaseHoldingLockedFiles)
-{
-    if (!isIDBDatabaseHoldingLockedFiles) {
-        RELEASE_LOG(ProcessSuspension, "UIProcess is releasing a background assertion because the Network process is no longer holding locked files for IDBDatabase");
-        m_tokenForIDBDatabaseHoldingLockedFiles = nullptr;
-        return;
-    }
-    if (!m_tokenForIDBDatabaseHoldingLockedFiles) {
-        RELEASE_LOG(ProcessSuspension, "UIProcess is taking a background assertion because the Network process is holding locked files for IDBDatabase");
-        m_tokenForIDBDatabaseHoldingLockedFiles = m_throttler.backgroundActivityToken();
-    }
-}
-
 void NetworkProcessProxy::syncAllCookies()
 {
     send(Messages::NetworkProcess::SyncAllCookies(), 0);
index 5ef5111..47c2299 100644 (file)
@@ -159,7 +159,6 @@ public:
     void synthesizeAppIsBackground(bool background);
 
     void setIsHoldingLockedFiles(bool);
-    void setIsIDBDatabaseHoldingLockedFiles(bool);
 
     void syncAllCookies();
     void didSyncAllCookies();
@@ -261,7 +260,6 @@ private:
 #endif
     ProcessThrottler m_throttler;
     ProcessThrottler::BackgroundActivityToken m_tokenForHoldingLockedFiles;
-    ProcessThrottler::BackgroundActivityToken m_tokenForIDBDatabaseHoldingLockedFiles;
     ProcessThrottler::BackgroundActivityToken m_syncAllCookiesToken;
     
     unsigned m_syncAllCookiesCounter { 0 };
index 16e5f30..be98e66 100644 (file)
@@ -33,7 +33,6 @@ messages -> NetworkProcessProxy LegacyReceiver {
 
     ProcessReadyToSuspend()
     SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
-    SetIsIDBDatabaseHoldingLockedFiles(bool isIDBDatabaseHoldingLockedFiles)
 
     # Diagnostic messages logging
     LogDiagnosticMessage(uint64_t pageID, String message, String description, enum:bool WebCore::ShouldSample shouldSample)