Changeset 200372 in webkit


Ignore:
Timestamp:
May 3, 2016 8:30:52 AM (8 years ago)
Author:
beidson@apple.com
Message:

Add/refactor isolatedCopy methods for 3 IDB classes.
https://bugs.webkit.org/show_bug.cgi?id=157289

Reviewed by Alex Christensen.

No new tests (Refactor, no behavior change).

In an upcoming, much larger patch, I'll need the ability to directly construct these three objects
as isolated copies.

This is a nice standalone refactor that enables that ability.

  • Modules/indexeddb/IDBGetResult.cpp:

(WebCore::IDBGetResult::IDBGetResult):
(WebCore::IDBGetResult::isolatedCopy):

  • Modules/indexeddb/IDBGetResult.h:
  • Modules/indexeddb/IDBKeyData.cpp:

(WebCore::IDBKeyData::IDBKeyData):
(WebCore::IDBKeyData::isolatedCopy):

  • Modules/indexeddb/IDBKeyData.h:
  • Modules/indexeddb/shared/IDBTransactionInfo.cpp:

(WebCore::IDBTransactionInfo::IDBTransactionInfo):
(WebCore::IDBTransactionInfo::isolatedCopy):

  • Modules/indexeddb/shared/IDBTransactionInfo.h:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r200369 r200372  
     12016-05-03  Brady Eidson  <beidson@apple.com>
     2
     3        Add/refactor isolatedCopy methods for 3 IDB classes.
     4        https://bugs.webkit.org/show_bug.cgi?id=157289
     5
     6        Reviewed by Alex Christensen.
     7
     8        No new tests (Refactor, no behavior change).
     9
     10        In an upcoming, much larger patch, I'll need the ability to directly construct these three objects
     11        as isolated copies.
     12       
     13        This is a nice standalone refactor that enables that ability.
     14
     15        * Modules/indexeddb/IDBGetResult.cpp:
     16        (WebCore::IDBGetResult::IDBGetResult):
     17        (WebCore::IDBGetResult::isolatedCopy):
     18        * Modules/indexeddb/IDBGetResult.h:
     19       
     20        * Modules/indexeddb/IDBKeyData.cpp:
     21        (WebCore::IDBKeyData::IDBKeyData):
     22        (WebCore::IDBKeyData::isolatedCopy):
     23        * Modules/indexeddb/IDBKeyData.h:
     24
     25        * Modules/indexeddb/shared/IDBTransactionInfo.cpp:
     26        (WebCore::IDBTransactionInfo::IDBTransactionInfo):
     27        (WebCore::IDBTransactionInfo::isolatedCopy):
     28        * Modules/indexeddb/shared/IDBTransactionInfo.h:
     29
    1302016-05-03  Joanmarie Diggs  <jdiggs@igalia.com>
    231
  • trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp

    r199248 r200372  
    3939}
    4040
     41IDBGetResult::IDBGetResult(const IDBGetResult& that, IsolatedCopyTag)
     42{
     43    isolatedCopy(that, *this);
     44}
     45
    4146IDBGetResult IDBGetResult::isolatedCopy() const
    4247{
    43     IDBGetResult result;
    44     result.m_value = m_value.isolatedCopy();
    45     result.m_keyData = m_keyData.isolatedCopy();
    46     result.m_primaryKeyData = m_primaryKeyData.isolatedCopy();
    47     result.m_keyPath = m_keyPath.isolatedCopy();
    48     result.m_isDefined = m_isDefined;
    49     return result;
     48    return { *this, IsolatedCopy };
     49}
     50
     51void IDBGetResult::isolatedCopy(const IDBGetResult& source, IDBGetResult& destination)
     52{
     53    destination.m_value = source.m_value.isolatedCopy();
     54    destination.m_keyData = source.m_keyData.isolatedCopy();
     55    destination.m_primaryKeyData = source.m_primaryKeyData.isolatedCopy();
     56    destination.m_keyPath = source.m_keyPath.isolatedCopy();
     57    destination.m_isDefined = source.m_isDefined;
    5058}
    5159
  • trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h

    r199524 r200372  
    9898    }
    9999
     100    enum IsolatedCopyTag { IsolatedCopy };
     101    IDBGetResult(const IDBGetResult&, IsolatedCopyTag);
     102
    100103    IDBGetResult isolatedCopy() const;
    101104
     
    111114private:
    112115    void dataFromBuffer(SharedBuffer&);
     116
     117    static void isolatedCopy(const IDBGetResult& source, IDBGetResult& destination);
    113118
    114119    IDBValue m_value;
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp

    r199120 r200372  
    9999}
    100100
     101IDBKeyData::IDBKeyData(const IDBKeyData& that, IsolatedCopyTag)
     102{
     103    isolatedCopy(that, *this);
     104}
     105
    101106IDBKeyData IDBKeyData::isolatedCopy() const
    102107{
    103     IDBKeyData result;
    104     result.m_type = m_type;
    105     result.m_isNull = m_isNull;
    106 
    107     switch (m_type) {
    108     case KeyType::Invalid:
    109         return result;
    110     case KeyType::Array:
    111         for (auto& key : m_arrayValue)
    112             result.m_arrayValue.append(key.isolatedCopy());
    113         return result;
    114     case KeyType::String:
    115         result.m_stringValue = m_stringValue.isolatedCopy();
    116         return result;
    117     case KeyType::Date:
    118     case KeyType::Number:
    119         result.m_numberValue = m_numberValue;
    120         return result;
    121     case KeyType::Max:
    122     case KeyType::Min:
    123         return result;
     108    return { *this, IsolatedCopy };
     109}
     110
     111void IDBKeyData::isolatedCopy(const IDBKeyData& source, IDBKeyData& destination)
     112{
     113    destination.m_type = source.m_type;
     114    destination.m_isNull = source.m_isNull;
     115
     116    switch (source.m_type) {
     117    case KeyType::Invalid:
     118        return;
     119    case KeyType::Array:
     120        for (auto& key : source.m_arrayValue)
     121            destination.m_arrayValue.append(key.isolatedCopy());
     122        return;
     123    case KeyType::String:
     124        destination.m_stringValue = source.m_stringValue.isolatedCopy();
     125        return;
     126    case KeyType::Date:
     127    case KeyType::Number:
     128        destination.m_numberValue = source.m_numberValue;
     129        return;
     130    case KeyType::Max:
     131    case KeyType::Min:
     132        return;
    124133    }
    125134
    126135    ASSERT_NOT_REACHED();
    127     return result;
    128136}
    129137
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h

    r197306 r200372  
    4747    WEBCORE_EXPORT IDBKeyData(const IDBKey*);
    4848
     49    enum IsolatedCopyTag { IsolatedCopy };
     50    IDBKeyData(const IDBKeyData&, IsolatedCopyTag);
     51
    4952    static IDBKeyData minimum()
    5053    {
     
    154157
    155158private:
     159    static void isolatedCopy(const IDBKeyData& source, IDBKeyData& destination);
     160
    156161    KeyType m_type;
    157162    Vector<IDBKeyData> m_arrayValue;
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp

    r198762 r200372  
    7171}
    7272
     73IDBTransactionInfo::IDBTransactionInfo(const IDBTransactionInfo& that, IsolatedCopyTag)
     74{
     75    isolatedCopy(that, *this);
     76}
     77
    7378IDBTransactionInfo IDBTransactionInfo::isolatedCopy() const
    7479{
    75     IDBTransactionInfo result(m_identifier);
    76     result.m_mode = m_mode;
    77     result.m_newVersion = m_newVersion;
     80    return { *this, IsolatedCopy };
     81}
    7882
    79     result.m_objectStores.reserveCapacity(m_objectStores.size());
    80     for (auto& objectStore : m_objectStores)
    81         result.m_objectStores.uncheckedAppend(objectStore.isolatedCopy());
     83void IDBTransactionInfo::isolatedCopy(const IDBTransactionInfo& source, IDBTransactionInfo& destination)
     84{
     85    destination.m_identifier = source.m_identifier.isolatedCopy();
     86    destination.m_mode = source.m_mode;
     87    destination.m_newVersion = source.m_newVersion;
    8288
    83     if (m_originalDatabaseInfo)
    84         result.m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(*m_originalDatabaseInfo, IDBDatabaseInfo::IsolatedCopy);
     89    destination.m_objectStores.reserveCapacity(source.m_objectStores.size());
     90    for (auto& objectStore : source.m_objectStores)
     91        destination.m_objectStores.uncheckedAppend(objectStore.isolatedCopy());
    8592
    86     return result;
     93    if (source.m_originalDatabaseInfo)
     94        destination.m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(*source.m_originalDatabaseInfo, IDBDatabaseInfo::IsolatedCopy);
    8795}
    8896
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h

    r196779 r200372  
    5151    IDBTransactionInfo(const IDBTransactionInfo&);
    5252
     53    enum IsolatedCopyTag { IsolatedCopy };
     54    IDBTransactionInfo(const IDBTransactionInfo&, IsolatedCopyTag);
     55
    5356    IDBTransactionInfo isolatedCopy() const;
    5457
     
    7275private:
    7376    IDBTransactionInfo(const IDBResourceIdentifier&);
     77
     78    static void isolatedCopy(const IDBTransactionInfo& source, IDBTransactionInfo& destination);
    7479
    7580    IDBResourceIdentifier m_identifier;
Note: See TracChangeset for help on using the changeset viewer.