Changeset 200372 in webkit
- Timestamp:
- May 3, 2016 8:30:52 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r200369 r200372 1 2016-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 1 30 2016-05-03 Joanmarie Diggs <jdiggs@igalia.com> 2 31 -
trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp
r199248 r200372 39 39 } 40 40 41 IDBGetResult::IDBGetResult(const IDBGetResult& that, IsolatedCopyTag) 42 { 43 isolatedCopy(that, *this); 44 } 45 41 46 IDBGetResult IDBGetResult::isolatedCopy() const 42 47 { 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 51 void 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; 50 58 } 51 59 -
trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h
r199524 r200372 98 98 } 99 99 100 enum IsolatedCopyTag { IsolatedCopy }; 101 IDBGetResult(const IDBGetResult&, IsolatedCopyTag); 102 100 103 IDBGetResult isolatedCopy() const; 101 104 … … 111 114 private: 112 115 void dataFromBuffer(SharedBuffer&); 116 117 static void isolatedCopy(const IDBGetResult& source, IDBGetResult& destination); 113 118 114 119 IDBValue m_value; -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp
r199120 r200372 99 99 } 100 100 101 IDBKeyData::IDBKeyData(const IDBKeyData& that, IsolatedCopyTag) 102 { 103 isolatedCopy(that, *this); 104 } 105 101 106 IDBKeyData IDBKeyData::isolatedCopy() const 102 107 { 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 111 void 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; 124 133 } 125 134 126 135 ASSERT_NOT_REACHED(); 127 return result;128 136 } 129 137 -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h
r197306 r200372 47 47 WEBCORE_EXPORT IDBKeyData(const IDBKey*); 48 48 49 enum IsolatedCopyTag { IsolatedCopy }; 50 IDBKeyData(const IDBKeyData&, IsolatedCopyTag); 51 49 52 static IDBKeyData minimum() 50 53 { … … 154 157 155 158 private: 159 static void isolatedCopy(const IDBKeyData& source, IDBKeyData& destination); 160 156 161 KeyType m_type; 157 162 Vector<IDBKeyData> m_arrayValue; -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp
r198762 r200372 71 71 } 72 72 73 IDBTransactionInfo::IDBTransactionInfo(const IDBTransactionInfo& that, IsolatedCopyTag) 74 { 75 isolatedCopy(that, *this); 76 } 77 73 78 IDBTransactionInfo IDBTransactionInfo::isolatedCopy() const 74 79 { 75 IDBTransactionInfo result(m_identifier); 76 result.m_mode = m_mode; 77 result.m_newVersion = m_newVersion; 80 return { *this, IsolatedCopy }; 81 } 78 82 79 result.m_objectStores.reserveCapacity(m_objectStores.size()); 80 for (auto& objectStore : m_objectStores) 81 result.m_objectStores.uncheckedAppend(objectStore.isolatedCopy()); 83 void 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; 82 88 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()); 85 92 86 return result; 93 if (source.m_originalDatabaseInfo) 94 destination.m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(*source.m_originalDatabaseInfo, IDBDatabaseInfo::IsolatedCopy); 87 95 } 88 96 -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h
r196779 r200372 51 51 IDBTransactionInfo(const IDBTransactionInfo&); 52 52 53 enum IsolatedCopyTag { IsolatedCopy }; 54 IDBTransactionInfo(const IDBTransactionInfo&, IsolatedCopyTag); 55 53 56 IDBTransactionInfo isolatedCopy() const; 54 57 … … 72 75 private: 73 76 IDBTransactionInfo(const IDBResourceIdentifier&); 77 78 static void isolatedCopy(const IDBTransactionInfo& source, IDBTransactionInfo& destination); 74 79 75 80 IDBResourceIdentifier m_identifier;
Note: See TracChangeset
for help on using the changeset viewer.