Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (192782 => 192783)
--- trunk/Source/WebCore/CMakeLists.txt 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/CMakeLists.txt 2015-11-27 17:50:54 UTC (rev 192783)
@@ -853,6 +853,7 @@
Modules/indexeddb/IDBDatabaseMetadata.cpp
Modules/indexeddb/IDBEventDispatcher.cpp
Modules/indexeddb/IDBFactory.cpp
+ Modules/indexeddb/IDBGetResult.cpp
Modules/indexeddb/IDBIndex.cpp
Modules/indexeddb/IDBKey.cpp
Modules/indexeddb/IDBKeyData.cpp
Modified: trunk/Source/WebCore/ChangeLog (192782 => 192783)
--- trunk/Source/WebCore/ChangeLog 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/ChangeLog 2015-11-27 17:50:54 UTC (rev 192783)
@@ -1,3 +1,53 @@
+2015-11-27 Brady Eidson <[email protected]>
+
+ Modern IDB: Class-ify IDBGetResult making it impossible to get the data members wrong.
+ https://bugs.webkit.org/show_bug.cgi?id=151627
+
+ Reviewed by Alexey Proskuryakov.
+
+ No new tests (No change in behavior).
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ * Modules/indexeddb/IDBGetResult.cpp: Added.
+ (WebCore::IDBGetResult::dataFromBuffer):
+ (WebCore::IDBGetResult::isolatedCopy):
+ * Modules/indexeddb/IDBGetResult.h:
+ (WebCore::IDBGetResult::IDBGetResult):
+ (WebCore::IDBGetResult::valueBuffer):
+ (WebCore::IDBGetResult::keyData):
+ (WebCore::IDBGetResult::primaryKeyData):
+ (WebCore::IDBGetResult::keyPath):
+ (WebCore::IDBGetResult::setValueBuffer):
+ (WebCore::IDBGetResult::setKeyData):
+ (WebCore::IDBGetResult::setPrimaryKeyData):
+ (WebCore::IDBGetResult::setKeyPath):
+ (WebCore::IDBGetResult::dataFromBuffer): Deleted.
+ (WebCore::IDBGetResult::isolatedCopy): Deleted.
+
+ * Modules/indexeddb/client/IDBCursorImpl.cpp:
+ (WebCore::IDBClient::IDBCursor::setGetResult):
+ * Modules/indexeddb/client/IDBCursorImpl.h:
+
+ * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+ (WebCore::IDBClient::IDBTransaction::didGetRecordOnServer):
+
+ * Modules/indexeddb/legacy/IDBTransactionBackendOperations.cpp:
+ (WebCore::GetOperation::perform):
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryCursor.h:
+
+ * Modules/indexeddb/server/MemoryIndexCursor.cpp:
+ (WebCore::IDBServer::MemoryIndexCursor::currentData):
+
+ * Modules/indexeddb/server/MemoryObjectStoreCursor.cpp:
+ (WebCore::IDBServer::MemoryObjectStoreCursor::currentData):
+
+ * platform/CrossThreadCopier.h:
+
2015-11-27 Carlos Garcia Campos <[email protected]>
[GTK] Do not use the WebCore garbage collector timer
Added: trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp (0 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBGetResult.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+void IDBGetResult::dataFromBuffer(SharedBuffer& buffer)
+{
+ Vector<uint8_t> data(buffer.size());
+ memcpy(data.data(), buffer.data(), buffer.size());
+
+ m_valueBuffer = ThreadSafeDataBuffer::adoptVector(data);
+}
+
+IDBGetResult IDBGetResult::isolatedCopy() const
+{
+ IDBGetResult result;
+ result.m_valueBuffer = m_valueBuffer;
+ result.m_keyData = m_keyData.isolatedCopy();
+ result.m_primaryKeyData = m_primaryKeyData.isolatedCopy();
+ result.m_keyPath = m_keyPath.isolatedCopy();
+ return result;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -36,7 +36,8 @@
namespace WebCore {
-struct IDBGetResult {
+class IDBGetResult {
+public:
IDBGetResult()
{
}
@@ -48,50 +49,63 @@
}
IDBGetResult(const ThreadSafeDataBuffer& buffer)
- : valueBuffer(buffer)
+ : m_valueBuffer(buffer)
{
}
IDBGetResult(PassRefPtr<IDBKey> key)
- : keyData(key.get())
+ : m_keyData(key.get())
{
}
IDBGetResult(const IDBKeyData& keyData)
- : keyData(keyData)
+ : m_keyData(keyData)
{
}
IDBGetResult(PassRefPtr<SharedBuffer> buffer, PassRefPtr<IDBKey> key, const IDBKeyPath& path)
- : keyData(key.get())
- , keyPath(path)
+ : m_keyData(key.get())
+ , m_keyPath(path)
{
if (buffer)
dataFromBuffer(*buffer);
}
- void dataFromBuffer(SharedBuffer& buffer)
+ IDBGetResult(const IDBKeyData& keyData, const IDBKeyData& primaryKeyData)
+ : m_keyData(keyData)
+ , m_primaryKeyData(primaryKeyData)
{
- Vector<uint8_t> data(buffer.size());
- memcpy(data.data(), buffer.data(), buffer.size());
-
- valueBuffer = ThreadSafeDataBuffer::adoptVector(data);
}
- IDBGetResult isolatedCopy() const
+ IDBGetResult(const IDBKeyData& keyData, const IDBKeyData& primaryKeyData, const ThreadSafeDataBuffer& valueBuffer)
+ : m_valueBuffer(valueBuffer)
+ , m_keyData(keyData)
+ , m_primaryKeyData(primaryKeyData)
{
- IDBGetResult result;
- result.valueBuffer = valueBuffer;
- result.keyData = keyData.isolatedCopy();
- result.primaryKeyData = primaryKeyData.isolatedCopy();
- result.keyPath = keyPath.isolatedCopy();
- return result;
}
- ThreadSafeDataBuffer valueBuffer;
- IDBKeyData keyData;
- IDBKeyData primaryKeyData;
- IDBKeyPath keyPath;
+ IDBGetResult isolatedCopy() const;
+
+ const ThreadSafeDataBuffer& valueBuffer() const { return m_valueBuffer; }
+ const IDBKeyData& keyData() const { return m_keyData; }
+ const IDBKeyData& primaryKeyData() const { return m_primaryKeyData; }
+ const IDBKeyPath& keyPath() const { return m_keyPath; }
+
+ // FIXME: When removing LegacyIDB, remove these setters.
+ // https://bugs.webkit.org/show_bug.cgi?id=150854
+
+ void setValueBuffer(const ThreadSafeDataBuffer& valueBuffer) { m_valueBuffer = valueBuffer; }
+ void setKeyData(const IDBKeyData& keyData) { m_keyData = keyData; }
+ void setPrimaryKeyData(const IDBKeyData& keyData) { m_primaryKeyData = keyData; }
+ void setKeyPath(const IDBKeyPath& keyPath) { m_keyPath = keyPath; }
+
+private:
+ WEBCORE_EXPORT void dataFromBuffer(SharedBuffer&);
+
+ ThreadSafeDataBuffer m_valueBuffer;
+ IDBKeyData m_keyData;
+ IDBKeyData m_primaryKeyData;
+ IDBKeyPath m_keyPath;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -282,20 +282,20 @@
void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
{
- LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData.loggingString().utf8().data());
+ LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData().loggingString().utf8().data());
auto* context = request.scriptExecutionContext();
if (!context)
return;
- m_deprecatedCurrentKey = idbKeyDataToScriptValue(context, getResult.keyData);
- m_deprecatedCurrentPrimaryKey = idbKeyDataToScriptValue(context, getResult.primaryKeyData);
- m_currentPrimaryKeyData = getResult.primaryKeyData;
+ m_deprecatedCurrentKey = idbKeyDataToScriptValue(context, getResult.keyData());
+ m_deprecatedCurrentPrimaryKey = idbKeyDataToScriptValue(context, getResult.primaryKeyData());
+ m_currentPrimaryKeyData = getResult.primaryKeyData();
if (isKeyCursor())
m_deprecatedCurrentValue = { };
else
- m_deprecatedCurrentValue = deserializeIDBValueData(*context, getResult.valueBuffer);
+ m_deprecatedCurrentValue = deserializeIDBValueData(*context, getResult.valueBuffer());
m_gotValue = true;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -34,7 +34,7 @@
namespace WebCore {
-struct IDBGetResult;
+class IDBGetResult;
namespace IDBClient {
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -602,13 +602,13 @@
const IDBGetResult& result = resultData.getResult();
if (request.sourceIndexIdentifier() && request.requestedIndexRecordType() == IndexedDB::IndexRecordType::Key) {
- if (!result.keyData.isNull())
- request.setResult(&result.keyData);
+ if (!result.keyData().isNull())
+ request.setResult(&result.keyData());
else
request.setResultToUndefined();
} else {
- if (resultData.getResult().valueBuffer.data())
- request.setResultToStructuredClone(resultData.getResult().valueBuffer);
+ if (resultData.getResult().valueBuffer().data())
+ request.setResultToStructuredClone(resultData.getResult().valueBuffer());
else
request.setResultToUndefined();
}
Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/IDBTransactionBackendOperations.cpp (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/legacy/IDBTransactionBackendOperations.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/IDBTransactionBackendOperations.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -100,15 +100,15 @@
if (error)
m_callbacks->onError(error);
else {
- if (!result.valueBuffer.data()) {
- if (result.keyData.isNull())
+ if (!result.valueBuffer().data()) {
+ if (result.keyData().isNull())
m_callbacks->onSuccess();
else
- m_callbacks->onSuccess(result.keyData.maybeCreateIDBKey());
+ m_callbacks->onSuccess(result.keyData().maybeCreateIDBKey());
} else {
- auto valueBuffer = SharedBuffer::create(result.valueBuffer.data()->data(), result.valueBuffer.data()->size());
- if (!result.keyData.isNull())
- m_callbacks->onSuccess(valueBuffer, result.keyData.maybeCreateIDBKey(), result.keyPath);
+ auto valueBuffer = SharedBuffer::create(result.valueBuffer().data()->data(), result.valueBuffer().data()->size());
+ if (!result.keyData().isNull())
+ m_callbacks->onSuccess(valueBuffer, result.keyData().maybeCreateIDBKey(), result.keyPath());
else
m_callbacks->onSuccess(valueBuffer);
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -34,6 +34,7 @@
namespace WebCore {
class IDBCursorInfo;
+class IDBGetResult;
class IDBIndexInfo;
class IDBKeyData;
class IDBObjectStoreInfo;
@@ -41,7 +42,6 @@
class IDBTransactionInfo;
class ThreadSafeDataBuffer;
-struct IDBGetResult;
struct IDBKeyRangeData;
namespace IndexedDB {
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryCursor.h (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryCursor.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryCursor.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -32,11 +32,10 @@
namespace WebCore {
+class IDBGetResult;
class IDBKeyData;
class IDBResourceIdentifier;
-struct IDBGetResult;
-
namespace IDBServer {
class MemoryCursor {
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -65,12 +65,10 @@
void MemoryIndexCursor::currentData(IDBGetResult& getResult)
{
- getResult.keyData = m_currentKey;
- getResult.primaryKeyData = m_currentPrimaryKey;
if (m_info.cursorType() == IndexedDB::CursorType::KeyOnly)
- return;
-
- getResult.valueBuffer = m_index.objectStore().valueForKey(m_currentPrimaryKey);
+ getResult = { m_currentKey, m_currentPrimaryKey };
+ else
+ getResult = { m_currentKey, m_currentPrimaryKey, m_index.objectStore().valueForKey(m_currentPrimaryKey) };
}
void MemoryIndexCursor::iterate(const IDBKeyData& key, uint32_t count, IDBGetResult& getResult)
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp (192782 => 192783)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -174,9 +174,7 @@
}
m_currentPositionKey = **m_forwardIterator;
- data.keyData = **m_forwardIterator;
- data.primaryKeyData = **m_forwardIterator;
- data.valueBuffer = m_objectStore.valueForKeyRange(**m_forwardIterator);
+ data = { **m_forwardIterator, **m_forwardIterator, m_objectStore.valueForKeyRange(**m_forwardIterator) };
} else {
if (!m_reverseIterator || *m_reverseIterator == set->rend()) {
data = { };
@@ -184,9 +182,7 @@
}
m_currentPositionKey = **m_reverseIterator;
- data.keyData = **m_reverseIterator;
- data.primaryKeyData = **m_reverseIterator;
- data.valueBuffer = m_objectStore.valueForKeyRange(**m_reverseIterator);
+ data = { **m_reverseIterator, **m_reverseIterator, m_objectStore.valueForKeyRange(**m_reverseIterator) };
}
}
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (192782 => 192783)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-11-27 17:50:54 UTC (rev 192783)
@@ -1963,6 +1963,7 @@
512DD8FB0D91E6AF000F89EE /* ArchiveResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 512DD8F10D91E6AF000F89EE /* ArchiveResource.cpp */; };
512DD8FC0D91E6AF000F89EE /* ArchiveResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 512DD8F20D91E6AF000F89EE /* ArchiveResource.h */; settings = {ATTRIBUTES = (Private, ); }; };
512DD8FD0D91E6AF000F89EE /* ArchiveFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 512DD8F30D91E6AF000F89EE /* ArchiveFactory.h */; };
+ 512F1A781C07EB6600908239 /* IDBGetResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 512F1A771C07EA0D00908239 /* IDBGetResult.cpp */; };
51327D6011A33A2B004F9D65 /* SinkDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 51327D5E11A33A2B004F9D65 /* SinkDocument.h */; };
51327D6111A33A2B004F9D65 /* SinkDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51327D5F11A33A2B004F9D65 /* SinkDocument.cpp */; };
513F14530AB634C400094DDF /* IconLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 513F14510AB634C400094DDF /* IconLoader.cpp */; };
@@ -9409,6 +9410,7 @@
512DD8F20D91E6AF000F89EE /* ArchiveResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArchiveResource.h; sourceTree = "<group>"; };
512DD8F30D91E6AF000F89EE /* ArchiveFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArchiveFactory.h; sourceTree = "<group>"; };
512EA9BD18202857001D01E0 /* IDBOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBOperation.h; sourceTree = "<group>"; };
+ 512F1A771C07EA0D00908239 /* IDBGetResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBGetResult.cpp; sourceTree = "<group>"; };
51327D5E11A33A2B004F9D65 /* SinkDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SinkDocument.h; sourceTree = "<group>"; };
51327D5F11A33A2B004F9D65 /* SinkDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SinkDocument.cpp; sourceTree = "<group>"; };
513F14510AB634C400094DDF /* IconLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconLoader.cpp; sourceTree = "<group>"; };
@@ -19299,6 +19301,7 @@
51645B461B9F889B00F789CE /* IDBFactory.cpp */,
51645B471B9F889B00F789CE /* IDBFactory.h */,
51D7198A181106DF0016DC51 /* IDBFactory.idl */,
+ 512F1A771C07EA0D00908239 /* IDBGetResult.cpp */,
5123AF1C18918AE40031CDC9 /* IDBGetResult.h */,
51645B481B9F889B00F789CE /* IDBIndex.cpp */,
51645B491B9F889B00F789CE /* IDBIndex.h */,
@@ -30434,6 +30437,7 @@
417253AA1354BBBC00360F2A /* MediaControlElements.cpp in Sources */,
DEBCCDD516646EB200A452E1 /* MediaControlElementTypes.cpp in Sources */,
CD27F6E7145770D30078207D /* MediaController.cpp in Sources */,
+ 512F1A781C07EB6600908239 /* IDBGetResult.cpp in Sources */,
1F3C3BEA135CAF3C00B8C1AC /* MediaControls.cpp in Sources */,
4157AF8112F1FB0400A8C6F5 /* MediaControlsApple.cpp in Sources */,
CDAB6D2817C7DE6C00C60B34 /* MediaControlsHost.cpp in Sources */,
Modified: trunk/Source/WebCore/platform/CrossThreadCopier.h (192782 => 192783)
--- trunk/Source/WebCore/platform/CrossThreadCopier.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebCore/platform/CrossThreadCopier.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -167,7 +167,7 @@
static Type copy(const IDBDatabaseMetadata&);
};
- struct IDBGetResult;
+ class IDBGetResult;
template<> struct WEBCORE_EXPORT CrossThreadCopierBase<false, false, IDBGetResult> {
typedef IDBGetResult Type;
static Type copy(const IDBGetResult&);
Modified: trunk/Source/WebKit2/ChangeLog (192782 => 192783)
--- trunk/Source/WebKit2/ChangeLog 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/ChangeLog 2015-11-27 17:50:54 UTC (rev 192783)
@@ -1,3 +1,26 @@
+2015-11-27 Brady Eidson <[email protected]>
+
+ Modern IDB: Class-ify IDBGetResult making it impossible to get the data members wrong.
+ https://bugs.webkit.org/show_bug.cgi?id=151627
+
+ Reviewed by Alexey Proskuryakov.
+
+ * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+ (WebKit::UniqueIDBDatabase::getRecordFromBackingStore):
+ * DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:
+
+ * DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
+
+ * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+ (WebKit::UniqueIDBDatabaseBackingStoreSQLite::getIndexRecord):
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<IDBGetResult>::encode):
+ (IPC::ArgumentCoder<IDBGetResult>::decode):
+ * Shared/WebCoreArgumentCoders.h:
+
+ * WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in:
+
2015-11-27 Carlos Garcia Campos <[email protected]>
[GTK] Remove the remaining uses of GMainLoopSource
Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp (192782 => 192783)
--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -938,7 +938,7 @@
}
// We must return a key path to know how to inject the result key into the result value object.
- result.keyPath = objectStoreMetadata.keyPath;
+ result.setKeyPath(objectStoreMetadata.keyPath);
postMainThreadTask(createCrossThreadTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, result, 0, String(StringImpl::empty())));
}
Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h (192782 => 192783)
--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -46,11 +46,11 @@
namespace WebCore {
class CrossThreadTask;
+class IDBGetResult;
class IDBKeyData;
class SharedBuffer;
struct IDBDatabaseMetadata;
-struct IDBGetResult;
struct IDBKeyRangeData;
struct SecurityOriginData;
}
Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h (192782 => 192783)
--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -32,13 +32,13 @@
#include <wtf/RefCounted.h>
namespace WebCore {
+class IDBGetResult;
class IDBKey;
class IDBKeyData;
class IDBKeyRange;
class SharedBuffer;
struct IDBDatabaseMetadata;
-struct IDBGetResult;
struct IDBObjectStoreMetadata;
}
Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp (192782 => 192783)
--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -1066,7 +1066,7 @@
result = IDBGetResult(cursor->currentPrimaryKey());
else {
result = IDBGetResult(SharedBuffer::create(cursor->currentValueBuffer().data(), cursor->currentValueBuffer().size()));
- result.keyData = cursor->currentPrimaryKey();
+ result.setKeyData(cursor->currentPrimaryKey());
}
// Closing the cursor will destroy the cursor object and remove it from our cursor set.
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (192782 => 192783)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2015-11-27 17:50:54 UTC (rev 192783)
@@ -1827,13 +1827,13 @@
void ArgumentCoder<IDBGetResult>::encode(ArgumentEncoder& encoder, const IDBGetResult& result)
{
- bool nullData = !result.valueBuffer.data();
+ bool nullData = !result.valueBuffer().data();
encoder << nullData;
if (!nullData)
- encoder << DataReference(result.valueBuffer.data()->data(), result.valueBuffer.data()->size());
+ encoder << DataReference(result.valueBuffer().data()->data(), result.valueBuffer().data()->size());
- encoder << result.keyData << result.keyPath;
+ encoder << result.keyData() << result.keyPath();
}
bool ArgumentCoder<IDBGetResult>::decode(ArgumentDecoder& decoder, IDBGetResult& result)
@@ -1843,7 +1843,7 @@
return false;
if (nullData)
- result.valueBuffer = { };
+ result.setValueBuffer({ });
else {
DataReference data;
if (!decoder.decode(data))
@@ -1851,15 +1851,21 @@
Vector<uint8_t> vector(data.size());
memcpy(vector.data(), data.data(), data.size());
- result.valueBuffer = ThreadSafeDataBuffer::adoptVector(vector);
+ result.setValueBuffer(ThreadSafeDataBuffer::adoptVector(vector));
}
- if (!decoder.decode(result.keyData))
+ IDBKeyData keyData;
+ if (!decoder.decode(keyData))
return false;
- if (!decoder.decode(result.keyPath))
+ result.setKeyData(keyData);
+
+ IDBKeyPath keyPath;
+ if (!decoder.decode(keyPath))
return false;
+ result.setKeyPath(keyPath);
+
return true;
}
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h (192782 => 192783)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2015-11-27 17:50:54 UTC (rev 192783)
@@ -47,6 +47,7 @@
class FloatSize;
class FixedPositionViewportConstraints;
class HTTPHeaderMap;
+class IDBGetResult;
class IntPoint;
class IntRect;
class IntSize;
@@ -75,7 +76,6 @@
struct FileChooserSettings;
struct Length;
struct GrammarDetail;
-struct IDBGetResult;
struct MimeClassInfo;
struct PasteboardImage;
struct PasteboardWebContent;
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in (192782 => 192783)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in 2015-11-27 16:54:45 UTC (rev 192782)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in 2015-11-27 17:50:54 UTC (rev 192783)
@@ -41,7 +41,7 @@
DidDeleteIndex(uint64_t requestID, bool success)
DidPutRecord(uint64_t requestID, WebCore::IDBKeyData resultKey, uint32_t errorCode, String errorMessage)
- DidGetRecord(uint64_t requestID, struct WebCore::IDBGetResult getResult, uint32_t errorCode, String errorMessage)
+ DidGetRecord(uint64_t requestID, WebCore::IDBGetResult getResult, uint32_t errorCode, String errorMessage)
DidOpenCursor(uint64_t requestID, int64_t cursorID, WebCore::IDBKeyData key, WebCore::IDBKeyData primaryKey, IPC::DataReference value, uint32_t errorCode, String errorMessage)
DidAdvanceCursor(uint64_t requestID, WebCore::IDBKeyData key, WebCore::IDBKeyData primaryKey, IPC::DataReference value, uint32_t errorCode, String errorMessage)
DidIterateCursor(uint64_t requestID, WebCore::IDBKeyData key, WebCore::IDBKeyData primaryKey, IPC::DataReference value, uint32_t errorCode, String errorMessage)