Changeset 259215 in webkit


Ignore:
Timestamp:
Mar 30, 2020 12:23:05 PM (4 years ago)
Author:
sihui_liu@apple.com
Message:

IndexedDB: destroy UniqueIDBDatabase when it's not used
https://bugs.webkit.org/show_bug.cgi?id=209532
<rdar://problem/60906908>

Reviewed by Geoffrey Garen.

When all connections of a UniqueIDBDatabase object are closed and there are no pending reuqests, the
object may not be used any more. We should delete it for better memory use.

  • Modules/indexeddb/server/IDBServer.cpp:

(WebCore::IDBServer::IDBServer::deleteDatabase):
(WebCore::IDBServer::IDBServer::establishTransaction):
(WebCore::IDBServer::IDBServer::databaseConnectionClosed):
(WebCore::IDBServer::IDBServer::openDBRequestCancelled):

  • Modules/indexeddb/server/UniqueIDBDatabase.cpp:

(WebCore::IDBServer::UniqueIDBDatabase::tryClose):

  • Modules/indexeddb/server/UniqueIDBDatabase.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259210 r259215  
     12020-03-30  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: destroy UniqueIDBDatabase when it's not used
     4        https://bugs.webkit.org/show_bug.cgi?id=209532
     5        <rdar://problem/60906908>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        When all connections of a UniqueIDBDatabase object are closed and there are no pending reuqests, the
     10        object may not be used any more. We should delete it for better memory use.
     11
     12        * Modules/indexeddb/server/IDBServer.cpp:
     13        (WebCore::IDBServer::IDBServer::deleteDatabase):
     14        (WebCore::IDBServer::IDBServer::establishTransaction):
     15        (WebCore::IDBServer::IDBServer::databaseConnectionClosed):
     16        (WebCore::IDBServer::IDBServer::openDBRequestCancelled):
     17        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     18        (WebCore::IDBServer::UniqueIDBDatabase::tryClose):
     19        * Modules/indexeddb/server/UniqueIDBDatabase.h:
     20
    1212020-03-30  Jack Lee  <shihchieh_lee@apple.com>
    222
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

    r259156 r259215  
    170170
    171171    database->handleDelete(*connection, requestData);
     172    if (database->tryClose())
     173        m_uniqueIDBDatabaseMap.remove(database->identifier());
    172174}
    173175
     
    393395    ASSERT(m_lock.isHeld());
    394396
    395     auto databaseConnection = m_databaseConnections.get(databaseConnectionIdentifier);
     397    auto* databaseConnection = m_databaseConnections.get(databaseConnectionIdentifier);
    396398    if (!databaseConnection)
    397399        return;
    398400
     401    auto* database = databaseConnection->database();
    399402    databaseConnection->establishTransaction(info);
     403    if (database->tryClose())
     404        m_uniqueIDBDatabaseMap.remove(database->identifier());
    400405}
    401406
     
    448453    ASSERT(m_lock.isHeld());
    449454
    450     auto databaseConnection = m_databaseConnections.get(databaseConnectionIdentifier);
     455    auto* databaseConnection = m_databaseConnections.get(databaseConnectionIdentifier);
    451456    if (!databaseConnection)
    452457        return;
    453458
     459    auto* database = databaseConnection->database();
    454460    databaseConnection->connectionClosedFromClient();
     461    if (database->tryClose())
     462        m_uniqueIDBDatabaseMap.remove(database->identifier());
    455463}
    456464
     
    493501
    494502    uniqueIDBDatabase->openDBRequestCancelled(requestData.requestIdentifier());
     503    if (uniqueIDBDatabase->tryClose())
     504        m_uniqueIDBDatabaseMap.remove(uniqueIDBDatabase->identifier());
    495505}
    496506
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r259156 r259215  
    11911191}
    11921192
     1193bool UniqueIDBDatabase::tryClose()
     1194{
     1195    if (m_backingStore && m_backingStore->isEphemeral())
     1196        return false;
     1197
     1198    if (hasAnyOpenConnections() || m_versionChangeDatabaseConnection)
     1199        return false;
     1200
     1201    close();
     1202    return true;
     1203}
     1204
    11931205RefPtr<ServerOpenDBRequest> UniqueIDBDatabase::takeNextRunnableRequest(RequestType requestType)
    11941206{
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h

    r259156 r259215  
    111111
    112112    void abortActiveTransactions();
     113    bool tryClose();
    113114
    114115private:
Note: See TracChangeset for help on using the changeset viewer.