зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1168606 - Change definition of OpenCursorParams subtypes to allow reducing duplicated code r=ttung,asuth
Differential Revision: https://phabricator.services.mozilla.com/D40955 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
abad982ec4
Коммит
f4cb5f1dee
|
@ -13985,79 +13985,85 @@ PBackgroundIDBCursorParent* TransactionBase::AllocCursor(
|
|||
case OpenCursorParams::TObjectStoreOpenCursorParams: {
|
||||
const ObjectStoreOpenCursorParams& params =
|
||||
aParams.get_ObjectStoreOpenCursorParams();
|
||||
objectStoreMetadata = GetMetadataForObjectStoreId(params.objectStoreId());
|
||||
objectStoreMetadata =
|
||||
GetMetadataForObjectStoreId(params.commonParams().objectStoreId());
|
||||
if (NS_WARN_IF(!objectStoreMetadata)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
if (aTrustParams &&
|
||||
NS_WARN_IF(!VerifyRequestParams(params.optionalKeyRange()))) {
|
||||
if (aTrustParams && NS_WARN_IF(!VerifyRequestParams(
|
||||
params.commonParams().optionalKeyRange()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
direction = params.direction();
|
||||
direction = params.commonParams().direction();
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenCursorParams::TObjectStoreOpenKeyCursorParams: {
|
||||
const ObjectStoreOpenKeyCursorParams& params =
|
||||
aParams.get_ObjectStoreOpenKeyCursorParams();
|
||||
objectStoreMetadata = GetMetadataForObjectStoreId(params.objectStoreId());
|
||||
objectStoreMetadata =
|
||||
GetMetadataForObjectStoreId(params.commonParams().objectStoreId());
|
||||
if (NS_WARN_IF(!objectStoreMetadata)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
if (aTrustParams &&
|
||||
NS_WARN_IF(!VerifyRequestParams(params.optionalKeyRange()))) {
|
||||
if (aTrustParams && NS_WARN_IF(!VerifyRequestParams(
|
||||
params.commonParams().optionalKeyRange()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
direction = params.direction();
|
||||
direction = params.commonParams().direction();
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenCursorParams::TIndexOpenCursorParams: {
|
||||
const IndexOpenCursorParams& params = aParams.get_IndexOpenCursorParams();
|
||||
objectStoreMetadata = GetMetadataForObjectStoreId(params.objectStoreId());
|
||||
objectStoreMetadata = GetMetadataForObjectStoreId(
|
||||
params.commonIndexParams().commonParams().objectStoreId());
|
||||
if (NS_WARN_IF(!objectStoreMetadata)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
indexMetadata =
|
||||
GetMetadataForIndexId(objectStoreMetadata, params.indexId());
|
||||
indexMetadata = GetMetadataForIndexId(
|
||||
objectStoreMetadata, params.commonIndexParams().indexId());
|
||||
if (NS_WARN_IF(!indexMetadata)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
if (aTrustParams &&
|
||||
NS_WARN_IF(!VerifyRequestParams(params.optionalKeyRange()))) {
|
||||
NS_WARN_IF(!VerifyRequestParams(
|
||||
params.commonIndexParams().commonParams().optionalKeyRange()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
direction = params.direction();
|
||||
direction = params.commonIndexParams().commonParams().direction();
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenCursorParams::TIndexOpenKeyCursorParams: {
|
||||
const IndexOpenKeyCursorParams& params =
|
||||
aParams.get_IndexOpenKeyCursorParams();
|
||||
objectStoreMetadata = GetMetadataForObjectStoreId(params.objectStoreId());
|
||||
objectStoreMetadata = GetMetadataForObjectStoreId(
|
||||
params.commonIndexParams().commonParams().objectStoreId());
|
||||
if (NS_WARN_IF(!objectStoreMetadata)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
indexMetadata =
|
||||
GetMetadataForIndexId(objectStoreMetadata, params.indexId());
|
||||
indexMetadata = GetMetadataForIndexId(
|
||||
objectStoreMetadata, params.commonIndexParams().indexId());
|
||||
if (NS_WARN_IF(!indexMetadata)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
if (aTrustParams &&
|
||||
NS_WARN_IF(!VerifyRequestParams(params.optionalKeyRange()))) {
|
||||
NS_WARN_IF(!VerifyRequestParams(
|
||||
params.commonIndexParams().commonParams().optionalKeyRange()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
direction = params.direction();
|
||||
direction = params.commonIndexParams().commonParams().direction();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -15047,13 +15053,21 @@ bool Cursor::Start(const OpenCursorParams& aParams) {
|
|||
|
||||
const Maybe<SerializedKeyRange>& optionalKeyRange =
|
||||
mType == OpenCursorParams::TObjectStoreOpenCursorParams
|
||||
? aParams.get_ObjectStoreOpenCursorParams().optionalKeyRange()
|
||||
? aParams.get_ObjectStoreOpenCursorParams()
|
||||
.commonParams()
|
||||
.optionalKeyRange()
|
||||
: mType == OpenCursorParams::TObjectStoreOpenKeyCursorParams
|
||||
? aParams.get_ObjectStoreOpenKeyCursorParams()
|
||||
.commonParams()
|
||||
.optionalKeyRange()
|
||||
: mType == OpenCursorParams::TIndexOpenCursorParams
|
||||
? aParams.get_IndexOpenCursorParams().optionalKeyRange()
|
||||
? aParams.get_IndexOpenCursorParams()
|
||||
.commonIndexParams()
|
||||
.commonParams()
|
||||
.optionalKeyRange()
|
||||
: aParams.get_IndexOpenKeyCursorParams()
|
||||
.commonIndexParams()
|
||||
.commonParams()
|
||||
.optionalKeyRange();
|
||||
|
||||
RefPtr<OpenOp> openOp = new OpenOp(this, optionalKeyRange);
|
||||
|
|
|
@ -458,18 +458,22 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
|
|||
OpenCursorParams params;
|
||||
if (aKeysOnly) {
|
||||
IndexOpenKeyCursorParams openParams;
|
||||
openParams.objectStoreId() = objectStoreId;
|
||||
openParams.indexId() = indexId;
|
||||
openParams.optionalKeyRange() = std::move(optionalKeyRange);
|
||||
openParams.direction() = direction;
|
||||
openParams.commonIndexParams().commonParams().objectStoreId() =
|
||||
objectStoreId;
|
||||
openParams.commonIndexParams().indexId() = indexId;
|
||||
openParams.commonIndexParams().commonParams().optionalKeyRange() =
|
||||
std::move(optionalKeyRange);
|
||||
openParams.commonIndexParams().commonParams().direction() = direction;
|
||||
|
||||
params = std::move(openParams);
|
||||
} else {
|
||||
IndexOpenCursorParams openParams;
|
||||
openParams.objectStoreId() = objectStoreId;
|
||||
openParams.indexId() = indexId;
|
||||
openParams.optionalKeyRange() = std::move(optionalKeyRange);
|
||||
openParams.direction() = direction;
|
||||
openParams.commonIndexParams().commonParams().objectStoreId() =
|
||||
objectStoreId;
|
||||
openParams.commonIndexParams().indexId() = indexId;
|
||||
openParams.commonIndexParams().commonParams().optionalKeyRange() =
|
||||
std::move(optionalKeyRange);
|
||||
openParams.commonIndexParams().commonParams().direction() = direction;
|
||||
|
||||
params = std::move(openParams);
|
||||
}
|
||||
|
|
|
@ -2273,16 +2273,16 @@ already_AddRefed<IDBRequest> IDBObjectStore::OpenCursorInternal(
|
|||
OpenCursorParams params;
|
||||
if (aKeysOnly) {
|
||||
ObjectStoreOpenKeyCursorParams openParams;
|
||||
openParams.objectStoreId() = objectStoreId;
|
||||
openParams.optionalKeyRange() = std::move(optionalKeyRange);
|
||||
openParams.direction() = direction;
|
||||
openParams.commonParams().objectStoreId() = objectStoreId;
|
||||
openParams.commonParams().optionalKeyRange() = std::move(optionalKeyRange);
|
||||
openParams.commonParams().direction() = direction;
|
||||
|
||||
params = std::move(openParams);
|
||||
} else {
|
||||
ObjectStoreOpenCursorParams openParams;
|
||||
openParams.objectStoreId() = objectStoreId;
|
||||
openParams.optionalKeyRange() = std::move(optionalKeyRange);
|
||||
openParams.direction() = direction;
|
||||
openParams.commonParams().objectStoreId() = objectStoreId;
|
||||
openParams.commonParams().optionalKeyRange() = std::move(optionalKeyRange);
|
||||
openParams.commonParams().direction() = direction;
|
||||
|
||||
params = std::move(openParams);
|
||||
}
|
||||
|
|
|
@ -124,36 +124,43 @@ struct ObjectStoreSpec
|
|||
IndexMetadata[] indexes;
|
||||
};
|
||||
|
||||
struct ObjectStoreOpenCursorParams
|
||||
struct CommonOpenCursorParams
|
||||
{
|
||||
int64_t objectStoreId;
|
||||
SerializedKeyRange? optionalKeyRange;
|
||||
Direction direction;
|
||||
};
|
||||
|
||||
struct ObjectStoreOpenCursorParams
|
||||
{
|
||||
CommonOpenCursorParams commonParams;
|
||||
};
|
||||
|
||||
struct ObjectStoreOpenKeyCursorParams
|
||||
{
|
||||
int64_t objectStoreId;
|
||||
SerializedKeyRange? optionalKeyRange;
|
||||
Direction direction;
|
||||
CommonOpenCursorParams commonParams;
|
||||
};
|
||||
|
||||
struct CommonIndexOpenCursorParams
|
||||
{
|
||||
CommonOpenCursorParams commonParams;
|
||||
int64_t indexId;
|
||||
};
|
||||
|
||||
struct IndexOpenCursorParams
|
||||
{
|
||||
int64_t objectStoreId;
|
||||
int64_t indexId;
|
||||
SerializedKeyRange? optionalKeyRange;
|
||||
Direction direction;
|
||||
CommonIndexOpenCursorParams commonIndexParams;
|
||||
};
|
||||
|
||||
struct IndexOpenKeyCursorParams
|
||||
{
|
||||
int64_t objectStoreId;
|
||||
int64_t indexId;
|
||||
SerializedKeyRange? optionalKeyRange;
|
||||
Direction direction;
|
||||
CommonIndexOpenCursorParams commonIndexParams;
|
||||
};
|
||||
|
||||
// TODO: Actually, using a union here is not very nice, unless IPDL supported
|
||||
// struct inheritance. Alternatively, if IPDL supported enums, we could merge
|
||||
// the subtypes into one. Using a plain integer for discriminating the
|
||||
// subtypes would be too error-prone.
|
||||
union OpenCursorParams
|
||||
{
|
||||
ObjectStoreOpenCursorParams;
|
||||
|
|
Загрузка…
Ссылка в новой задаче