Bug 1497007 - Added explaining comments. r=ttung,asuth

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-11-11 08:25:20 +00:00
parent 1bf29f747f
commit 19128f8aae
3 changed files with 24 additions and 6 deletions

View File

@ -732,6 +732,8 @@ void IDBDatabase::AbortTransactions(bool aShouldWarn) {
aDatabase->mTransactions;
if (!transactionTable.Count()) {
// Return early as an optimization, the remainder is a no-op in this
// case.
return;
}
@ -754,6 +756,8 @@ void IDBDatabase::AbortTransactions(bool aShouldWarn) {
MOZ_ASSERT(transactionsToAbort.Length() <= transactionTable.Count());
if (transactionsToAbort.IsEmpty()) {
// Return early as an optimization, the remainder is a no-op in this
// case.
return;
}

View File

@ -118,6 +118,8 @@ IDBTransaction::IDBTransaction(IDBDatabase* const aDatabase,
MOZ_ASSERT(aDatabase);
aDatabase->AssertIsOnOwningThread();
// This also nulls mBackgroundActor.mVersionChangeBackgroundActor, so this is
// valid also for mMode == VERSION_CHANGE.
mBackgroundActor.mNormalBackgroundActor = nullptr;
#ifdef DEBUG

View File

@ -86,8 +86,16 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
int64_t mNextObjectStoreId;
int64_t mNextIndexId;
nsresult mAbortCode;
uint32_t mPendingRequestCount;
nsresult mAbortCode; ///< The result that caused the transaction to be
///< aborted, or NS_OK if not aborted.
///< NS_ERROR_DOM_INDEXEDDB_ABORT_ERR indicates that the
///< user explicitly requested aborting. Should be
///< renamed to mResult or so, because it is actually
///< used to check if the transaction has been aborted.
uint32_t mPendingRequestCount; ///< Counted via OnNewRequest and
///< OnRequestFinished, so that the
///< transaction can auto-commit when the last
///< pending request finished.
const nsString mFilename;
const uint32_t mLineNo;
@ -96,8 +104,11 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
ReadyState mReadyState;
const Mode mMode;
bool mCreating;
bool mRegistered;
bool mCreating; ///< Set between successful creation until the transaction
///< has run on the event-loop.
bool mRegistered; ///< Whether mDatabase->RegisterTransaction() has been
///< called (which may not be the case if construction was
///< incomplete).
bool mAbortedByScript;
bool mNotedActiveTransaction;
@ -198,6 +209,7 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
IDBDatabase* Db() const { return Database(); }
// Only for use by ProfilerHelpers.h
const nsTArray<nsString>& ObjectStoreNamesInternal() const {
AssertIsOnOwningThread();
return mObjectStoreNames;
@ -262,8 +274,8 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, DOMEventTargetHelper)
// nsWrapperCache
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
// EventTarget
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;