Backed out 12 changesets (bug 1168606) for causing build bustages on ActorsParent.cpp and Assertions.h. CLOSED TREE

Backed out changeset 307bd8d24407 (bug 1168606)
Backed out changeset a2ae085f929f (bug 1168606)
Backed out changeset 8fdc4a3d3ecb (bug 1168606)
Backed out changeset 918dc7cce5e9 (bug 1168606)
Backed out changeset 8c776a5cb5db (bug 1168606)
Backed out changeset dffe1e6c58bd (bug 1168606)
Backed out changeset 41f1bef0f019 (bug 1168606)
Backed out changeset 96cb7140a4f6 (bug 1168606)
Backed out changeset 6818224b9b11 (bug 1168606)
Backed out changeset f1be81af7d6b (bug 1168606)
Backed out changeset 8dc185488801 (bug 1168606)
Backed out changeset 9d8b02674d45 (bug 1168606)
This commit is contained in:
Cosmin Sabou 2019-11-05 16:34:22 +02:00
Родитель a97f9adaf8
Коммит 1211bbc800
12 изменённых файлов: 300 добавлений и 972 удалений

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

@ -1274,19 +1274,6 @@ void DispatchFileHandleSuccessEvent(FileHandleResultHelper* aResultHelper) {
MOZ_ASSERT(fileHandle->IsOpen() || fileHandle->IsAborted());
}
auto GetKeyOperator(const IDBCursor::Direction aDirection) {
switch (aDirection) {
case IDBCursor::NEXT:
case IDBCursor::NEXT_UNIQUE:
return &Key::operator>=;
case IDBCursor::PREV:
case IDBCursor::PREV_UNIQUE:
return &Key::operator<=;
default:
MOZ_CRASH("Should never get here.");
}
}
} // namespace
/*******************************************************************************
@ -2845,7 +2832,7 @@ void BackgroundRequestChild::ActorDestroy(ActorDestroyReason aWhy) {
if (mTransaction) {
mTransaction->AssertIsOnOwningThread();
mTransaction->OnRequestFinished(/* aRequestCompletedSuccessfully */
mTransaction->OnRequestFinished(/* aActorDestroyedNormally */
aWhy == Deletion);
#ifdef DEBUG
mTransaction = nullptr;
@ -2932,7 +2919,7 @@ mozilla::ipc::IPCResult BackgroundRequestChild::Recv__delete__(
}
}
mTransaction->OnRequestFinished(/* aRequestCompletedSuccessfully */ true);
mTransaction->OnRequestFinished(/* aActorDestroyedNormally */ true);
// Null this out so that we don't try to call OnRequestFinished() again in
// ActorDestroy.
@ -3215,28 +3202,6 @@ BackgroundRequestChild::PreprocessHelper::OnFileMetadataReady(
* BackgroundCursorChild
******************************************************************************/
BackgroundCursorChild::CachedResponse::CachedResponse(
Key aKey, StructuredCloneReadInfo&& aCloneInfo)
: mKey{std::move(aKey)}, mCloneInfo{std::move(aCloneInfo)} {}
BackgroundCursorChild::CachedResponse::CachedResponse(
Key aKey, Key aLocaleAwareKey, Key aObjectStoreKey,
StructuredCloneReadInfo&& aCloneInfo)
: mKey{std::move(aKey)},
mLocaleAwareKey{std::move(aLocaleAwareKey)},
mObjectStoreKey{std::move(aObjectStoreKey)},
mCloneInfo{std::move(aCloneInfo)} {}
BackgroundCursorChild::CachedResponse::CachedResponse(Key aKey)
: mKey{std::move(aKey)} {}
BackgroundCursorChild::CachedResponse::CachedResponse(Key aKey,
Key aLocaleAwareKey,
Key aObjectStoreKey)
: mKey{std::move(aKey)},
mLocaleAwareKey{std::move(aLocaleAwareKey)},
mObjectStoreKey{std::move(aObjectStoreKey)} {}
// Does not need to be threadsafe since this only runs on one thread, but
// inheriting from CancelableRunnable is easy.
class BackgroundCursorChild::DelayedActionRunnable final
@ -3307,8 +3272,7 @@ BackgroundCursorChild::~BackgroundCursorChild() {
}
void BackgroundCursorChild::SendContinueInternal(
const CursorRequestParams& aParams, const Key& aCurrentKey,
const Key& aCurrentObjectStoreKey) {
const CursorRequestParams& aParams, const Key& aCurrentKey) {
AssertIsOnOwningThread();
MOZ_ASSERT(mRequest);
MOZ_ASSERT(mTransaction);
@ -3324,157 +3288,8 @@ void BackgroundCursorChild::SendContinueInternal(
mTransaction->OnNewRequest();
CursorRequestParams params = aParams;
Key currentKey = aCurrentKey;
Key currentObjectStoreKey = aCurrentObjectStoreKey;
switch (params.type()) {
case CursorRequestParams::TContinueParams: {
const auto& key = params.get_ContinueParams().key();
if (key.IsUnset()) {
break;
}
// Discard cache entries before the target key.
DiscardCachedResponses(
[&key, isLocaleAware = mCursor->IsLocaleAware(),
keyOperator = GetKeyOperator(mDirection),
transactionSerialNumber = mTransaction->LoggingSerialNumber(),
requestSerialNumber = mRequest->LoggingSerialNumber()](
const auto& currentCachedResponse) {
// This duplicates the logic from the parent. We could avoid this
// duplication if we invalidated the cached records always for any
// continue-with-key operation, but would lose the benefits of
// preloading then.
const auto& cachedSortKey =
isLocaleAware ? currentCachedResponse.mLocaleAwareKey
: currentCachedResponse.mKey;
const bool discard = !(cachedSortKey.*keyOperator)(key);
if (discard) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Continue to key %s, discarding cached key %s/%s",
"Continue, discarding", transactionSerialNumber,
requestSerialNumber, key.GetBuffer().get(),
cachedSortKey.GetBuffer().get(),
currentCachedResponse.mObjectStoreKey.GetBuffer().get());
} else {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Continue to key %s, keeping cached key %s/%s and "
"further",
"Continue, keeping", transactionSerialNumber,
requestSerialNumber, key.GetBuffer().get(),
cachedSortKey.GetBuffer().get(),
currentCachedResponse.mObjectStoreKey.GetBuffer().get());
}
return discard;
});
break;
}
case CursorRequestParams::TContinuePrimaryKeyParams:
// TODO: Implement preloading for this case
InvalidateCachedResponses();
break;
case CursorRequestParams::TAdvanceParams: {
uint32_t& advanceCount = params.get_AdvanceParams().count();
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Advancing %" PRIu32 " records", "Advancing",
mTransaction->LoggingSerialNumber(), mRequest->LoggingSerialNumber(),
advanceCount);
// Discard cache entries.
DiscardCachedResponses(
[&advanceCount, &currentKey,
&currentObjectStoreKey](const auto& currentCachedResponse) {
const bool res = advanceCount > 1;
if (res) {
--advanceCount;
// TODO: We only need to update currentKey on the last entry, the
// others are overwritten in the next iteration anyway.
currentKey = currentCachedResponse.mKey;
currentObjectStoreKey = currentCachedResponse.mObjectStoreKey;
}
return res;
});
break;
}
default:
MOZ_CRASH("Should never get here!");
}
if (!mCachedResponses.empty()) {
// We need to remove the response here from mCachedResponses, since when
// requests are interleaved, other events may be processed before
// CompleteContinueRequestFromCache, which may modify mCachedResponses.
mDelayedResponses.emplace_back(std::move(mCachedResponses.front()));
mCachedResponses.pop_front();
// We cannot send the response right away, as we must preserve the request
// order. Dispatching a DelayedActionRunnable only partially addresses this.
// This is accompanied by invalidating cached entries at proper locations to
// make it correct. To avoid this, further changes are necessary, see Bug
// 1580499.
nsCOMPtr<nsIRunnable> continueRunnable = new DelayedActionRunnable(
this, &BackgroundCursorChild::CompleteContinueRequestFromCache);
MOZ_ALWAYS_TRUE(
NS_SUCCEEDED(NS_DispatchToCurrentThread(continueRunnable.forget())));
// TODO: Could we preload further entries in the background when the size of
// mCachedResponses falls under some threshold? Or does the response
// handling model disallow this?
} else {
MOZ_ALWAYS_TRUE(PBackgroundIDBCursorChild::SendContinue(
params, currentKey, currentObjectStoreKey));
}
}
void BackgroundCursorChild::CompleteContinueRequestFromCache() {
AssertIsOnOwningThread();
MOZ_ASSERT(mTransaction);
MOZ_ASSERT(mCursor);
MOZ_ASSERT(mStrongCursor);
MOZ_ASSERT(!mDelayedResponses.empty());
RefPtr<IDBCursor> cursor;
mStrongCursor.swap(cursor);
auto& item = mDelayedResponses.front();
switch (mCursor->GetType()) {
case IDBCursor::Type_ObjectStore:
mCursor->Reset(std::move(item.mKey), std::move(item.mCloneInfo));
break;
case IDBCursor::Type_Index:
mCursor->Reset(std::move(item.mKey), std::move(item.mLocaleAwareKey),
std::move(item.mObjectStoreKey),
std::move(item.mCloneInfo));
break;
case IDBCursor::Type_ObjectStoreKey:
mCursor->Reset(std::move(item.mKey));
break;
case IDBCursor::Type_IndexKey:
mCursor->Reset(std::move(item.mKey), std::move(item.mLocaleAwareKey),
std::move(item.mObjectStoreKey));
break;
default:
MOZ_CRASH("Should never get here.");
}
mDelayedResponses.pop_front();
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Consumed 1 cached response, %zu cached responses remaining",
"Consumed cached response", mTransaction->LoggingSerialNumber(),
mRequest->LoggingSerialNumber(),
mDelayedResponses.size() + mCachedResponses.size());
ResultHelper helper(mRequest, mTransaction, mCursor);
DispatchSuccessEvent(&helper);
mTransaction->OnRequestFinished(/* aRequestCompletedSuccessfully */ true);
MOZ_ALWAYS_TRUE(
PBackgroundIDBCursorChild::SendContinue(aParams, aCurrentKey));
}
void BackgroundCursorChild::SendDeleteMeInternal() {
@ -3495,40 +3310,6 @@ void BackgroundCursorChild::SendDeleteMeInternal() {
}
}
void BackgroundCursorChild::InvalidateCachedResponses() {
AssertIsOnOwningThread();
MOZ_ASSERT(mTransaction);
MOZ_ASSERT(mRequest);
// TODO: With more information on the reason for the invalidation, we might
// only selectively invalidate cached responses. If the reason is an updated
// value, we do not need to care for key-only cursors. If the key of the
// changed entry is not in the remaining range of the cursor, we also do not
// need to care, etc.
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Invalidating all %zu cached responses", "Invalidating",
mTransaction->LoggingSerialNumber(), mRequest->LoggingSerialNumber(),
mCachedResponses.size());
mCachedResponses.clear();
}
template <typename Condition>
void BackgroundCursorChild::DiscardCachedResponses(
const Condition& aConditionFunc) {
size_t discardedCount = 0;
while (!mCachedResponses.empty() &&
aConditionFunc(mCachedResponses.front())) {
mCachedResponses.pop_front();
++discardedCount;
}
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Discarded %zu cached responses, %zu remaining", "Discarded",
mTransaction->LoggingSerialNumber(), mRequest->LoggingSerialNumber(),
discardedCount, mCachedResponses.size());
}
void BackgroundCursorChild::HandleResponse(nsresult aResponse) {
AssertIsOnOwningThread();
MOZ_ASSERT(NS_FAILED(aResponse));
@ -3563,146 +3344,130 @@ void BackgroundCursorChild::HandleResponse(const void_t& aResponse) {
}
}
template <typename... Args>
void BackgroundCursorChild::HandleIndividualCursorResponse(
const bool aUseAsCurrentResult, Args&&... aArgs) {
if (mCursor) {
if (aUseAsCurrentResult) {
mCursor->Reset(std::forward<Args>(aArgs)...);
} else {
mCachedResponses.emplace_back(std::forward<Args>(aArgs)...);
}
} else {
MOZ_ASSERT(aUseAsCurrentResult);
// TODO: This looks particularly dangerous to me. Why do we need to
// have an extra newCursor of type RefPtr? Why can't we directly
// assign to mCursor? Why is mCursor not a RefPtr?
RefPtr<IDBCursor> newCursor =
IDBCursor::Create(this, std::forward<Args>(aArgs)...);
mCursor = newCursor;
}
}
template <typename T, typename Func>
void BackgroundCursorChild::HandleMultipleCursorResponses(
const nsTArray<T>& aResponses, const Func& aHandleRecord) {
void BackgroundCursorChild::HandleResponse(
const nsTArray<ObjectStoreCursorResponse>& aResponses) {
AssertIsOnOwningThread();
MOZ_ASSERT(mRequest);
MOZ_ASSERT(mTransaction);
MOZ_ASSERT(mObjectStore);
MOZ_ASSERT(!mStrongRequest);
MOZ_ASSERT(!mStrongCursor);
MOZ_ASSERT(aResponses.Length() > 0);
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Received %zu cursor responses", "Received",
mTransaction->LoggingSerialNumber(), mRequest->LoggingSerialNumber(),
aResponses.Length());
MOZ_ASSERT_IF(aResponses.Length() > 1, mCachedResponses.empty());
MOZ_ASSERT(aResponses.Length() == 1);
// XXX Fix this somehow...
auto& responses = const_cast<nsTArray<T>&>(aResponses);
auto& responses =
const_cast<nsTArray<ObjectStoreCursorResponse>&>(aResponses);
bool isFirst = true;
for (auto& response : responses) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Processing response for key %s", "Processing",
mTransaction->LoggingSerialNumber(), mRequest->LoggingSerialNumber(),
response.key().GetBuffer().get());
for (ObjectStoreCursorResponse& response : responses) {
StructuredCloneReadInfo cloneReadInfo(std::move(response.cloneInfo()));
cloneReadInfo.mDatabase = mTransaction->Database();
// TODO: At the moment, we only send a cursor request to the parent if
// requested by the user code. Therefore, the first result is always used as
// the current result, and the potential extra results are cached. If we
// extended this towards preloading in the background, all results might
// need to be cached.
aHandleRecord(/* aUseAsCurrentResult */ isFirst, response);
isFirst = false;
DeserializeStructuredCloneFiles(
mTransaction->Database(), response.cloneInfo().files(),
/* aForPreprocess */ false, cloneReadInfo.mFiles);
RefPtr<IDBCursor> newCursor;
if (mCursor) {
mCursor->Reset(std::move(response.key()), std::move(cloneReadInfo));
} else {
newCursor = IDBCursor::Create(this, std::move(response.key()),
std::move(cloneReadInfo));
mCursor = newCursor;
}
}
ResultHelper helper(mRequest, mTransaction, mCursor);
DispatchSuccessEvent(&helper);
}
// Note: the parameter type is an rvalue reference, since passing it by value
// yields a 'Type must not be used as parameter' error
StructuredCloneReadInfo BackgroundCursorChild::PrepareCloneReadInfo(
SerializedStructuredCloneReadInfo&& aCloneInfo) const {
StructuredCloneReadInfo cloneReadInfo(
std::forward<SerializedStructuredCloneReadInfo>(aCloneInfo));
void BackgroundCursorChild::HandleResponse(
const ObjectStoreKeyCursorResponse& aResponse) {
AssertIsOnOwningThread();
MOZ_ASSERT(mRequest);
MOZ_ASSERT(mTransaction);
MOZ_ASSERT(mObjectStore);
MOZ_ASSERT(!mStrongRequest);
MOZ_ASSERT(!mStrongCursor);
// XXX Fix this somehow...
auto& response = const_cast<ObjectStoreKeyCursorResponse&>(aResponse);
RefPtr<IDBCursor> newCursor;
if (mCursor) {
mCursor->Reset(std::move(response.key()));
} else {
newCursor = IDBCursor::Create(this, std::move(response.key()));
mCursor = newCursor;
}
ResultHelper helper(mRequest, mTransaction, mCursor);
DispatchSuccessEvent(&helper);
}
void BackgroundCursorChild::HandleResponse(
const IndexCursorResponse& aResponse) {
AssertIsOnOwningThread();
MOZ_ASSERT(mRequest);
MOZ_ASSERT(mTransaction);
MOZ_ASSERT(mIndex);
MOZ_ASSERT(!mStrongRequest);
MOZ_ASSERT(!mStrongCursor);
// XXX Fix this somehow...
auto& response = const_cast<IndexCursorResponse&>(aResponse);
StructuredCloneReadInfo cloneReadInfo(std::move(response.cloneInfo()));
cloneReadInfo.mDatabase = mTransaction->Database();
// TODO: This uses response.cloneInfo() after it was apparently moved
// above, which would be invalid. However, it was not really moved,
// since
// StructuredCloneReadInfo::StructuredCloneReadInfo(SerializedStructuredCloneReadInfo&&)
// does not touch 'files' at all. This is, however, confusing.
// Can't this be done in the constructor of StructuredCloneReadInfo as
// well?
// Note: this will be fixed in a subsequent patch for bug 1168606.
DeserializeStructuredCloneFiles(mTransaction->Database(), aCloneInfo.files(),
/* aForPreprocess */ false,
cloneReadInfo.mFiles);
DeserializeStructuredCloneFiles(
mTransaction->Database(), aResponse.cloneInfo().files(),
/* aForPreprocess */ false, cloneReadInfo.mFiles);
return cloneReadInfo;
RefPtr<IDBCursor> newCursor;
if (mCursor) {
mCursor->Reset(std::move(response.key()), std::move(response.sortKey()),
std::move(response.objectKey()), std::move(cloneReadInfo));
} else {
newCursor = IDBCursor::Create(
this, std::move(response.key()), std::move(response.sortKey()),
std::move(response.objectKey()), std::move(cloneReadInfo));
mCursor = newCursor;
}
ResultHelper helper(mRequest, mTransaction, mCursor);
DispatchSuccessEvent(&helper);
}
void BackgroundCursorChild::HandleResponse(
const nsTArray<ObjectStoreCursorResponse>& aResponses) {
AssertIsOnOwningThread();
MOZ_ASSERT(mObjectStore);
HandleMultipleCursorResponses(
aResponses, [this](const bool useAsCurrentResult,
ObjectStoreCursorResponse& response) {
// TODO: Maybe move the deserialization of the clone-read-info into the
// cursor, so that it is only done for records actually accessed, which
// might not be the case for all cached records.
HandleIndividualCursorResponse(
useAsCurrentResult, std::move(response.key()),
PrepareCloneReadInfo(std::move(response.cloneInfo())));
});
}
void BackgroundCursorChild::HandleResponse(
const nsTArray<ObjectStoreKeyCursorResponse>& aResponses) {
AssertIsOnOwningThread();
MOZ_ASSERT(mObjectStore);
HandleMultipleCursorResponses(
aResponses, [this](const bool useAsCurrentResult,
ObjectStoreKeyCursorResponse& response) {
HandleIndividualCursorResponse(useAsCurrentResult,
std::move(response.key()));
});
}
void BackgroundCursorChild::HandleResponse(
const nsTArray<IndexCursorResponse>& aResponses) {
const IndexKeyCursorResponse& aResponse) {
AssertIsOnOwningThread();
MOZ_ASSERT(mRequest);
MOZ_ASSERT(mTransaction);
MOZ_ASSERT(mIndex);
MOZ_ASSERT(!mStrongRequest);
MOZ_ASSERT(!mStrongCursor);
HandleMultipleCursorResponses(
aResponses,
[this](const bool useAsCurrentResult, IndexCursorResponse& response) {
HandleIndividualCursorResponse(
useAsCurrentResult, std::move(response.key()),
std::move(response.sortKey()), std::move(response.objectKey()),
PrepareCloneReadInfo(std::move(response.cloneInfo())));
});
}
// XXX Fix this somehow...
auto& response = const_cast<IndexKeyCursorResponse&>(aResponse);
void BackgroundCursorChild::HandleResponse(
const nsTArray<IndexKeyCursorResponse>& aResponses) {
AssertIsOnOwningThread();
MOZ_ASSERT(mIndex);
RefPtr<IDBCursor> newCursor;
HandleMultipleCursorResponses(
aResponses,
[this](const bool useAsCurrentResult, IndexKeyCursorResponse& response) {
HandleIndividualCursorResponse(
useAsCurrentResult, std::move(response.key()),
std::move(response.sortKey()), std::move(response.objectKey()));
});
if (mCursor) {
mCursor->Reset(std::move(response.key()), std::move(response.sortKey()),
std::move(response.objectKey()));
} else {
newCursor = IDBCursor::Create(this, std::move(response.key()),
std::move(response.sortKey()),
std::move(response.objectKey()));
mCursor = newCursor;
}
ResultHelper helper(mRequest, mTransaction, mCursor);
DispatchSuccessEvent(&helper);
}
void BackgroundCursorChild::ActorDestroy(ActorDestroyReason aWhy) {
@ -3713,7 +3478,7 @@ void BackgroundCursorChild::ActorDestroy(ActorDestroyReason aWhy) {
MaybeCollectGarbageOnIPCMessage();
if (mStrongRequest && !mStrongCursor && mTransaction) {
mTransaction->OnRequestFinished(/* aRequestCompletedSuccessfully */
mTransaction->OnRequestFinished(/* aActorDestroyedNormally */
aWhy == Deletion);
}
@ -3764,23 +3529,23 @@ mozilla::ipc::IPCResult BackgroundCursorChild::RecvResponse(
HandleResponse(aResponse.get_ArrayOfObjectStoreCursorResponse());
break;
case CursorResponse::TArrayOfObjectStoreKeyCursorResponse:
HandleResponse(aResponse.get_ArrayOfObjectStoreKeyCursorResponse());
case CursorResponse::TObjectStoreKeyCursorResponse:
HandleResponse(aResponse.get_ObjectStoreKeyCursorResponse());
break;
case CursorResponse::TArrayOfIndexCursorResponse:
HandleResponse(aResponse.get_ArrayOfIndexCursorResponse());
case CursorResponse::TIndexCursorResponse:
HandleResponse(aResponse.get_IndexCursorResponse());
break;
case CursorResponse::TArrayOfIndexKeyCursorResponse:
HandleResponse(aResponse.get_ArrayOfIndexKeyCursorResponse());
case CursorResponse::TIndexKeyCursorResponse:
HandleResponse(aResponse.get_IndexKeyCursorResponse());
break;
default:
MOZ_CRASH("Should never get here!");
}
transaction->OnRequestFinished(/* aRequestCompletedSuccessfully */ true);
transaction->OnRequestFinished(/* aActorDestroyedNormally */ true);
return IPC_OK();
}

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

@ -618,35 +618,12 @@ class BackgroundRequestChild final : public BackgroundRequestChildBase,
const PreprocessParams& aParams) override;
};
// TODO: Consider defining different subclasses for the different cursor types,
// possibly using the CRTP, which would remove the need for various case
// distinctions.
class BackgroundCursorChild final : public PBackgroundIDBCursorChild {
friend class BackgroundTransactionChild;
friend class BackgroundVersionChangeTransactionChild;
class DelayedActionRunnable;
struct CachedResponse {
CachedResponse() = delete;
CachedResponse(Key aKey, StructuredCloneReadInfo&& aCloneInfo);
CachedResponse(Key aKey, Key aLocaleAwareKey, Key aObjectStoreKey,
StructuredCloneReadInfo&& aCloneInfo);
explicit CachedResponse(Key aKey);
CachedResponse(Key aKey, Key aLocaleAwareKey, Key aObjectStoreKey);
CachedResponse(CachedResponse&& aOther) = default;
CachedResponse& operator=(CachedResponse&& aOther) = default;
CachedResponse(const CachedResponse& aOther) = delete;
CachedResponse& operator=(const CachedResponse& aOther) = delete;
Key mKey;
Key mLocaleAwareKey;
Key mObjectStoreKey;
StructuredCloneReadInfo mCloneInfo;
};
IDBRequest* mRequest;
IDBTransaction* mTransaction;
IDBObjectStore* mObjectStore;
@ -661,8 +638,6 @@ class BackgroundCursorChild final : public PBackgroundIDBCursorChild {
NS_DECL_OWNINGTHREAD
std::deque<CachedResponse> mCachedResponses, mDelayedResponses;
public:
BackgroundCursorChild(IDBRequest* aRequest, IDBObjectStore* aObjectStore,
Direction aDirection);
@ -675,16 +650,10 @@ class BackgroundCursorChild final : public PBackgroundIDBCursorChild {
}
void SendContinueInternal(const CursorRequestParams& aParams,
const Key& aCurrentKey,
const Key& aCurrentObjectStoreKey);
const Key& aCurrentKey);
void SendDeleteMeInternal();
void InvalidateCachedResponses();
template <typename Condition>
void DiscardCachedResponses(const Condition& aConditionFunc);
IDBRequest* GetRequest() const {
AssertIsOnOwningThread();
@ -714,30 +683,17 @@ class BackgroundCursorChild final : public PBackgroundIDBCursorChild {
// BackgroundVersionChangeTransactionChild.
~BackgroundCursorChild();
void CompleteContinueRequestFromCache();
void HandleResponse(nsresult aResponse);
void HandleResponse(const void_t& aResponse);
void HandleResponse(const nsTArray<ObjectStoreCursorResponse>& aResponses);
void HandleResponse(const nsTArray<ObjectStoreCursorResponse>& aResponse);
void HandleResponse(const nsTArray<ObjectStoreKeyCursorResponse>& aResponses);
void HandleResponse(const ObjectStoreKeyCursorResponse& aResponse);
void HandleResponse(const nsTArray<IndexCursorResponse>& aResponses);
void HandleResponse(const IndexCursorResponse& aResponse);
StructuredCloneReadInfo PrepareCloneReadInfo(
SerializedStructuredCloneReadInfo&& aCloneInfo) const;
template <typename T, typename Func>
void HandleMultipleCursorResponses(const nsTArray<T>& aResponses,
const Func& aHandleRecord);
void HandleResponse(const nsTArray<IndexKeyCursorResponse>& aResponses);
template <typename... Args>
void HandleIndividualCursorResponse(bool aUseAsCurrentResult,
Args&&... aArgs);
void HandleResponse(const IndexKeyCursorResponse& aResponse);
// IPDL methods are only called by IPDL.
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
@ -747,8 +703,8 @@ class BackgroundCursorChild final : public PBackgroundIDBCursorChild {
public:
// Force callers to use SendContinueInternal.
bool SendContinue(const CursorRequestParams& aParams, const Key& aCurrentKey,
const Key& aCurrentObjectStoreKey) = delete;
bool SendContinue(const CursorRequestParams& aParams,
const Key& aCurrentKey) = delete;
bool SendDeleteMe() = delete;
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -54,8 +54,6 @@ IDBCursor::IDBCursor(Type aType, BackgroundCursorChild* aBackgroundActor,
MOZ_ASSERT_IF(aType == Type_Index || aType == Type_IndexKey, mSourceIndex);
MOZ_ASSERT(mTransaction);
MOZ_ASSERT(!aKey.IsUnset());
mTransaction->RegisterCursor(this);
}
bool IDBCursor::IsLocaleAware() const {
@ -65,8 +63,6 @@ bool IDBCursor::IsLocaleAware() const {
IDBCursor::~IDBCursor() {
AssertIsOnOwningThread();
mTransaction->UnregisterCursor(this);
DropJSObjects();
if (mBackgroundActor) {
@ -258,8 +254,6 @@ IDBCursorDirection IDBCursor::GetDirection() const {
}
}
IDBCursor::Type IDBCursor::GetType() const { return mType; }
void IDBCursor::GetSource(OwningIDBObjectStoreOrIDBIndex& aSource) const {
AssertIsOnOwningThread();
@ -455,8 +449,7 @@ void IDBCursor::Continue(JSContext* aCx, JS::Handle<JS::Value> aKey,
IDB_LOG_STRINGIFY(key));
}
mBackgroundActor->SendContinueInternal(ContinueParams(key), mKey,
mPrimaryKey);
mBackgroundActor->SendContinueInternal(ContinueParams(key), Key());
mContinueCalled = true;
}
@ -562,7 +555,7 @@ void IDBCursor::ContinuePrimaryKey(JSContext* aCx, JS::Handle<JS::Value> aKey,
IDB_LOG_STRINGIFY(key), IDB_LOG_STRINGIFY(primaryKey));
mBackgroundActor->SendContinueInternal(
ContinuePrimaryKeyParams(key, primaryKey), mKey, mPrimaryKey);
ContinuePrimaryKeyParams(key, primaryKey), Key());
mContinueCalled = true;
}
@ -607,8 +600,7 @@ void IDBCursor::Advance(uint32_t aCount, ErrorResult& aRv) {
IDB_LOG_STRINGIFY(mSourceIndex), IDB_LOG_STRINGIFY(mDirection), aCount);
}
mBackgroundActor->SendContinueInternal(AdvanceParams(aCount), mKey,
mPrimaryKey);
mBackgroundActor->SendContinueInternal(AdvanceParams(aCount), Key());
mContinueCalled = true;
}
@ -639,8 +631,6 @@ already_AddRefed<IDBRequest> IDBCursor::Update(JSContext* aCx,
MOZ_ASSERT(!mKey.IsUnset());
MOZ_ASSERT_IF(mType == Type_Index, !mPrimaryKey.IsUnset());
mTransaction->InvalidateCursorCaches();
IDBObjectStore* objectStore;
if (mType == Type_ObjectStore) {
objectStore = mSourceObjectStore;
@ -749,8 +739,6 @@ already_AddRefed<IDBRequest> IDBCursor::Delete(JSContext* aCx,
MOZ_ASSERT(mType == Type_ObjectStore || mType == Type_Index);
MOZ_ASSERT(!mKey.IsUnset());
mTransaction->InvalidateCursorCaches();
IDBObjectStore* const objectStore = mType == Type_ObjectStore
? mSourceObjectStore.get()
: mSourceIndex->ObjectStore();
@ -849,15 +837,6 @@ void IDBCursor::Reset(Key&& aKey, Key&& aSortKey, Key&& aPrimaryKey) {
mHaveValue = !mKey.IsUnset();
}
void IDBCursor::InvalidateCachedResponses() {
AssertIsOnOwningThread();
// TODO: In what case would mBackgroundActor be nullptr?
if (mBackgroundActor) {
mBackgroundActor->InvalidateCachedResponses();
}
}
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBCursor)
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBCursor)

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

@ -33,9 +33,6 @@ namespace indexedDB {
class BackgroundCursorChild;
}
// TODO: Consider defining different subclasses for the different cursor types,
// possibly using the CRTP, which would remove the need for various case
// distinctions.
class IDBCursor final : public nsISupports, public nsWrapperCache {
public:
typedef indexedDB::Key Key;
@ -51,6 +48,7 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
DIRECTION_INVALID
};
private:
enum Type {
Type_ObjectStore,
Type_ObjectStoreKey,
@ -58,7 +56,6 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
Type_IndexKey,
};
private:
indexedDB::BackgroundCursorChild* mBackgroundActor;
// TODO: mRequest, mSourceObjectStore and mSourceIndex could be made const if
@ -77,8 +74,8 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
JS::Heap<JS::Value> mCachedValue;
Key mKey;
Key mSortKey; ///< AKA locale aware key/position elsewhere
Key mPrimaryKey; ///< AKA object store key/position elsewhere
Key mSortKey;
Key mPrimaryKey;
StructuredCloneReadInfo mCloneInfo;
const Type mType;
@ -123,8 +120,6 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
IDBCursorDirection GetDirection() const;
Type GetType() const;
void GetKey(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
@ -164,11 +159,6 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
mBackgroundActor = nullptr;
}
void InvalidateCachedResponses();
// Checks if this is a locale aware cursor (ie. the index's sortKey is unset)
bool IsLocaleAware() const;
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBCursor)
@ -182,6 +172,9 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
~IDBCursor();
// Checks if this is a locale aware cursor (ie. the index's sortKey is unset)
bool IsLocaleAware() const;
void DropJSObjects();
bool IsSourceDeleted() const;

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

@ -333,11 +333,6 @@ already_AddRefed<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly,
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange));
}
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
transaction->InvalidateCursorCaches();
transaction->StartRequest(request, params);
return request.forget();
@ -408,11 +403,6 @@ already_AddRefed<IDBRequest> IDBIndex::GetAllInternal(
IDB_LOG_STRINGIFY(aLimit));
}
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
transaction->InvalidateCursorCaches();
transaction->StartRequest(request, params);
return request.forget();
@ -479,7 +469,7 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"openCursor(%s, %s)",
"IDBIndex.openCursor()", transaction->LoggingSerialNumber(),
"IDBObjectStore.openCursor()", transaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(transaction->Database()),
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
@ -490,11 +480,6 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
BackgroundCursorChild* const actor =
new BackgroundCursorChild(request, this, direction);
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
transaction->InvalidateCursorCaches();
mObjectStore->Transaction()->OpenCursor(actor, params);
return request.forget();
@ -538,17 +523,12 @@ already_AddRefed<IDBRequest> IDBIndex::Count(JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"count(%s)",
"IDBIndex.count()", transaction->LoggingSerialNumber(),
"IDBObjectStore.count()", transaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(transaction->Database()),
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange));
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
transaction->InvalidateCursorCaches();
transaction->StartRequest(request, params);
return request.forget();

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

@ -1675,8 +1675,6 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
mTransaction->StartRequest(request, params);
mTransaction->InvalidateCursorCaches();
return request.forget();
}
@ -1742,11 +1740,6 @@ already_AddRefed<IDBRequest> IDBObjectStore::GetAllInternal(
IDB_LOG_STRINGIFY(keyRange), IDB_LOG_STRINGIFY(aLimit));
}
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
mTransaction->InvalidateCursorCaches();
mTransaction->StartRequest(request, params);
return request.forget();
@ -1783,8 +1776,6 @@ already_AddRefed<IDBRequest> IDBObjectStore::Clear(JSContext* aCx,
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(mTransaction), IDB_LOG_STRINGIFY(this));
mTransaction->InvalidateCursorCaches();
mTransaction->StartRequest(request, params);
return request.forget();
@ -1974,11 +1965,6 @@ already_AddRefed<IDBRequest> IDBObjectStore::GetInternal(
IDB_LOG_STRINGIFY(mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange));
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
mTransaction->InvalidateCursorCaches();
mTransaction->StartRequest(request, params);
return request.forget();
@ -2026,7 +2012,7 @@ already_AddRefed<IDBRequest> IDBObjectStore::DeleteInternal(
if (!aFromCursor) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).delete(%s)",
"IDBObjectStore.delete()", mTransaction->LoggingSerialNumber(),
" IDBObjectStore.delete()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(mTransaction), IDB_LOG_STRINGIFY(this),
@ -2035,8 +2021,6 @@ already_AddRefed<IDBRequest> IDBObjectStore::DeleteInternal(
mTransaction->StartRequest(request, params);
mTransaction->InvalidateCursorCaches();
return request.forget();
}
@ -2253,11 +2237,6 @@ already_AddRefed<IDBRequest> IDBObjectStore::Count(JSContext* aCx,
IDB_LOG_STRINGIFY(mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange));
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
mTransaction->InvalidateCursorCaches();
mTransaction->StartRequest(request, params);
return request.forget();
@ -2334,11 +2313,6 @@ already_AddRefed<IDBRequest> IDBObjectStore::OpenCursorInternal(
BackgroundCursorChild* const actor =
new BackgroundCursorChild(request, this, direction);
// TODO: This is necessary to preserve request ordering only. Proper
// sequencing of requests should be done in a more sophisticated manner that
// doesn't require invalidating cursor caches (Bug 1580499).
mTransaction->InvalidateCursorCaches();
mTransaction->OpenCursor(actor, params);
return request.forget();

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

@ -338,7 +338,7 @@ void IDBTransaction::OnNewRequest() {
++mPendingRequestCount;
}
void IDBTransaction::OnRequestFinished(bool aRequestCompletedSuccessfully) {
void IDBTransaction::OnRequestFinished(bool aActorDestroyedNormally) {
AssertIsOnOwningThread();
MOZ_ASSERT(mPendingRequestCount);
@ -347,7 +347,7 @@ void IDBTransaction::OnRequestFinished(bool aRequestCompletedSuccessfully) {
if (!mPendingRequestCount) {
mReadyState = COMMITTING;
if (aRequestCompletedSuccessfully) {
if (aActorDestroyedNormally) {
if (NS_SUCCEEDED(mAbortCode)) {
SendCommit();
} else {
@ -797,27 +797,6 @@ int64_t IDBTransaction::NextIndexId() {
return mNextIndexId++;
}
void IDBTransaction::InvalidateCursorCaches() {
AssertIsOnOwningThread();
for (auto* const cursor : mCursors) {
cursor->InvalidateCachedResponses();
}
}
void IDBTransaction::RegisterCursor(IDBCursor* const aCursor) {
AssertIsOnOwningThread();
mCursors.AppendElement(aCursor);
}
void IDBTransaction::UnregisterCursor(IDBCursor* const aCursor) {
AssertIsOnOwningThread();
DebugOnly<bool> removed = mCursors.RemoveElement(aCursor);
MOZ_ASSERT(removed);
}
nsIGlobalObject* IDBTransaction::GetParentObject() const {
AssertIsOnOwningThread();

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

@ -25,7 +25,6 @@ namespace dom {
class DOMException;
class DOMStringList;
class IDBCursor;
class IDBDatabase;
class IDBObjectStore;
class IDBOpenDBRequest;
@ -68,7 +67,6 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
nsTArray<RefPtr<IDBObjectStore>> mObjectStores;
nsTArray<RefPtr<IDBObjectStore>> mDeletedObjectStores;
RefPtr<StrongWorkerRef> mWorkerRef;
nsTArray<IDBCursor*> mCursors;
// Tagged with mMode. If mMode is VERSION_CHANGE then mBackgroundActor will be
// a BackgroundVersionChangeTransactionChild. Otherwise it will be a
@ -252,10 +250,6 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
// Only for VERSION_CHANGE transactions.
int64_t NextIndexId();
void InvalidateCursorCaches();
void RegisterCursor(IDBCursor* aCursor);
void UnregisterCursor(IDBCursor* aCursor);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIRUNNABLE
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, DOMEventTargetHelper)
@ -285,7 +279,7 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
void OnNewRequest();
void OnRequestFinished(bool aRequestCompletedSuccessfully);
void OnRequestFinished(bool aActorDestroyedNormally);
};
} // namespace dom

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

@ -112,8 +112,6 @@ const int32_t kDefaultDataThresholdBytes = 1024 * 1024; // 1MB
// The maximal size of a serialized object to be transfered through IPC.
const int32_t kDefaultMaxSerializedMsgSize = IPC::Channel::kMaximumMessageSize;
const int32_t kDefaultMaxPreloadExtraRecords = 0;
#define IDB_PREF_BRANCH_ROOT "dom.indexedDB."
const char kTestingPref[] = IDB_PREF_BRANCH_ROOT "testing";
@ -125,8 +123,6 @@ const char kPrefMaxSerilizedMsgSize[] =
const char kPrefErrorEventToSelfError[] =
IDB_PREF_BRANCH_ROOT "errorEventToSelfError";
const char kPreprocessingPref[] = IDB_PREF_BRANCH_ROOT "preprocessing";
const char kPrefMaxPreloadExtraRecords[] =
IDB_PREF_BRANCH_ROOT "maxPreloadExtraRecords";
#define IDB_PREF_LOGGING_BRANCH_ROOT IDB_PREF_BRANCH_ROOT "logging."
@ -152,7 +148,6 @@ Atomic<bool> gPrefErrorEventToSelfError(false);
Atomic<int32_t> gDataThresholdBytes(0);
Atomic<int32_t> gMaxSerializedMsgSize(0);
Atomic<bool> gPreprocessingEnabled(false);
Atomic<int32_t> gMaxPreloadExtraRecords(0);
void AtomicBoolPrefChangedCallback(const char* aPrefName, void* aBool) {
MOZ_ASSERT(NS_IsMainThread());
@ -188,21 +183,6 @@ void MaxSerializedMsgSizePrefChangeCallback(const char* aPrefName,
MOZ_ASSERT(gMaxSerializedMsgSize > 0);
}
void MaxPreloadExtraRecordsPrefChangeCallback(const char* aPrefName,
void* aClosure) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!strcmp(aPrefName, kPrefMaxPreloadExtraRecords));
MOZ_ASSERT(!aClosure);
gMaxPreloadExtraRecords =
Preferences::GetInt(aPrefName, kDefaultMaxPreloadExtraRecords);
MOZ_ASSERT(gMaxPreloadExtraRecords >= 0);
// TODO: We could also allow setting a negative value to preload all available
// records, but this doesn't seem to be too useful in general, and it would
// require adaptations in ActorsParent.cpp
}
} // namespace
IndexedDatabaseManager::IndexedDatabaseManager()
@ -305,9 +285,6 @@ nsresult IndexedDatabaseManager::Init() {
kPreprocessingPref,
&gPreprocessingEnabled);
Preferences::RegisterCallbackAndCall(MaxPreloadExtraRecordsPrefChangeCallback,
kPrefMaxPreloadExtraRecords);
nsAutoCString acceptLang;
Preferences::GetLocalizedCString("intl.accept_languages", acceptLang);
@ -656,15 +633,6 @@ bool IndexedDatabaseManager::PreprocessingEnabled() {
return gPreprocessingEnabled;
}
// static
int32_t IndexedDatabaseManager::MaxPreloadExtraRecords() {
MOZ_ASSERT(gDBManager,
"MaxPreloadExtraRecords() called before indexedDB has been "
"initialized!");
return gMaxPreloadExtraRecords;
}
void IndexedDatabaseManager::ClearBackgroundActor() {
MOZ_ASSERT(NS_IsMainThread());

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

@ -97,10 +97,6 @@ class IndexedDatabaseManager final {
static bool PreprocessingEnabled();
// The maximum number of extra entries to preload in an Cursor::OpenOp or
// Cursor::ContinueOp.
static int32_t MaxPreloadExtraRecords();
void ClearBackgroundActor();
already_AddRefed<FileManager> GetFileManager(PersistenceType aPersistenceType,

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

@ -73,15 +73,14 @@ struct IndexKeyCursorResponse
Key objectKey;
};
// TODO: All cursor responses must be arrays!
union CursorResponse
{
void_t;
nsresult;
ObjectStoreCursorResponse[];
ObjectStoreKeyCursorResponse[];
IndexCursorResponse[];
IndexKeyCursorResponse[];
ObjectStoreKeyCursorResponse;
IndexCursorResponse;
IndexKeyCursorResponse;
};
protocol PBackgroundIDBCursor
@ -91,8 +90,7 @@ protocol PBackgroundIDBCursor
parent:
async DeleteMe();
async Continue(CursorRequestParams params, Key currentKey,
Key currentObjectStoreKey);
async Continue(CursorRequestParams params, Key currentKey);
child:
async __delete__();