Title: [277106] trunk/Source/WebKit
Revision
277106
Author
[email protected]
Date
2021-05-06 12:09:18 -0700 (Thu, 06 May 2021)

Log Message

Drop some unnecessary code in LocalStorageDatabase
https://bugs.webkit.org/show_bug.cgi?id=225435

Reviewed by Chris Dumez.

No behavior change.

* NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::create):
(WebKit::LocalStorageDatabase::LocalStorageDatabase): Remove two paremeters that are no longer needed after
dropping code.
(WebKit::LocalStorageDatabase::openDatabase):
(WebKit::LocalStorageDatabase::migrateItemTableIfNeeded): SQLiteTransaction() by default sets readOnly to false,
and it will be rolled back for failure in ~SQLiteTransaction.
(WebKit::LocalStorageDatabase::close):
(WebKit::LocalStorageDatabase::tryToOpenDatabase): Deleted. Merged to openDatabase.
* NetworkProcess/WebStorage/LocalStorageDatabase.h:
* NetworkProcess/WebStorage/StorageArea.cpp:
(WebKit::StorageArea::ensureDatabase const):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (277105 => 277106)


--- trunk/Source/WebKit/ChangeLog	2021-05-06 18:58:21 UTC (rev 277105)
+++ trunk/Source/WebKit/ChangeLog	2021-05-06 19:09:18 UTC (rev 277106)
@@ -1,3 +1,25 @@
+2021-05-06  Sihui Liu  <[email protected]>
+
+        Drop some unnecessary code in LocalStorageDatabase
+        https://bugs.webkit.org/show_bug.cgi?id=225435
+
+        Reviewed by Chris Dumez.
+
+        No behavior change.
+
+        * NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
+        (WebKit::LocalStorageDatabase::create): 
+        (WebKit::LocalStorageDatabase::LocalStorageDatabase): Remove two paremeters that are no longer needed after 
+        dropping code.
+        (WebKit::LocalStorageDatabase::openDatabase):
+        (WebKit::LocalStorageDatabase::migrateItemTableIfNeeded): SQLiteTransaction() by default sets readOnly to false,
+        and it will be rolled back for failure in ~SQLiteTransaction.
+        (WebKit::LocalStorageDatabase::close):
+        (WebKit::LocalStorageDatabase::tryToOpenDatabase): Deleted. Merged to openDatabase.
+        * NetworkProcess/WebStorage/LocalStorageDatabase.h:
+        * NetworkProcess/WebStorage/StorageArea.cpp:
+        (WebKit::StorageArea::ensureDatabase const):
+
 2021-05-06  Per Arne Vollan  <[email protected]>
 
         Add sandbox extension flag to specify that path contains no symlinks

Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp (277105 => 277106)


--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp	2021-05-06 18:58:21 UTC (rev 277105)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp	2021-05-06 19:09:18 UTC (rev 277106)
@@ -26,21 +26,14 @@
 #include "config.h"
 #include "LocalStorageDatabase.h"
 
-#include "LocalStorageDatabaseTracker.h"
 #include <WebCore/SQLiteFileSystem.h>
 #include <WebCore/SQLiteStatement.h>
 #include <WebCore/SQLiteStatementAutoResetScope.h>
 #include <WebCore/SQLiteTransaction.h>
-#include <WebCore/SecurityOriginData.h>
 #include <WebCore/StorageMap.h>
-#include <WebCore/SuddenTermination.h>
 #include <wtf/FileSystem.h>
 #include <wtf/HashMap.h>
 #include <wtf/RefPtr.h>
-#include <wtf/RunLoop.h>
-#include <wtf/WorkQueue.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 using namespace WebCore;
@@ -47,16 +40,13 @@
 
 static const char getItemsQueryString[] = "SELECT key, value FROM ItemTable";
 
-Ref<LocalStorageDatabase> LocalStorageDatabase::create(Ref<WorkQueue>&& queue, Ref<LocalStorageDatabaseTracker>&& tracker, const SecurityOriginData& securityOrigin, unsigned quotaInBytes)
+Ref<LocalStorageDatabase> LocalStorageDatabase::create(String&& databasePath, unsigned quotaInBytes)
 {
-    return adoptRef(*new LocalStorageDatabase(WTFMove(queue), WTFMove(tracker), securityOrigin, quotaInBytes));
+    return adoptRef(*new LocalStorageDatabase(WTFMove(databasePath), quotaInBytes));
 }
 
-LocalStorageDatabase::LocalStorageDatabase(Ref<WorkQueue>&& queue, Ref<LocalStorageDatabaseTracker>&& tracker, const SecurityOriginData& securityOrigin, unsigned quotaInBytes)
-    : m_queue(WTFMove(queue))
-    , m_tracker(WTFMove(tracker))
-    , m_securityOrigin(securityOrigin)
-    , m_databasePath(m_tracker->databasePath(m_securityOrigin))
+LocalStorageDatabase::LocalStorageDatabase(String&& databasePath, unsigned quotaInBytes)
+    : m_databasePath(WTFMove(databasePath))
     , m_quotaInBytes(quotaInBytes)
 {
     ASSERT(!RunLoop::isMain());
@@ -68,24 +58,9 @@
     ASSERT(m_isClosed);
 }
 
-void LocalStorageDatabase::openDatabase(ShouldCreateDatabase shouldCreateDatabase)
+bool LocalStorageDatabase::openDatabase(ShouldCreateDatabase shouldCreateDatabase)
 {
     ASSERT(!RunLoop::isMain());
-    ASSERT(!m_database.isOpen());
-    ASSERT(!m_failedToOpenDatabase);
-
-    if (!tryToOpenDatabase(shouldCreateDatabase)) {
-        m_failedToOpenDatabase = true;
-        return;
-    }
-
-    if (m_database.isOpen())
-        m_tracker->didOpenDatabaseWithOrigin(m_securityOrigin);
-}
-
-bool LocalStorageDatabase::tryToOpenDatabase(ShouldCreateDatabase shouldCreateDatabase)
-{
-    ASSERT(!RunLoop::isMain());
     if (!FileSystem::fileExists(m_databasePath) && shouldCreateDatabase == ShouldCreateDatabase::No)
         return true;
 
@@ -140,7 +115,7 @@
         0,
     };
 
-    SQLiteTransaction transaction(m_database, false);
+    SQLiteTransaction transaction(m_database);
     transaction.begin();
 
     for (size_t i = 0; commands[i]; ++i) {
@@ -148,7 +123,6 @@
             continue;
 
         LOG_ERROR("Failed to migrate table ItemTable for local storage when executing: %s", commands[i]);
-        transaction.rollback();
 
         return false;
     }
@@ -319,7 +293,7 @@
         m_database.close();
 
     if (isEmpty)
-        m_tracker->deleteDatabaseWithOrigin(m_securityOrigin);
+        SQLiteFileSystem::deleteDatabaseFile(m_databasePath);
 }
 
 bool LocalStorageDatabase::databaseIsEmpty() const

Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h (277105 => 277106)


--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h	2021-05-06 18:58:21 UTC (rev 277105)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h	2021-05-06 19:09:18 UTC (rev 277106)
@@ -26,12 +26,10 @@
 #pragma once
 
 #include <WebCore/SQLiteDatabase.h>
-#include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 class SQLiteStatementAutoResetScope;
-class SuddenTerminationDisabler;
 
 struct SecurityOriginData;
 }
@@ -38,11 +36,9 @@
 
 namespace WebKit {
 
-class LocalStorageDatabaseTracker;
-
 class LocalStorageDatabase : public RefCounted<LocalStorageDatabase> {
 public:
-    static Ref<LocalStorageDatabase> create(Ref<WorkQueue>&&, Ref<LocalStorageDatabaseTracker>&&, const WebCore::SecurityOriginData&, unsigned quotaInBytes);
+    static Ref<LocalStorageDatabase> create(String&& databasePath, unsigned quotaInBytes);
     ~LocalStorageDatabase();
 
     HashMap<String, String> items() const;
@@ -58,11 +54,10 @@
     void handleLowMemoryWarning();
 
 private:
-    LocalStorageDatabase(Ref<WorkQueue>&&, Ref<LocalStorageDatabaseTracker>&&, const WebCore::SecurityOriginData&, unsigned quotaInBytes);
+    LocalStorageDatabase(String&& databasePath, unsigned quotaInBytes);
 
     enum class ShouldCreateDatabase : bool { No, Yes };
-    bool tryToOpenDatabase(ShouldCreateDatabase);
-    void openDatabase(ShouldCreateDatabase);
+    bool openDatabase(ShouldCreateDatabase);
 
     bool migrateItemTableIfNeeded();
     bool databaseIsEmpty() const;
@@ -69,18 +64,12 @@
 
     WebCore::SQLiteStatementAutoResetScope scopedStatement(std::unique_ptr<WebCore::SQLiteStatement>&, const String& query) const;
 
-    Ref<WorkQueue> m_queue;
-    Ref<LocalStorageDatabaseTracker> m_tracker;
-    WebCore::SecurityOriginData m_securityOrigin;
-
     String m_databasePath;
     mutable WebCore::SQLiteDatabase m_database;
     const unsigned m_quotaInBytes { 0 };
-    bool m_failedToOpenDatabase { false };
     bool m_isClosed { false };
     Optional<unsigned> m_databaseSize;
 
-    std::unique_ptr<WebCore::SuddenTerminationDisabler> m_disableSuddenTerminationWhileWritingToLocalStorage;
     mutable std::unique_ptr<WebCore::SQLiteStatement> m_clearStatement;
     mutable std::unique_ptr<WebCore::SQLiteStatement> m_insertStatement;
     mutable std::unique_ptr<WebCore::SQLiteStatement> m_getItemStatement;

Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp (277105 => 277106)


--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp	2021-05-06 18:58:21 UTC (rev 277105)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp	2021-05-06 19:09:18 UTC (rev 277106)
@@ -178,7 +178,8 @@
     ASSERT(m_localStorageNamespace->storageManager()->localStorageDatabaseTracker());
     // We open the database here even if we've already imported our items to ensure that the database is open if we need to write to it.
     if (!m_localStorageDatabase) {
-        m_localStorageDatabase = LocalStorageDatabase::create(m_queue.copyRef(), *m_localStorageNamespace->storageManager()->localStorageDatabaseTracker(), m_securityOrigin, m_quotaInBytes);
+        auto* localStorageDatabaseTracker = m_localStorageNamespace->storageManager()->localStorageDatabaseTracker();
+        m_localStorageDatabase = LocalStorageDatabase::create(localStorageDatabaseTracker->databasePath(m_securityOrigin), m_quotaInBytes);
         m_localStorageDatabase->openIfExisting();
     }
     return *m_localStorageDatabase;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to