Changeset 248377 in webkit


Ignore:
Timestamp:
Aug 7, 2019 11:05:12 AM (5 years ago)
Author:
youenn@apple.com
Message:

Remove IDBDatabaseIdentifier::m_sessionID
https://bugs.webkit.org/show_bug.cgi?id=200489

Reviewed by Darin Adler.

IDBDatabaseIdentifier can be created without a valid session ID.
Its session ID is only used in NetworkProcess where it can be retrieved from the IDBServer.
In WebProcess, session ID is also known from the IDB connection.
Update SQLiteIDBBackingStore to store a session ID which is given from its IDBServer.
No observable change of behavior.

  • Modules/indexeddb/IDBDatabaseIdentifier.cpp:

(WebCore::IDBDatabaseIdentifier::IDBDatabaseIdentifier):
(WebCore::IDBDatabaseIdentifier::isolatedCopy const):

  • Modules/indexeddb/IDBDatabaseIdentifier.h:

(WebCore::IDBDatabaseIdentifier::hash const):
(WebCore::IDBDatabaseIdentifier::databaseName const):
(WebCore::IDBDatabaseIdentifier::encode const):
(WebCore::IDBDatabaseIdentifier::decode):
(WebCore::IDBDatabaseIdentifier::sessionID const): Deleted.

  • Modules/indexeddb/IDBFactory.cpp:

(WebCore::IDBFactory::openInternal):
(WebCore::IDBFactory::deleteDatabase):

  • Modules/indexeddb/server/IDBServer.cpp:

(WebCore::IDBServer::IDBServer::createBackingStore):

  • Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:

(WebCore::IDBServer::SQLiteIDBBackingStore::SQLiteIDBBackingStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::getAllObjectStoreRecords):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetIndexRecordForOneKey):

  • Modules/indexeddb/server/SQLiteIDBBackingStore.h:

(WebCore::IDBServer::SQLiteIDBBackingStore::sessionID const):

  • Modules/indexeddb/server/SQLiteIDBCursor.cpp:

(WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r248376 r248377  
     12019-08-07  Youenn Fablet  <youenn@apple.com>
     2
     3        Remove IDBDatabaseIdentifier::m_sessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=200489
     5
     6        Reviewed by Darin Adler.
     7
     8        IDBDatabaseIdentifier can be created without a valid session ID.
     9        Its session ID is only used in NetworkProcess where it can be retrieved from the IDBServer.
     10        In WebProcess, session ID is also known from the IDB connection.
     11        Update SQLiteIDBBackingStore to store a session ID which is given from its IDBServer.
     12        No observable change of behavior.
     13
     14        * Modules/indexeddb/IDBDatabaseIdentifier.cpp:
     15        (WebCore::IDBDatabaseIdentifier::IDBDatabaseIdentifier):
     16        (WebCore::IDBDatabaseIdentifier::isolatedCopy const):
     17        * Modules/indexeddb/IDBDatabaseIdentifier.h:
     18        (WebCore::IDBDatabaseIdentifier::hash const):
     19        (WebCore::IDBDatabaseIdentifier::databaseName const):
     20        (WebCore::IDBDatabaseIdentifier::encode const):
     21        (WebCore::IDBDatabaseIdentifier::decode):
     22        (WebCore::IDBDatabaseIdentifier::sessionID const): Deleted.
     23        * Modules/indexeddb/IDBFactory.cpp:
     24        (WebCore::IDBFactory::openInternal):
     25        (WebCore::IDBFactory::deleteDatabase):
     26        * Modules/indexeddb/server/IDBServer.cpp:
     27        (WebCore::IDBServer::IDBServer::createBackingStore):
     28        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     29        (WebCore::IDBServer::SQLiteIDBBackingStore::SQLiteIDBBackingStore):
     30        (WebCore::IDBServer::SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord):
     31        (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
     32        (WebCore::IDBServer::SQLiteIDBBackingStore::getAllObjectStoreRecords):
     33        (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetIndexRecordForOneKey):
     34        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
     35        (WebCore::IDBServer::SQLiteIDBBackingStore::sessionID const):
     36        * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
     37        (WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):
     38
    1392019-08-07  Chris Dumez  <cdumez@apple.com>
    240
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp

    r243019 r248377  
    3636namespace WebCore {
    3737
    38 IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, const PAL::SessionID& sessionID, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin)
     38IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin)
    3939    : m_databaseName(databaseName)
    40     , m_sessionID(sessionID)
    4140    , m_origin { WTFMove(openingOrigin), WTFMove(mainFrameOrigin) }
    4241{
     
    5049
    5150    identifier.m_databaseName = m_databaseName.isolatedCopy();
    52     identifier.m_sessionID = m_sessionID.isolatedCopy();
    5351    identifier.m_origin = m_origin.isolatedCopy();
    5452
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h

    r243163 r248377  
    4646    }
    4747
    48     WEBCORE_EXPORT IDBDatabaseIdentifier(const String& databaseName, const PAL::SessionID&, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin);
     48    WEBCORE_EXPORT IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin);
    4949
    5050    IDBDatabaseIdentifier isolatedCopy() const;
     
    5858    {
    5959        unsigned nameHash = StringHash::hash(m_databaseName);
    60         unsigned sessionIDHash = WTF::SessionIDHash::hash(m_sessionID);
    6160        unsigned originHash = m_origin.hash();
    6261
    63         unsigned hashCodes[3] = { nameHash, sessionIDHash, originHash };
     62        unsigned hashCodes[2] = { nameHash, originHash };
    6463        return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
    6564    }
     
    8281
    8382    const String& databaseName() const { return m_databaseName; }
    84     const PAL::SessionID& sessionID() const { return m_sessionID; }
    8583    const ClientOrigin& origin() const { return m_origin; }
    8684
     
    9997private:
    10098    String m_databaseName;
    101     PAL::SessionID m_sessionID;
    10299    ClientOrigin m_origin;
    103100    SecurityOriginData m_mainFrameOrigin;
     
    119116void IDBDatabaseIdentifier::encode(Encoder& encoder) const
    120117{
    121     encoder << m_databaseName << m_sessionID << m_origin;
     118    encoder << m_databaseName << m_origin;
    122119}
    123120
     
    130127        return WTF::nullopt;
    131128
    132     Optional<PAL::SessionID> sessionID;
    133     decoder >> sessionID;
    134     if (!sessionID)
    135         return WTF::nullopt;
    136    
    137129    Optional<ClientOrigin> origin;
    138130    decoder >> origin;
     
    142134    IDBDatabaseIdentifier identifier;
    143135    identifier.m_databaseName = WTFMove(*databaseName); // FIXME: When decoding from IPC, databaseName can be null, and the non-empty constructor asserts that this is not the case.
    144     identifier.m_sessionID = WTFMove(*sessionID);
    145136    identifier.m_origin = WTFMove(*origin);
    146137    return identifier;
  • trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp

    r243348 r248377  
    9292
    9393    ASSERT(context.securityOrigin());
    94     IDBDatabaseIdentifier databaseIdentifier(name, context.sessionID(), SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
     94    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
    9595    if (!databaseIdentifier.isValid())
    9696        return Exception { TypeError, "IDBFactory.open() called with an invalid security origin"_s };
     
    112112
    113113    ASSERT(context.securityOrigin());
    114     IDBDatabaseIdentifier databaseIdentifier(name, context.sessionID(), SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
     114    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
    115115    if (!databaseIdentifier.isValid())
    116116        return Exception { TypeError, "IDBFactory.deleteDatabase() called with an invalid security origin"_s };
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

    r245871 r248377  
    136136        return MemoryIDBBackingStore::create(identifier);
    137137
    138     return std::make_unique<SQLiteIDBBackingStore>(identifier, m_databaseDirectoryPath, m_backingStoreTemporaryFileHandler, m_perOriginQuota);
     138    return std::make_unique<SQLiteIDBBackingStore>(m_sessionID, identifier, m_databaseDirectoryPath, m_backingStoreTemporaryFileHandler, m_perOriginQuota);
    139139}
    140140
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r246922 r248377  
    229229}
    230230
    231 SQLiteIDBBackingStore::SQLiteIDBBackingStore(const IDBDatabaseIdentifier& identifier, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler& fileHandler, uint64_t quota)
    232     : m_identifier(identifier)
     231SQLiteIDBBackingStore::SQLiteIDBBackingStore(PAL::SessionID sessionID, const IDBDatabaseIdentifier& identifier, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler& fileHandler, uint64_t quota)
     232    : m_sessionID(sessionID)
     233    , m_identifier(identifier)
    233234    , m_databaseRootDirectory(databaseRootDirectory)
    234235    , m_temporaryFileHandler(fileHandler)
     
    19061907}
    19071908
    1908 IDBError SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, PAL::SessionID& sessionID, Vector<String>& blobFilePaths)
     1909IDBError SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths)
    19091910{
    19101911    ASSERT(objectStoreRecord);
     
    19551956        blobFilePaths.append(FileSystem::pathByAppendingComponent(m_databaseDirectory, fileName));
    19561957    }
    1957     sessionID = m_identifier.sessionID();
    1958 
    19591958    return IDBError { };
    19601959}
     
    20832082    ASSERT(recordID);
    20842083    Vector<String> blobURLs, blobFilePaths;
    2085     PAL::SessionID sessionID;
    2086     auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths);
     2084    auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths);
    20872085    ASSERT(blobURLs.size() == blobFilePaths.size());
    20882086
     
    20922090    auto* objectStoreInfo = infoForObjectStore(objectStoreID);
    20932091    ASSERT(objectStoreInfo);
    2094     resultValue = { keyData, { valueResultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath()};
     2092    resultValue = { keyData, { valueResultBuffer, WTFMove(blobURLs), m_sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath()};
    20952093    return IDBError { };
    20962094}
     
    22052203            ASSERT(recordID);
    22062204            Vector<String> blobURLs, blobFilePaths;
    2207             PAL::SessionID sessionID;
    2208             auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths);
     2205            auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths);
    22092206            ASSERT(blobURLs.size() == blobFilePaths.size());
    22102207
     
    22122209                return error;
    22132210
    2214             result.addValue({ valueResultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) });
     2211            result.addValue({ valueResultBuffer, WTFMove(blobURLs), m_sessionID, WTFMove(blobFilePaths) });
    22152212        }
    22162213
     
    23672364    int64_t recordID = sql->getColumnInt64(2);
    23682365    Vector<String> blobURLs, blobFilePaths;
    2369     PAL::SessionID sessionID;
    2370     auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths);
     2366    auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths);
    23712367    ASSERT(blobURLs.size() == blobFilePaths.size());
    23722368
     
    23762372    auto* objectStoreInfo = infoForObjectStore(objectStoreID);
    23772373    ASSERT(objectStoreInfo);
    2378     getResult = { objectStoreKey, objectStoreKey, { ThreadSafeDataBuffer::create(WTFMove(valueVector)), WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath() };
     2374    getResult = { objectStoreKey, objectStoreKey, { ThreadSafeDataBuffer::create(WTFMove(valueVector)), WTFMove(blobURLs), m_sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath() };
    23792375    return IDBError { };
    23802376}
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h

    r244687 r248377  
    4949    WTF_MAKE_FAST_ALLOCATED;
    5050public:
    51     SQLiteIDBBackingStore(const IDBDatabaseIdentifier&, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler&, uint64_t quota);
     51    SQLiteIDBBackingStore(PAL::SessionID, const IDBDatabaseIdentifier&, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler&, uint64_t quota);
    5252   
    5353    ~SQLiteIDBBackingStore() final;
     
    9292    IDBBackingStoreTemporaryFileHandler& temporaryFileHandler() const { return m_temporaryFileHandler; }
    9393
    94     IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, PAL::SessionID&, Vector<String>& blobFilePaths);
     94    IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);
    9595
    9696    static String databaseNameFromEncodedFilename(const String&);
     
    102102
    103103    bool hasTransaction(const IDBResourceIdentifier&) const final;
     104
     105    PAL::SessionID sessionID() const { return m_sessionID; }
     106
    104107private:
    105108    String filenameForDatabaseName() const;
     
    192195    void initializeVM();
    193196
     197    PAL::SessionID m_sessionID;
    194198    IDBDatabaseIdentifier m_identifier;
    195199    std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp

    r244436 r248377  
    457457
    458458        Vector<String> blobURLs, blobFilePaths;
    459         PAL::SessionID sessionID;
    460         auto error = m_transaction->backingStore().getBlobRecordsForObjectStoreRecord(record.rowID, blobURLs, sessionID, blobFilePaths);
     459        auto error = m_transaction->backingStore().getBlobRecordsForObjectStoreRecord(record.rowID, blobURLs, blobFilePaths);
    461460        if (!error.isNull()) {
    462461            LOG_ERROR("Unable to fetch blob records from database while advancing cursor");
     
    466465
    467466        if (m_cursorType == IndexedDB::CursorType::KeyAndValue)
    468             record.record.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)), blobURLs, sessionID, blobFilePaths);
     467            record.record.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)), blobURLs, m_transaction->backingStore().sessionID(), blobFilePaths);
    469468    } else {
    470469        if (!deserializeIDBKeyData(keyData.data(), keyData.size(), record.record.primaryKey)) {
Note: See TracChangeset for help on using the changeset viewer.