Title: [200372] trunk/Source/WebCore
Revision
200372
Author
beid...@apple.com
Date
2016-05-03 08:30:52 -0700 (Tue, 03 May 2016)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200371 => 200372)


--- trunk/Source/WebCore/ChangeLog	2016-05-03 15:24:36 UTC (rev 200371)
+++ trunk/Source/WebCore/ChangeLog	2016-05-03 15:30:52 UTC (rev 200372)
@@ -1,3 +1,32 @@
+2016-05-03  Brady Eidson  <beid...@apple.com>
+
+        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:
+
 2016-05-03  Joanmarie Diggs  <jdi...@igalia.com>
 
         [ATK] accessibility/content-editable-as-textarea.html fails

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp (200371 => 200372)


--- trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp	2016-05-03 15:24:36 UTC (rev 200371)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp	2016-05-03 15:30:52 UTC (rev 200372)
@@ -38,17 +38,25 @@
     m_value = ThreadSafeDataBuffer::adoptVector(data);
 }
 
+IDBGetResult::IDBGetResult(const IDBGetResult& that, IsolatedCopyTag)
+{
+    isolatedCopy(that, *this);
+}
+
 IDBGetResult IDBGetResult::isolatedCopy() const
 {
-    IDBGetResult result;
-    result.m_value = m_value.isolatedCopy();
-    result.m_keyData = m_keyData.isolatedCopy();
-    result.m_primaryKeyData = m_primaryKeyData.isolatedCopy();
-    result.m_keyPath = m_keyPath.isolatedCopy();
-    result.m_isDefined = m_isDefined;
-    return result;
+    return { *this, IsolatedCopy };
 }
 
+void IDBGetResult::isolatedCopy(const IDBGetResult& source, IDBGetResult& destination)
+{
+    destination.m_value = source.m_value.isolatedCopy();
+    destination.m_keyData = source.m_keyData.isolatedCopy();
+    destination.m_primaryKeyData = source.m_primaryKeyData.isolatedCopy();
+    destination.m_keyPath = source.m_keyPath.isolatedCopy();
+    destination.m_isDefined = source.m_isDefined;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h (200371 => 200372)


--- trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h	2016-05-03 15:24:36 UTC (rev 200371)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h	2016-05-03 15:30:52 UTC (rev 200372)
@@ -97,6 +97,9 @@
     {
     }
 
+    enum IsolatedCopyTag { IsolatedCopy };
+    IDBGetResult(const IDBGetResult&, IsolatedCopyTag);
+
     IDBGetResult isolatedCopy() const;
 
     const IDBValue& value() const { return m_value; }
@@ -111,6 +114,8 @@
 private:
     void dataFromBuffer(SharedBuffer&);
 
+    static void isolatedCopy(const IDBGetResult& source, IDBGetResult& destination);
+
     IDBValue m_value;
     IDBKeyData m_keyData;
     IDBKeyData m_primaryKeyData;

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (200371 => 200372)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp	2016-05-03 15:24:36 UTC (rev 200371)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp	2016-05-03 15:30:52 UTC (rev 200372)
@@ -98,33 +98,41 @@
     return nullptr;
 }
 
+IDBKeyData::IDBKeyData(const IDBKeyData& that, IsolatedCopyTag)
+{
+    isolatedCopy(that, *this);
+}
+
 IDBKeyData IDBKeyData::isolatedCopy() const
 {
-    IDBKeyData result;
-    result.m_type = m_type;
-    result.m_isNull = m_isNull;
+    return { *this, IsolatedCopy };
+}
 
-    switch (m_type) {
+void IDBKeyData::isolatedCopy(const IDBKeyData& source, IDBKeyData& destination)
+{
+    destination.m_type = source.m_type;
+    destination.m_isNull = source.m_isNull;
+
+    switch (source.m_type) {
     case KeyType::Invalid:
-        return result;
+        return;
     case KeyType::Array:
-        for (auto& key : m_arrayValue)
-            result.m_arrayValue.append(key.isolatedCopy());
-        return result;
+        for (auto& key : source.m_arrayValue)
+            destination.m_arrayValue.append(key.isolatedCopy());
+        return;
     case KeyType::String:
-        result.m_stringValue = m_stringValue.isolatedCopy();
-        return result;
+        destination.m_stringValue = source.m_stringValue.isolatedCopy();
+        return;
     case KeyType::Date:
     case KeyType::Number:
-        result.m_numberValue = m_numberValue;
-        return result;
+        destination.m_numberValue = source.m_numberValue;
+        return;
     case KeyType::Max:
     case KeyType::Min:
-        return result;
+        return;
     }
 
     ASSERT_NOT_REACHED();
-    return result;
 }
 
 void IDBKeyData::encode(KeyedEncoder& encoder) const

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h (200371 => 200372)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h	2016-05-03 15:24:36 UTC (rev 200371)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h	2016-05-03 15:30:52 UTC (rev 200372)
@@ -46,6 +46,9 @@
 
     WEBCORE_EXPORT IDBKeyData(const IDBKey*);
 
+    enum IsolatedCopyTag { IsolatedCopy };
+    IDBKeyData(const IDBKeyData&, IsolatedCopyTag);
+
     static IDBKeyData minimum()
     {
         IDBKeyData result;
@@ -153,6 +156,8 @@
     }
 
 private:
+    static void isolatedCopy(const IDBKeyData& source, IDBKeyData& destination);
+
     KeyType m_type;
     Vector<IDBKeyData> m_arrayValue;
     String m_stringValue;

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp (200371 => 200372)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp	2016-05-03 15:24:36 UTC (rev 200371)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp	2016-05-03 15:30:52 UTC (rev 200372)
@@ -70,20 +70,28 @@
         m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(*info.m_originalDatabaseInfo);
 }
 
+IDBTransactionInfo::IDBTransactionInfo(const IDBTransactionInfo& that, IsolatedCopyTag)
+{
+    isolatedCopy(that, *this);
+}
+
 IDBTransactionInfo IDBTransactionInfo::isolatedCopy() const
 {
-    IDBTransactionInfo result(m_identifier);
-    result.m_mode = m_mode;
-    result.m_newVersion = m_newVersion;
+    return { *this, IsolatedCopy };
+}
 
-    result.m_objectStores.reserveCapacity(m_objectStores.size());
-    for (auto& objectStore : m_objectStores)
-        result.m_objectStores.uncheckedAppend(objectStore.isolatedCopy());
+void IDBTransactionInfo::isolatedCopy(const IDBTransactionInfo& source, IDBTransactionInfo& destination)
+{
+    destination.m_identifier = source.m_identifier.isolatedCopy();
+    destination.m_mode = source.m_mode;
+    destination.m_newVersion = source.m_newVersion;
 
-    if (m_originalDatabaseInfo)
-        result.m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(*m_originalDatabaseInfo, IDBDatabaseInfo::IsolatedCopy);
+    destination.m_objectStores.reserveCapacity(source.m_objectStores.size());
+    for (auto& objectStore : source.m_objectStores)
+        destination.m_objectStores.uncheckedAppend(objectStore.isolatedCopy());
 
-    return result;
+    if (source.m_originalDatabaseInfo)
+        destination.m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(*source.m_originalDatabaseInfo, IDBDatabaseInfo::IsolatedCopy);
 }
 
 #ifndef NDEBUG

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h (200371 => 200372)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h	2016-05-03 15:24:36 UTC (rev 200371)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h	2016-05-03 15:30:52 UTC (rev 200372)
@@ -50,6 +50,9 @@
 
     IDBTransactionInfo(const IDBTransactionInfo&);
 
+    enum IsolatedCopyTag { IsolatedCopy };
+    IDBTransactionInfo(const IDBTransactionInfo&, IsolatedCopyTag);
+
     IDBTransactionInfo isolatedCopy() const;
 
     const IDBResourceIdentifier& identifier() const { return m_identifier; }
@@ -72,6 +75,8 @@
 private:
     IDBTransactionInfo(const IDBResourceIdentifier&);
 
+    static void isolatedCopy(const IDBTransactionInfo& source, IDBTransactionInfo& destination);
+
     IDBResourceIdentifier m_identifier;
 
     IndexedDB::TransactionMode m_mode { IndexedDB::TransactionMode::ReadOnly };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to