Commit 19bcfd87 authored by Simon Giesecke's avatar Simon Giesecke
Browse files

Bug 1597211 - Calculate size of individual cursor response entries....

Bug 1597211 - Calculate size of individual cursor response entries. r=dom-workers-and-storage-reviewers,ytausky

Differential Revision: https://phabricator.services.mozilla.com/D53937

--HG--
extra : moz-landing-system : lando
parent 75118862
......@@ -9479,6 +9479,11 @@ struct CommonCursorTypeTraits {
aResponse->key() = std::move(mPosition);
}
 
template <typename Response>
static size_t GetKeySize(const Response* const aResponse) {
return aResponse->key().GetBuffer().Length();
}
protected:
const Key& GetPosition() const { return mPosition; }
 
......@@ -9528,6 +9533,13 @@ struct IndexCursorTypeTraits : CommonCursorTypeTraits {
aResponse->objectKey() = std::move(mObjectStorePosition);
}
 
template <typename Response>
static size_t GetKeySize(const Response* const aResponse) {
return CommonCursorTypeTraits::GetKeySize(aResponse) +
aResponse->sortKey().GetBuffer().Length() +
aResponse->objectKey().GetBuffer().Length();
}
private:
Key mLocaleAwarePosition, mObjectStorePosition;
};
......@@ -9542,6 +9554,12 @@ struct KeyCursorTypeTraits {
template <typename Response>
static constexpr void MaybeFillCloneInfo(Response* const /*aResponse*/,
FilesArray* const /*aFiles*/) {}
template <typename Response>
static constexpr size_t MaybeGetCloneInfoSize(
const Response* const /*aResponse*/) {
return 0;
}
};
 
template <bool StatementHasIndexKeyBindings>
......@@ -9573,6 +9591,11 @@ struct ValueCursorTypeTraits {
aFiles->AppendElement(std::move(mCloneInfo.mFiles));
}
 
template <typename Response>
static size_t MaybeGetCloneInfoSize(const Response* const aResponse) {
return aResponse->cloneInfo().data().data.Size();
}
private:
StructuredCloneReadInfo mCloneInfo{
JS::StructuredCloneScope::DifferentProcess};
......@@ -25985,11 +26008,12 @@ Cursor::CursorOpBase::PopulateResponseFromTypedStatement(
 
auto& responses = cursorTypeTraits.GetTypedResponse(&mResponse);
auto* response = responses.AppendElement();
cursorTypeTraits.FillKeys(response);
cursorTypeTraits.MaybeFillCloneInfo(response, &mFiles);
 
// TODO: Calculate real size and return it.
return 0;
return cursorTypeTraits.GetKeySize(response) +
cursorTypeTraits.MaybeGetCloneInfoSize(response);
}
 
Cursor::CursorOpBase::ResponseSizeOrError
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment