Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Modern IDB: Make IDBGetResult contain an IDBValue instead of a buffer…
…, and remove unused methods.

https://bugs.webkit.org/show_bug.cgi?id=156416

Reviewed by Alex Christensen.

No new tests (Refactor, no change in behavior).

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::setGetResult):

* Modules/indexeddb/IDBGetResult.cpp:
(WebCore::IDBGetResult::dataFromBuffer):
(WebCore::IDBGetResult::isolatedCopy):
* Modules/indexeddb/IDBGetResult.h:
(WebCore::IDBGetResult::IDBGetResult):
(WebCore::IDBGetResult::value):
(WebCore::IDBGetResult::encode):
(WebCore::IDBGetResult::decode):
(WebCore::IDBGetResult::valueBuffer): Deleted.
(WebCore::IDBGetResult::setValueBuffer): Deleted.
(WebCore::IDBGetResult::setKeyData): Deleted.
(WebCore::IDBGetResult::setPrimaryKeyData): Deleted.
(WebCore::IDBGetResult::setKeyPath): Deleted.

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::didGetRecordOnServer):

* Modules/indexeddb/IDBValue.cpp:
(WebCore::IDBValue::IDBValue):
* Modules/indexeddb/IDBValue.h:

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::getIndexRecord):


Canonical link: https://commits.webkit.org/174516@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
beidson committed Apr 8, 2016
1 parent 13153d3 commit 34c423f
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 39 deletions.
36 changes: 36 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,39 @@
2016-04-08 Brady Eidson <beidson@apple.com>

Modern IDB: Make IDBGetResult contain an IDBValue instead of a buffer, and remove unused methods.
https://bugs.webkit.org/show_bug.cgi?id=156416

Reviewed by Alex Christensen.

No new tests (Refactor, no change in behavior).

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::setGetResult):

* Modules/indexeddb/IDBGetResult.cpp:
(WebCore::IDBGetResult::dataFromBuffer):
(WebCore::IDBGetResult::isolatedCopy):
* Modules/indexeddb/IDBGetResult.h:
(WebCore::IDBGetResult::IDBGetResult):
(WebCore::IDBGetResult::value):
(WebCore::IDBGetResult::encode):
(WebCore::IDBGetResult::decode):
(WebCore::IDBGetResult::valueBuffer): Deleted.
(WebCore::IDBGetResult::setValueBuffer): Deleted.
(WebCore::IDBGetResult::setKeyData): Deleted.
(WebCore::IDBGetResult::setPrimaryKeyData): Deleted.
(WebCore::IDBGetResult::setKeyPath): Deleted.

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::didGetRecordOnServer):

* Modules/indexeddb/IDBValue.cpp:
(WebCore::IDBValue::IDBValue):
* Modules/indexeddb/IDBValue.h:

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::getIndexRecord):

2016-04-08 Zalan Bujtas <zalan@apple.com>

Focus ring drawn at incorrect location on image map with CSS transform.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Expand Up @@ -418,7 +418,7 @@ void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
if (isKeyCursor())
m_deprecatedCurrentValue = { };
else
m_deprecatedCurrentValue = deserializeIDBValueData(*context, getResult.valueBuffer());
m_deprecatedCurrentValue = deserializeIDBValueData(*context, getResult.value().data());

m_gotValue = true;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/Modules/indexeddb/IDBGetResult.cpp
Expand Up @@ -35,13 +35,13 @@ void IDBGetResult::dataFromBuffer(SharedBuffer& buffer)
Vector<uint8_t> data(buffer.size());
memcpy(data.data(), buffer.data(), buffer.size());

m_valueBuffer = ThreadSafeDataBuffer::adoptVector(data);
m_value = ThreadSafeDataBuffer::adoptVector(data);
}

IDBGetResult IDBGetResult::isolatedCopy() const
{
IDBGetResult result;
result.m_valueBuffer = m_valueBuffer;
result.m_value = m_value.isolatedCopy();
result.m_keyData = m_keyData.isolatedCopy();
result.m_primaryKeyData = m_primaryKeyData.isolatedCopy();
result.m_keyPath = m_keyPath.isolatedCopy();
Expand Down
40 changes: 10 additions & 30 deletions Source/WebCore/Modules/indexeddb/IDBGetResult.h
Expand Up @@ -31,8 +31,8 @@
#include "IDBKey.h"
#include "IDBKeyData.h"
#include "IDBKeyPath.h"
#include "IDBValue.h"
#include "SharedBuffer.h"
#include "ThreadSafeDataBuffer.h"

namespace WebCore {

Expand All @@ -43,14 +43,14 @@ class IDBGetResult {
{
}

IDBGetResult(SharedBuffer* buffer)
IDBGetResult(Ref<SharedBuffer>&& buffer, const IDBKeyData& currentPrimaryKey)
: m_primaryKeyData(currentPrimaryKey)
{
if (buffer)
dataFromBuffer(*buffer);
dataFromBuffer(buffer.get());
}

IDBGetResult(const ThreadSafeDataBuffer& buffer)
: m_valueBuffer(buffer)
: m_value(buffer)
{
}

Expand Down Expand Up @@ -79,15 +79,15 @@ class IDBGetResult {
}

IDBGetResult(const IDBKeyData& keyData, const IDBKeyData& primaryKeyData, const ThreadSafeDataBuffer& valueBuffer)
: m_valueBuffer(valueBuffer)
: m_value(valueBuffer)
, m_keyData(keyData)
, m_primaryKeyData(primaryKeyData)
{
}

IDBGetResult isolatedCopy() const;

const ThreadSafeDataBuffer& valueBuffer() const { return m_valueBuffer; }
const IDBValue& value() const { return m_value; }
const IDBKeyData& keyData() const { return m_keyData; }
const IDBKeyData& primaryKeyData() const { return m_primaryKeyData; }
const IDBKeyPath& keyPath() const { return m_keyPath; }
Expand All @@ -96,18 +96,10 @@ class IDBGetResult {
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static bool decode(Decoder&, IDBGetResult&);

// 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;
IDBValue m_value;
IDBKeyData m_keyData;
IDBKeyData m_primaryKeyData;
IDBKeyPath m_keyPath;
Expand All @@ -117,11 +109,7 @@ class IDBGetResult {
template<class Encoder>
void IDBGetResult::encode(Encoder& encoder) const
{
encoder << m_keyData << m_primaryKeyData << m_keyPath << m_isDefined;

encoder << !!m_valueBuffer.data();
if (m_valueBuffer.data())
encoder << *m_valueBuffer.data();
encoder << m_keyData << m_primaryKeyData << m_keyPath << m_isDefined << m_value;
}

template<class Decoder>
Expand All @@ -139,17 +127,9 @@ bool IDBGetResult::decode(Decoder& decoder, IDBGetResult& result)
if (!decoder.decode(result.m_isDefined))
return false;

bool hasObject;
if (!decoder.decode(hasObject))
if (!decoder.decode(result.m_value))
return false;

if (hasObject) {
Vector<uint8_t> value;
if (!decoder.decode(value))
return false;
result.m_valueBuffer = ThreadSafeDataBuffer::adoptVector(value);
}

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Expand Up @@ -737,8 +737,8 @@ void IDBTransaction::didGetRecordOnServer(IDBRequest& request, const IDBResultDa
else
request.setResultToUndefined();
} else {
if (resultData.getResult().valueBuffer().data())
request.setResultToStructuredClone(resultData.getResult().valueBuffer());
if (resultData.getResult().value().data().data())
request.setResultToStructuredClone(resultData.getResult().value().data());
else
request.setResultToUndefined();
}
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/Modules/indexeddb/IDBValue.cpp
Expand Up @@ -42,6 +42,11 @@ IDBValue::IDBValue(const SerializedScriptValue& scriptValue)
{
}

IDBValue::IDBValue(const ThreadSafeDataBuffer& value)
: m_data(value)
{
}

IDBValue::IDBValue(const SerializedScriptValue& scriptValue, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)
: m_data(ThreadSafeDataBuffer::copyVector(scriptValue.data()))
, m_blobURLs(blobURLs)
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/Modules/indexeddb/IDBValue.h
Expand Up @@ -37,6 +37,7 @@ class IDBValue {
public:
WEBCORE_EXPORT IDBValue();
IDBValue(const SerializedScriptValue&);
IDBValue(const ThreadSafeDataBuffer&);
IDBValue(const SerializedScriptValue&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);

IDBValue isolatedCopy() const;
Expand Down
Expand Up @@ -1630,10 +1630,8 @@ IDBError SQLiteIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& tran
else {
if (type == IndexedDB::IndexRecordType::Key)
getResult = { cursor->currentPrimaryKey() };
else {
getResult = { SharedBuffer::create(cursor->currentValueBuffer().data(), cursor->currentValueBuffer().size()).ptr() };
getResult.setKeyData(cursor->currentPrimaryKey());
}
else
getResult = { SharedBuffer::create(cursor->currentValueBuffer().data(), cursor->currentValueBuffer().size()), cursor->currentPrimaryKey() };
}

return { };
Expand Down

0 comments on commit 34c423f

Please sign in to comment.