Changeset 247159 in webkit


Ignore:
Timestamp:
Jul 5, 2019 9:24:26 AM (5 years ago)
Author:
youenn@apple.com
Message:

ASSERT that a sessionID is valid when encoding it
https://bugs.webkit.org/show_bug.cgi?id=199302

Reviewed by Darin Adler.

Source/WebCore:

For IDBValue, instead of encoding an invalid session ID, encode a boolean that tells there is no sessionID.
For IDBRequestData, keep track of whether there is an IDBDatabaseIdentifier
and encode/decode accordingly to not encode an invalid sessionID.
No observable change of behavior.

  • Modules/indexeddb/IDBValue.h:

(WebCore::IDBValue::sessionID const):
(WebCore::IDBValue::encode const):
(WebCore::IDBValue::decode):

  • Modules/indexeddb/shared/IDBRequestData.cpp:

(WebCore::IDBRequestData::isolatedCopy):

  • Modules/indexeddb/shared/IDBRequestData.h:

(WebCore::IDBRequestData::databaseIdentifier const):
(WebCore::IDBRequestData::decode):

Source/WebCore/PAL:

ASSERT that a sessionID is valid at encoding/decoding time.

  • pal/SessionID.h:

(PAL::SessionID::encode const):
(PAL::SessionID::decode):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247153 r247159  
     12019-07-05  Youenn Fablet  <youenn@apple.com>
     2
     3        ASSERT that a sessionID is valid when encoding it
     4        https://bugs.webkit.org/show_bug.cgi?id=199302
     5
     6        Reviewed by Darin Adler.
     7
     8        For IDBValue, instead of encoding an invalid session ID, encode a boolean that tells there is no sessionID.
     9        For IDBRequestData, keep track of whether there is an IDBDatabaseIdentifier
     10        and encode/decode accordingly to not encode an invalid sessionID.
     11        No observable change of behavior.
     12
     13        * Modules/indexeddb/IDBValue.h:
     14        (WebCore::IDBValue::sessionID const):
     15        (WebCore::IDBValue::encode const):
     16        (WebCore::IDBValue::decode):
     17        * Modules/indexeddb/shared/IDBRequestData.cpp:
     18        (WebCore::IDBRequestData::isolatedCopy):
     19        * Modules/indexeddb/shared/IDBRequestData.h:
     20        (WebCore::IDBRequestData::databaseIdentifier const):
     21        (WebCore::IDBRequestData::decode):
     22
    1232019-07-05  Zalan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/Modules/indexeddb/IDBValue.h

    r243163 r247159  
    5151    const ThreadSafeDataBuffer& data() const { return m_data; }
    5252    const Vector<String>& blobURLs() const { return m_blobURLs; }
    53     const PAL::SessionID& sessionID() const { return m_sessionID; }
     53    const PAL::SessionID& sessionID() const;
    5454    const Vector<String>& blobFilePaths() const { return m_blobFilePaths; }
    5555
     
    6060    ThreadSafeDataBuffer m_data;
    6161    Vector<String> m_blobURLs;
    62     PAL::SessionID m_sessionID;
     62    mutable Optional<PAL::SessionID> m_sessionID;
    6363    Vector<String> m_blobFilePaths;
    6464};
    6565
     66inline const PAL::SessionID& IDBValue::sessionID() const
     67{
     68    // FIXME: We should assert m_sessionID is valid or remove m_sessionID.
     69    if (!m_sessionID)
     70        m_sessionID = PAL::SessionID { };
     71    return *m_sessionID;
     72}
    6673
    6774template<class Encoder>
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBRequestData.cpp

    r200495 r247159  
    9999    destination.m_requestType = source.m_requestType;
    100100
    101     destination.m_databaseIdentifier = source.m_databaseIdentifier.isolatedCopy();
     101    if (source.m_databaseIdentifier)
     102        destination.m_databaseIdentifier = source.m_databaseIdentifier->isolatedCopy();
    102103
    103104    if (source.m_requestIdentifier)
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBRequestData.h

    r243460 r247159  
    6666    IDBResourceIdentifier cursorIdentifier() const;
    6767
    68     const IDBDatabaseIdentifier& databaseIdentifier() const { return m_databaseIdentifier; }
     68    const IDBDatabaseIdentifier& databaseIdentifier() const;
    6969    uint64_t requestedVersion() const;
    7070
     
    9090    IndexedDB::IndexRecordType m_indexRecordType;
    9191
    92     IDBDatabaseIdentifier m_databaseIdentifier;
     92    mutable Optional<IDBDatabaseIdentifier> m_databaseIdentifier;
    9393    uint64_t m_requestedVersion { 0 };
    9494
    9595    IndexedDB::RequestType m_requestType { IndexedDB::RequestType::Other };
    9696};
     97
     98inline const IDBDatabaseIdentifier& IDBRequestData::databaseIdentifier() const
     99{
     100    ASSERT(m_databaseIdentifier);
     101    if (!m_databaseIdentifier)
     102        m_databaseIdentifier = IDBDatabaseIdentifier { };
     103    return *m_databaseIdentifier;
     104}
    97105
    98106template<class Encoder>
     
    129137        return false;
    130138
    131     Optional<IDBDatabaseIdentifier> databaseIdentifier;
     139    Optional<Optional<IDBDatabaseIdentifier>> databaseIdentifier;
    132140    decoder >> databaseIdentifier;
    133141    if (!databaseIdentifier)
  • trunk/Source/WebCore/PAL/ChangeLog

    r247117 r247159  
     12019-07-05  Youenn Fablet  <youenn@apple.com>
     2
     3        ASSERT that a sessionID is valid when encoding it
     4        https://bugs.webkit.org/show_bug.cgi?id=199302
     5
     6        Reviewed by Darin Adler.
     7
     8        ASSERT that a sessionID is valid at encoding/decoding time.
     9
     10        * pal/SessionID.h:
     11        (PAL::SessionID::encode const):
     12        (PAL::SessionID::decode):
     13
    1142019-07-03  Jonathan Bedard  <jbedard@apple.com>
    215
  • trunk/Source/WebCore/PAL/pal/SessionID.h

    r239427 r247159  
    8181void SessionID::encode(Encoder& encoder) const
    8282{
    83     // FIXME: Eliminate places that encode invalid SessionIDs, then ASSERT here that the sessionID is valid.
     83    ASSERT(isValid());
    8484    encoder << m_sessionID;
    8585}
     
    105105        return WTF::nullopt;
    106106
    107     // FIXME: Eliminate places that encode invalid SessionIDs, then fail to decode an invalid sessionID.
     107    // FIXME: We should fail to decode an invalid sessionID.
     108    ASSERT(SessionID { *sessionID }.isValid());
    108109    return SessionID { *sessionID };
    109110}
Note: See TracChangeset for help on using the changeset viewer.