mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Bug 1168606 - Extract functions for accessing sort key into Cursor. r=ytausky,asuth
Depends on D44443 Differential Revision: https://phabricator.services.mozilla.com/D45308 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
594fcf54d2
commit
688308e098
@ -7683,6 +7683,9 @@ class Cursor final : public PBackgroundIDBCursorParent {
|
||||
|
||||
void SetOptionalKeyRange(const Maybe<SerializedKeyRange>& aOptionalKeyRange,
|
||||
bool* aOpen);
|
||||
|
||||
const Key& GetSortKey() const;
|
||||
Key* GetModifiableSortKey();
|
||||
};
|
||||
|
||||
class Cursor::CursorOpBase : public TransactionDatabaseOperationBase {
|
||||
@ -15135,7 +15138,7 @@ bool Cursor::VerifyRequestParams(const CursorRequestParams& aParams) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const Key& sortKey = IsLocaleAware() ? mLocaleAwarePosition : mPosition;
|
||||
const Key& sortKey = GetSortKey();
|
||||
|
||||
switch (aParams.type()) {
|
||||
case CursorRequestParams::TContinueParams: {
|
||||
@ -15422,6 +15425,12 @@ mozilla::ipc::IPCResult Cursor::RecvContinue(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
const Key& Cursor::GetSortKey() const {
|
||||
return IsLocaleAware() ? mLocaleAwarePosition : mPosition;
|
||||
}
|
||||
|
||||
Key* Cursor::GetModifiableSortKey() { return &const_cast<Key&>(GetSortKey()); }
|
||||
|
||||
/*******************************************************************************
|
||||
* FileManager
|
||||
******************************************************************************/
|
||||
@ -25758,8 +25767,10 @@ void Cursor::CursorOpBase::Cleanup() {
|
||||
nsresult Cursor::CursorOpBase::PopulateResponseFromStatement(
|
||||
mozIStorageStatement* const aStmt, const bool aInitializeResponse) {
|
||||
Transaction()->AssertIsOnConnectionThread();
|
||||
MOZ_ASSERT(aInitializeResponse ==
|
||||
(mResponse.type() == CursorResponse::T__None));
|
||||
MOZ_ASSERT_IF(aInitializeResponse,
|
||||
mResponse.type() == CursorResponse::T__None);
|
||||
MOZ_ASSERT_IF(!aInitializeResponse,
|
||||
mResponse.type() != CursorResponse::T__None);
|
||||
MOZ_ASSERT_IF(
|
||||
mFiles.IsEmpty() &&
|
||||
(mResponse.type() ==
|
||||
@ -25906,10 +25917,7 @@ nsresult Cursor::CursorOpBase::PopulateExtraResponses(
|
||||
// For unique cursors, we need to skip records with the same key. The SQL
|
||||
// queries currently do not filter these out.
|
||||
Key previousKey =
|
||||
IsUnique(mCursor->mDirection)
|
||||
? (mCursor->IsLocaleAware() ? mCursor->mLocaleAwarePosition
|
||||
: mCursor->mPosition)
|
||||
: Key{};
|
||||
IsUnique(mCursor->mDirection) ? mCursor->GetSortKey() : Key{};
|
||||
|
||||
uint32_t extraCount = 0;
|
||||
do {
|
||||
@ -25931,9 +25939,7 @@ nsresult Cursor::CursorOpBase::PopulateExtraResponses(
|
||||
}
|
||||
|
||||
if (IsUnique(mCursor->mDirection)) {
|
||||
const auto& currentKey = mCursor->IsLocaleAware()
|
||||
? mCursor->mLocaleAwarePosition
|
||||
: mCursor->mPosition;
|
||||
const auto& currentKey = mCursor->GetSortKey();
|
||||
const bool sameKey = previousKey == currentKey;
|
||||
previousKey = currentKey;
|
||||
if (sameKey) {
|
||||
@ -26183,7 +26189,7 @@ nsresult Cursor::OpenOp::DoObjectStoreDatabaseWork(
|
||||
// ContinueOp::DoDatabaseWork.
|
||||
//
|
||||
// TODO: We should somehow evaluate the effects of this. Maybe use a smaller
|
||||
// extra count that for ContinueOp?
|
||||
// extra count than for ContinueOp?
|
||||
//
|
||||
// TODO: If this is done here, do this in the other Do*DatabaseWork functions
|
||||
// as well (or move this to DoDatabaseWork).
|
||||
@ -26611,8 +26617,7 @@ nsresult Cursor::ContinueOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
// key/position in the operation's result. Maybe rename to
|
||||
// targetKey/targetPosition (which is also not exact, as it might imply that
|
||||
// the result always has this key).
|
||||
Key& currentKey = mCursor->IsLocaleAware() ? mCursor->mLocaleAwarePosition
|
||||
: mCursor->mPosition;
|
||||
Key& currentKey = *mCursor->GetModifiableSortKey();
|
||||
|
||||
IDB_LOG_MARK_PARENT_TRANSACTION_REQUEST(
|
||||
"PRELOAD: ContinueOp: currentKey == %s", "currentKey",
|
||||
|
Loading…
Reference in New Issue
Block a user