Bug 1545196 - Avoid copying large RequestParams sub-object in ObjectStoreAddOrPutRequestOp. r=dom-workers-and-storage-reviewers,janv

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2020-01-23 13:53:46 +00:00
Родитель 7afb826ef9
Коммит c30b0678a2
2 изменённых файлов: 18 добавлений и 10 удалений

Просмотреть файл

@ -6433,7 +6433,7 @@ class TransactionBase {
CommitOrAbort(); CommitOrAbort();
} }
PBackgroundIDBRequestParent* AllocRequest(const RequestParams& aParams, PBackgroundIDBRequestParent* AllocRequest(RequestParams&& aParams,
bool aTrustParams); bool aTrustParams);
bool StartRequest(PBackgroundIDBRequestParent* aActor); bool StartRequest(PBackgroundIDBRequestParent* aActor);
@ -7415,7 +7415,7 @@ class ObjectStoreAddOrPutRequestOp final : public NormalTransactionOp {
private: private:
// Only created by TransactionBase. // Only created by TransactionBase.
ObjectStoreAddOrPutRequestOp(RefPtr<TransactionBase> aTransaction, ObjectStoreAddOrPutRequestOp(RefPtr<TransactionBase> aTransaction,
const RequestParams& aParams); RequestParams&& aParams);
~ObjectStoreAddOrPutRequestOp() override = default; ~ObjectStoreAddOrPutRequestOp() override = default;
@ -14658,7 +14658,7 @@ void TransactionBase::Invalidate() {
} }
PBackgroundIDBRequestParent* TransactionBase::AllocRequest( PBackgroundIDBRequestParent* TransactionBase::AllocRequest(
const RequestParams& aParams, bool aTrustParams) { RequestParams&& aParams, bool aTrustParams) {
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();
MOZ_ASSERT(aParams.type() != RequestParams::T__None); MOZ_ASSERT(aParams.type() != RequestParams::T__None);
@ -14682,7 +14682,7 @@ PBackgroundIDBRequestParent* TransactionBase::AllocRequest(
switch (aParams.type()) { switch (aParams.type()) {
case RequestParams::TObjectStoreAddParams: case RequestParams::TObjectStoreAddParams:
case RequestParams::TObjectStorePutParams: case RequestParams::TObjectStorePutParams:
actor = new ObjectStoreAddOrPutRequestOp(this, aParams); actor = new ObjectStoreAddOrPutRequestOp(this, std::move(aParams));
break; break;
case RequestParams::TObjectStoreGetParams: case RequestParams::TObjectStoreGetParams:
@ -14958,7 +14958,8 @@ NormalTransaction::AllocPBackgroundIDBRequestParent(
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();
MOZ_ASSERT(aParams.type() != RequestParams::T__None); MOZ_ASSERT(aParams.type() != RequestParams::T__None);
return AllocRequest(aParams, IsSameProcessActor()); return AllocRequest(std::move(const_cast<RequestParams&>(aParams)),
IsSameProcessActor());
} }
mozilla::ipc::IPCResult NormalTransaction::RecvPBackgroundIDBRequestConstructor( mozilla::ipc::IPCResult NormalTransaction::RecvPBackgroundIDBRequestConstructor(
@ -15591,7 +15592,8 @@ VersionChangeTransaction::AllocPBackgroundIDBRequestParent(
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();
MOZ_ASSERT(aParams.type() != RequestParams::T__None); MOZ_ASSERT(aParams.type() != RequestParams::T__None);
return AllocRequest(aParams, IsSameProcessActor()); return AllocRequest(std::move(const_cast<RequestParams&>(aParams)),
IsSameProcessActor());
} }
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
@ -24702,11 +24704,12 @@ mozilla::ipc::IPCResult NormalTransactionOp::RecvContinue(
} }
ObjectStoreAddOrPutRequestOp::ObjectStoreAddOrPutRequestOp( ObjectStoreAddOrPutRequestOp::ObjectStoreAddOrPutRequestOp(
RefPtr<TransactionBase> aTransaction, const RequestParams& aParams) RefPtr<TransactionBase> aTransaction, RequestParams&& aParams)
: NormalTransactionOp(std::move(aTransaction)), : NormalTransactionOp(std::move(aTransaction)),
mParams(aParams.type() == RequestParams::TObjectStoreAddParams mParams(
? aParams.get_ObjectStoreAddParams().commonParams() std::move(aParams.type() == RequestParams::TObjectStoreAddParams
: aParams.get_ObjectStorePutParams().commonParams()), ? aParams.get_ObjectStoreAddParams().commonParams()
: aParams.get_ObjectStorePutParams().commonParams())),
mGroup(Transaction().GetDatabase()->Group()), mGroup(Transaction().GetDatabase()->Group()),
mOrigin(Transaction().GetDatabase()->Origin()), mOrigin(Transaction().GetDatabase()->Origin()),
mPersistenceType(Transaction().GetDatabase()->Type()), mPersistenceType(Transaction().GetDatabase()->Type()),

Просмотреть файл

@ -78,6 +78,11 @@ struct SerializedStructuredCloneBuffer final {
SerializedStructuredCloneBuffer() SerializedStructuredCloneBuffer()
: data(JS::StructuredCloneScope::Unassigned) {} : data(JS::StructuredCloneScope::Unassigned) {}
SerializedStructuredCloneBuffer(SerializedStructuredCloneBuffer&&) noexcept =
default;
SerializedStructuredCloneBuffer& operator=(
SerializedStructuredCloneBuffer&&) noexcept = default;
SerializedStructuredCloneBuffer(const SerializedStructuredCloneBuffer& aOther) SerializedStructuredCloneBuffer(const SerializedStructuredCloneBuffer& aOther)
: SerializedStructuredCloneBuffer() { : SerializedStructuredCloneBuffer() {
*this = aOther; *this = aOther;