Backed out 4 changesets (bug 1650076) for build bustages on indexedDB/ProfilerHelpers.h. CLOSED TREE

Backed out changeset 42951b61e9dc (bug 1650076)
Backed out changeset 18b34fb0ddbd (bug 1650076)
Backed out changeset 1d378f2af866 (bug 1650076)
Backed out changeset 42df520d1cff (bug 1650076)
This commit is contained in:
Cosmin Sabou 2020-07-03 11:49:58 +03:00
Родитель 47af2fe80f
Коммит a40ede8ab7
16 изменённых файлов: 459 добавлений и 541 удалений

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

@ -53,7 +53,6 @@
#include "PermissionRequestBase.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "ThreadLocal.h"
#ifdef DEBUG
# include "IndexedDatabaseManager.h"
@ -93,9 +92,14 @@ const uint32_t kFileCopyBufferSize = 32768;
******************************************************************************/
ThreadLocal::ThreadLocal(const nsID& aBackgroundChildLoggingId)
: mLoggingInfo(aBackgroundChildLoggingId, 1, -1, 1),
mLoggingIdString(aBackgroundChildLoggingId) {
: mLoggingInfo(aBackgroundChildLoggingId, 1, -1, 1) {
MOZ_COUNT_CTOR(mozilla::dom::indexedDB::ThreadLocal);
// NSID_LENGTH counts the null terminator, SetLength() does not.
mLoggingIdString.SetLength(NSID_LENGTH - 1);
aBackgroundChildLoggingId.ToProvidedString(
*reinterpret_cast<char(*)[NSID_LENGTH]>(mLoggingIdString.BeginWriting()));
}
ThreadLocal::~ThreadLocal() {
@ -2973,7 +2977,7 @@ void BackgroundCursorChild<CursorType>::SendContinueInternal(
if (discard) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Continue to key %s, discarding cached key %s/%s",
"Continue, discarding%.0s%.0s%.0s", transactionSerialNumber,
"Continue, discarding", transactionSerialNumber,
requestSerialNumber, key.GetBuffer().get(),
cachedSortKey.GetBuffer().get(),
currentCachedResponse.GetObjectStoreKeyForLogging());
@ -2981,7 +2985,7 @@ void BackgroundCursorChild<CursorType>::SendContinueInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Continue to key %s, keeping cached key %s/%s and "
"further",
"Continue, keeping%.0s%.0s%.0s", transactionSerialNumber,
"Continue, keeping", transactionSerialNumber,
requestSerialNumber, key.GetBuffer().get(),
cachedSortKey.GetBuffer().get(),
currentCachedResponse.GetObjectStoreKeyForLogging());
@ -3029,7 +3033,7 @@ void BackgroundCursorChild<CursorType>::SendContinueInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Continue to key %s with primary key %s, discarding "
"cached key %s with cached primary key %s",
"Continue, discarding%.0s%.0s%.0s%.0s", transactionSerialNumber,
"Continue, discarding", transactionSerialNumber,
requestSerialNumber, key.GetBuffer().get(),
primaryKey.GetBuffer().get(), cachedSortKey.GetBuffer().get(),
cachedSortPrimaryKey.GetBuffer().get());
@ -3037,7 +3041,7 @@ void BackgroundCursorChild<CursorType>::SendContinueInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Continue to key %s with primary key %s, keeping "
"cached key %s with cached primary key %s and further",
"Continue, keeping%.0s%.0s%.0s%.0s", transactionSerialNumber,
"Continue, keeping", transactionSerialNumber,
requestSerialNumber, key.GetBuffer().get(),
primaryKey.GetBuffer().get(), cachedSortKey.GetBuffer().get(),
cachedSortPrimaryKey.GetBuffer().get());
@ -3055,7 +3059,7 @@ void BackgroundCursorChild<CursorType>::SendContinueInternal(
case CursorRequestParams::TAdvanceParams: {
uint32_t& advanceCount = params.get_AdvanceParams().count();
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Advancing %" PRIu32 " records", "Advancing %" PRIu32,
"PRELOAD: Advancing %" PRIu32 " records", "Advancing",
mTransaction->LoggingSerialNumber(),
GetRequest()->LoggingSerialNumber(), advanceCount);
@ -3126,8 +3130,8 @@ void BackgroundCursorChild<CursorType>::CompleteContinueRequestFromCache() {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Consumed 1 cached response, %zu cached responses remaining",
"Consumed cached response, %zu remaining",
mTransaction->LoggingSerialNumber(), GetRequest()->LoggingSerialNumber(),
"Consumed cached response", mTransaction->LoggingSerialNumber(),
GetRequest()->LoggingSerialNumber(),
mDelayedResponses.size() + mCachedResponses.size());
SetResultAndDispatchSuccessEvent(
@ -3174,7 +3178,7 @@ void BackgroundCursorChild<CursorType>::InvalidateCachedResponses() {
// need to care, etc.
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Invalidating all %zu cached responses", "Invalidating %zu",
"PRELOAD: Invalidating all %zu cached responses", "Invalidating",
mTransaction->LoggingSerialNumber(), GetRequest()->LoggingSerialNumber(),
mCachedResponses.size());
@ -3206,10 +3210,9 @@ void BackgroundCursorChild<CursorType>::DiscardCachedResponses(
++discardedCount;
}
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Discarded %zu cached responses, %zu remaining",
"Discarded %zu; remaining %zu", mTransaction->LoggingSerialNumber(),
GetRequest()->LoggingSerialNumber(), discardedCount,
mCachedResponses.size());
"PRELOAD: Discarded %zu cached responses, %zu remaining", "Discarded",
mTransaction->LoggingSerialNumber(), GetRequest()->LoggingSerialNumber(),
discardedCount, mCachedResponses.size());
}
void BackgroundCursorChildBase::HandleResponse(nsresult aResponse) {
@ -3289,7 +3292,7 @@ void BackgroundCursorChild<CursorType>::HandleMultipleCursorResponses(
MOZ_ASSERT(aResponses.Length() > 0);
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Received %zu cursor responses", "Received %zu",
"PRELOAD: Received %zu cursor responses", "Received",
mTransaction->LoggingSerialNumber(), GetRequest()->LoggingSerialNumber(),
aResponses.Length());
MOZ_ASSERT_IF(aResponses.Length() > 1, mCachedResponses.empty());
@ -3301,7 +3304,7 @@ void BackgroundCursorChild<CursorType>::HandleMultipleCursorResponses(
bool isFirst = true;
for (auto& response : aResponses) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"PRELOAD: Processing response for key %s", "Processing%.0s",
"PRELOAD: Processing response for key %s", "Processing",
mTransaction->LoggingSerialNumber(),
GetRequest()->LoggingSerialNumber(), response.key().GetBuffer().get());

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

@ -69,6 +69,77 @@ namespace mozilla {
namespace dom {
namespace indexedDB {
class ThreadLocal {
friend class DefaultDelete<ThreadLocal>;
friend IDBFactory;
LoggingInfo mLoggingInfo;
Maybe<IDBTransaction&> mCurrentTransaction;
nsCString mLoggingIdString;
NS_DECL_OWNINGTHREAD
public:
ThreadLocal() = delete;
ThreadLocal(const ThreadLocal& aOther) = delete;
void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(ThreadLocal); }
const LoggingInfo& GetLoggingInfo() const {
AssertIsOnOwningThread();
return mLoggingInfo;
}
const nsID& Id() const {
AssertIsOnOwningThread();
return mLoggingInfo.backgroundChildLoggingId();
}
const nsCString& IdString() const {
AssertIsOnOwningThread();
return mLoggingIdString;
}
int64_t NextTransactionSN(IDBTransaction::Mode aMode) {
AssertIsOnOwningThread();
MOZ_ASSERT(mLoggingInfo.nextTransactionSerialNumber() < INT64_MAX);
MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() >
INT64_MIN);
if (aMode == IDBTransaction::Mode::VersionChange) {
return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--;
}
return mLoggingInfo.nextTransactionSerialNumber()++;
}
uint64_t NextRequestSN() {
AssertIsOnOwningThread();
MOZ_ASSERT(mLoggingInfo.nextRequestSerialNumber() < UINT64_MAX);
return mLoggingInfo.nextRequestSerialNumber()++;
}
void SetCurrentTransaction(Maybe<IDBTransaction&> aCurrentTransaction) {
AssertIsOnOwningThread();
mCurrentTransaction = aCurrentTransaction;
}
Maybe<IDBTransaction&> MaybeCurrentTransactionRef() const {
AssertIsOnOwningThread();
return mCurrentTransaction;
}
private:
explicit ThreadLocal(const nsID& aBackgroundChildLoggingId);
~ThreadLocal();
};
class BackgroundFactoryChild final : public PBackgroundIDBFactoryChild {
friend class mozilla::ipc::BackgroundChildImpl;
friend IDBFactory;

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

@ -9922,7 +9922,7 @@ struct CommonPopulateResponseHelper {
}
IDB_LOG_MARK_PARENT_TRANSACTION_REQUEST(
"PRELOAD: Populating response with key %s", "Populating%.0s",
"PRELOAD: Populating response with key %s", "Populating",
IDB_LOG_ID_STRING(mOp.BackgroundChildLoggingId()),
mOp.TransactionLoggingSerialNumber(), mOp.LoggingSerialNumber(),
mPosition.GetBuffer().get());
@ -26490,7 +26490,7 @@ void CursorOpBaseHelperBase<CursorType>::PopulateExtraResponses(
IDB_LOG_MARK_PARENT_TRANSACTION_REQUEST(
"PRELOAD: %s: Dropping entries because maximum message size is "
"exceeded: %" PRIu32 "/%zu bytes",
"%.0s Dropping too large (%" PRIu32 "/%zu)",
"Dropping too large",
IDB_LOG_ID_STRING(mOp.mBackgroundChildLoggingId),
mOp.mTransactionLoggingSerialNumber, mOp.mLoggingSerialNumber,
aOperation.get(), extraCount, accumulatedResponseSize);
@ -26504,8 +26504,7 @@ void CursorOpBaseHelperBase<CursorType>::PopulateExtraResponses(
IDB_LOG_MARK_PARENT_TRANSACTION_REQUEST(
"PRELOAD: %s: Number of extra results populated: %" PRIu32 "/%" PRIu32,
"%.0s Populated (%" PRIu32 "/%" PRIu32 ")",
IDB_LOG_ID_STRING(mOp.mBackgroundChildLoggingId),
"Populated", IDB_LOG_ID_STRING(mOp.mBackgroundChildLoggingId),
mOp.mTransactionLoggingSerialNumber, mOp.mLoggingSerialNumber,
aOperation.get(), extraCount, aMaxExtraCount);
}

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

@ -397,18 +397,16 @@ void IDBTypedCursor<CursorType>::Continue(JSContext* const aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"cursor(%s).continue(%s)",
"IDBCursor.continue(%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"IDBCursor.continue()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(mSource),
IDB_LOG_STRINGIFY(mDirection), IDB_LOG_STRINGIFY(key));
} else {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"index(%s).cursor(%s).continue(%s)",
"IDBCursor.continue(%.0s%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"IDBCursor.continue()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction),
IDB_LOG_STRINGIFY(GetSourceRef().ObjectStore()),
IDB_LOG_STRINGIFY(mSource), IDB_LOG_STRINGIFY(mDirection),
@ -513,9 +511,8 @@ void IDBTypedCursor<CursorType>::ContinuePrimaryKey(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"index(%s).cursor(%s).continuePrimaryKey(%s, %s)",
"IDBCursor.continuePrimaryKey(%.0s%.0s%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"IDBCursor.continuePrimaryKey()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction),
IDB_LOG_STRINGIFY(&GetSourceObjectStoreRef()),
IDB_LOG_STRINGIFY(mSource), IDB_LOG_STRINGIFY(mDirection),
@ -554,19 +551,17 @@ void IDBTypedCursor<CursorType>::Advance(const uint32_t aCount,
if constexpr (IsObjectStoreCursor) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"cursor(%s).advance(%" PRIi32 ")",
"IDBCursor.advance(%.0s%.0s%.0s%.0s%" PRIi32 ")",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"cursor(%s).advance(%ld)",
"IDBCursor.advance()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(mSource),
IDB_LOG_STRINGIFY(mDirection), aCount);
} else {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"index(%s).cursor(%s).advance(%" PRIi32 ")",
"IDBCursor.advance(%.0s%.0s%.0s%.0s%.0s%" PRIi32 ")",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"index(%s).cursor(%s).advance(%ld)",
"IDBCursor.advance()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction),
IDB_LOG_STRINGIFY(GetSourceRef().ObjectStore()),
IDB_LOG_STRINGIFY(mSource), IDB_LOG_STRINGIFY(mDirection), aCount);
@ -662,8 +657,8 @@ RefPtr<IDBRequest> IDBTypedCursor<CursorType>::Update(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"cursor(%s).update(%s)",
"IDBCursor.update(%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBCursor.update()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(&objectStore),
IDB_LOG_STRINGIFY(mDirection),
@ -672,8 +667,8 @@ RefPtr<IDBRequest> IDBTypedCursor<CursorType>::Update(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"index(%s).cursor(%s).update(%s)",
"IDBCursor.update(%.0s%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBCursor.update()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(&objectStore),
IDB_LOG_STRINGIFY(mSource), IDB_LOG_STRINGIFY(mDirection),
@ -734,8 +729,8 @@ RefPtr<IDBRequest> IDBTypedCursor<CursorType>::Delete(JSContext* const aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"cursor(%s).delete(%s)",
"IDBCursor.delete(%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBCursor.delete()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(&objectStore),
IDB_LOG_STRINGIFY(mDirection),
@ -744,8 +739,8 @@ RefPtr<IDBRequest> IDBTypedCursor<CursorType>::Delete(JSContext* const aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"index(%s).cursor(%s).delete(%s)",
"IDBCursor.delete(%.0s%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBCursor.delete()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(&objectStore),
IDB_LOG_STRINGIFY(mSource), IDB_LOG_STRINGIFY(mDirection),

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

@ -417,10 +417,9 @@ RefPtr<IDBObjectStore> IDBDatabase::CreateObjectStore(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).createObjectStore(%s)",
"IDBDatabase.createObjectStore(%.0s%.0s%.0s)",
transaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(*transaction),
IDB_LOG_STRINGIFY(objectStore));
"IDBDatabase.createObjectStore()", transaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(*transaction), IDB_LOG_STRINGIFY(objectStore));
return objectStore;
}
@ -467,10 +466,9 @@ void IDBDatabase::DeleteObjectStore(const nsAString& aName, ErrorResult& aRv) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).deleteObjectStore(\"%s\")",
"IDBDatabase.deleteObjectStore(%.0s%.0s%.0s)",
transaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(*transaction),
NS_ConvertUTF16toUTF8(aName).get());
"IDBDatabase.deleteObjectStore()", transaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(*transaction), NS_ConvertUTF16toUTF8(aName).get());
}
RefPtr<IDBTransaction> IDBDatabase::Transaction(
@ -605,7 +603,7 @@ RefPtr<IDBTransaction> IDBDatabase::Transaction(
new BackgroundTransactionChild(transaction.clonePtr());
IDB_LOG_MARK_CHILD_TRANSACTION(
"database(%s).transaction(%s)", "IDBDatabase.transaction(%.0s%.0s)",
"database(%s).transaction(%s)", "IDBDatabase.transaction()",
transaction->LoggingSerialNumber(), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(*transaction));
@ -664,9 +662,9 @@ RefPtr<IDBRequest> IDBDatabase::CreateMutableFile(
new BackgroundDatabaseRequestChild(this, request);
IDB_LOG_MARK_CHILD_REQUEST(
"database(%s).createMutableFile(%s)",
"IDBDatabase.createMutableFile(%.0s%.0s)", request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(this), NS_ConvertUTF16toUTF8(aName).get());
"database(%s).createMutableFile(%s)", "IDBDatabase.createMutableFile()",
request->LoggingSerialNumber(), IDB_LOG_STRINGIFY(this),
NS_ConvertUTF16toUTF8(aName).get());
mBackgroundActor->SendPBackgroundIDBDatabaseRequestConstructor(actor, params);

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

@ -36,7 +36,6 @@
#include "nsServiceManagerUtils.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "ThreadLocal.h"
// Include this last to avoid path problems on Windows.
#include "ActorsChild.h"
@ -697,11 +696,11 @@ RefPtr<IDBOpenDBRequest> IDBFactory::OpenInternal(
if (aDeleting) {
IDB_LOG_MARK_CHILD_REQUEST(
"indexedDB.deleteDatabase(\"%s\")", "IDBFactory.deleteDatabase(%.0s)",
"indexedDB.deleteDatabase(\"%s\")", "IDBFactory.deleteDatabase()",
request->LoggingSerialNumber(), NS_ConvertUTF16toUTF8(aName).get());
} else {
IDB_LOG_MARK_CHILD_REQUEST(
"indexedDB.open(\"%s\", %s)", "IDBFactory.open(%.0s%.0s)",
"indexedDB.open(\"%s\", %s)", "IDBFactory.open()",
request->LoggingSerialNumber(), NS_ConvertUTF16toUTF8(aName).get(),
IDB_LOG_STRINGIFY(aVersion));
}

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

@ -7,7 +7,6 @@
#include "IDBIndex.h"
#include "IDBCursorType.h"
#include "IDBDatabase.h"
#include "IDBEvents.h"
#include "IDBKeyRange.h"
#include "IDBObjectStore.h"
@ -213,11 +212,10 @@ void IDBIndex::SetName(const nsAString& aName, ErrorResult& aRv) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"rename(%s)",
"IDBIndex.rename(%.0s%.0s%.0s%.0s%.0s)",
transaction.LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(transaction.Database()), IDB_LOG_STRINGIFY(transaction),
IDB_LOG_STRINGIFY(mObjectStore), loggingOldIndex.get(),
IDB_LOG_STRINGIFY(this));
"IDBIndex.rename()", transaction.LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(transaction.Database()),
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
loggingOldIndex.get(), IDB_LOG_STRINGIFY(this));
mObjectStore->MutableTransactionRef().RenameIndex(mObjectStore, indexId,
aName);
@ -355,8 +353,8 @@ RefPtr<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly, JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"getKey(%s)",
"IDBIndex.getKey(%.0s%.0s%.0s%.0s%.0s)",
transaction.LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBIndex.getKey()", 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));
@ -364,7 +362,7 @@ RefPtr<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly, JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"get(%s)",
"IDBIndex.get(%.0s%.0s%.0s%.0s%.0s)", transaction.LoggingSerialNumber(),
"IDBIndex.get()", transaction.LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(transaction.Database()),
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
@ -430,8 +428,8 @@ RefPtr<IDBRequest> IDBIndex::GetAllInternal(bool aKeysOnly, JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"getAllKeys(%s, %s)",
"IDBIndex.getAllKeys(%.0s%.0s%.0s%.0s%.0s%.0s)",
transaction.LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBIndex.getAllKeys()", 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),
@ -440,8 +438,8 @@ RefPtr<IDBRequest> IDBIndex::GetAllInternal(bool aKeysOnly, JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"getAll(%s, %s)",
"IDBIndex.getAll(%.0s%.0s%.0s%.0s%.0s%.0s)",
transaction.LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBIndex.getAll()", 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),
@ -508,8 +506,8 @@ RefPtr<IDBRequest> IDBIndex::OpenCursorInternal(bool aKeysOnly, JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"openKeyCursor(%s, %s)",
"IDBIndex.openKeyCursor(%.0s%.0s%.0s%.0s%.0s%.0s)",
transaction.LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBIndex.openKeyCursor()", 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),
@ -518,8 +516,8 @@ RefPtr<IDBRequest> IDBIndex::OpenCursorInternal(bool aKeysOnly, JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"openCursor(%s, %s)",
"IDBIndex.openCursor(%.0s%.0s%.0s%.0s%.0s%.0s)",
transaction.LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBIndex.openCursor()", 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),
@ -581,7 +579,7 @@ RefPtr<IDBRequest> IDBIndex::Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"count(%s)",
"IDBIndex.count(%.0s%.0s%.0s%.0s%.0s)", transaction.LoggingSerialNumber(),
"IDBIndex.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));

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

@ -907,16 +907,16 @@ RefPtr<IDBRequest> IDBObjectStore::AddOrPut(JSContext* aCx,
if (aOverwrite) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).put(%s)",
"IDBObjectStore.put(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.put()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(key));
} else {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).add(%s)",
"IDBObjectStore.add(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.add()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(key));
@ -975,8 +975,8 @@ RefPtr<IDBRequest> IDBObjectStore::GetAllInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"getAllKeys(%s, %s)",
"IDBObjectStore.getAllKeys(%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.getAllKeys()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange), IDB_LOG_STRINGIFY(aLimit));
@ -984,8 +984,8 @@ RefPtr<IDBRequest> IDBObjectStore::GetAllInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"getAll(%s, %s)",
"IDBObjectStore.getAll(%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.getAll()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange), IDB_LOG_STRINGIFY(aLimit));
@ -1071,7 +1071,7 @@ RefPtr<IDBRequest> IDBObjectStore::Clear(JSContext* aCx, ErrorResult& aRv) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).clear()",
"IDBObjectStore.clear(%.0s%.0s%.0s)", mTransaction->LoggingSerialNumber(),
"IDBObjectStore.clear()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this));
@ -1289,8 +1289,8 @@ RefPtr<IDBRequest> IDBObjectStore::GetInternal(bool aKeyOnly, JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).get(%s)",
"IDBObjectStore.get(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.get()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange));
@ -1347,8 +1347,8 @@ RefPtr<IDBRequest> IDBObjectStore::DeleteInternal(JSContext* aCx,
if (!aFromCursor) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).delete(%s)",
"IDBObjectStore.delete(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.delete()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange));
@ -1457,9 +1457,8 @@ RefPtr<IDBIndex> IDBObjectStore::CreateIndex(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).createIndex(%s)",
"IDBObjectStore.createIndex(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"IDBObjectStore.createIndex()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(index));
@ -1524,9 +1523,8 @@ void IDBObjectStore::DeleteIndex(const nsAString& aName, ErrorResult& aRv) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"deleteIndex(\"%s\")",
"IDBObjectStore.deleteIndex(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"IDBObjectStore.deleteIndex()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
NS_ConvertUTF16toUTF8(aName).get());
@ -1567,8 +1565,8 @@ RefPtr<IDBRequest> IDBObjectStore::Count(JSContext* aCx,
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).count(%s)",
"IDBObjectStore.count(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.count()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange));
@ -1631,8 +1629,8 @@ RefPtr<IDBRequest> IDBObjectStore::OpenCursorInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"openKeyCursor(%s, %s)",
"IDBObjectStore.openKeyCursor(%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.openKeyCursor()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange), IDB_LOG_STRINGIFY(aDirection));
@ -1640,8 +1638,8 @@ RefPtr<IDBRequest> IDBObjectStore::OpenCursorInternal(
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s)."
"openCursor(%s, %s)",
"IDBObjectStore.openCursor(%.0s%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), request->LoggingSerialNumber(),
"IDBObjectStore.openCursor()", mTransaction->LoggingSerialNumber(),
request->LoggingSerialNumber(),
IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), IDB_LOG_STRINGIFY(this),
IDB_LOG_STRINGIFY(keyRange), IDB_LOG_STRINGIFY(aDirection));
@ -1766,9 +1764,8 @@ void IDBObjectStore::SetName(const nsAString& aName, ErrorResult& aRv) {
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
"database(%s).transaction(%s).objectStore(%s).rename(%s)",
"IDBObjectStore.rename(%.0s%.0s%.0s%.0s)",
mTransaction->LoggingSerialNumber(), requestSerialNumber,
IDB_LOG_STRINGIFY(mTransaction->Database()),
"IDBObjectStore.rename()", mTransaction->LoggingSerialNumber(),
requestSerialNumber, IDB_LOG_STRINGIFY(mTransaction->Database()),
IDB_LOG_STRINGIFY(*mTransaction), loggingOldObjectStore.get(),
IDB_LOG_STRINGIFY(this));

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

@ -34,7 +34,9 @@
#include "nsIScriptContext.h"
#include "nsJSUtils.h"
#include "nsString.h"
#include "ThreadLocal.h"
// Include this last to avoid path problems on Windows.
#include "ActorsChild.h"
namespace mozilla {
namespace dom {

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

@ -26,7 +26,6 @@
#include "nsTHashtable.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "ThreadLocal.h"
// Include this last to avoid path problems on Windows.
#include "ActorsChild.h"

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

@ -26,7 +26,6 @@
#include "nsGlobalWindow.h"
#include "mozilla/Logging.h"
#include "ActorsChild.h"
#include "FileManager.h"
#include "IDBEvents.h"
#include "IDBFactory.h"

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

@ -1,292 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ProfilerHelpers.h"
#include "BackgroundChildImpl.h"
#include "GeckoProfiler.h"
#include "IDBDatabase.h"
#include "IDBIndex.h"
#include "IDBKeyRange.h"
#include "IDBObjectStore.h"
#include "IDBTransaction.h"
#include "Key.h"
#include "ThreadLocal.h"
namespace mozilla {
namespace dom {
namespace indexedDB {
namespace {
static const char kQuote = '\"';
static const char kOpenBracket = '[';
static const char kCloseBracket = ']';
static const char kOpenParen = '(';
static const char kCloseParen = ')';
void LoggingHelper(bool aUseProfiler, const char* aFmt, va_list args) {
MOZ_ASSERT(IndexedDatabaseManager::GetLoggingMode() !=
IndexedDatabaseManager::Logging_Disabled);
MOZ_ASSERT(aFmt);
mozilla::LogModule* logModule = IndexedDatabaseManager::GetLoggingModule();
MOZ_ASSERT(logModule);
static const mozilla::LogLevel logLevel = LogLevel::Warning;
if (MOZ_LOG_TEST(logModule, logLevel) ||
#ifdef MOZ_GECKO_PROFILER
(aUseProfiler && profiler_thread_is_being_profiled())
#else
false
#endif
) {
nsAutoCString message;
message.AppendPrintf(aFmt, args);
MOZ_LOG(logModule, logLevel, ("%s", message.get()));
if (aUseProfiler) {
PROFILER_ADD_MARKER(message.get(), DOM);
}
}
}
} // namespace
template <bool CheckLoggingMode>
LoggingIdString<CheckLoggingMode>::LoggingIdString() {
using mozilla::ipc::BackgroundChildImpl;
if (!CheckLoggingMode || IndexedDatabaseManager::GetLoggingMode() !=
IndexedDatabaseManager::Logging_Disabled) {
const BackgroundChildImpl::ThreadLocal* threadLocal =
BackgroundChildImpl::GetThreadLocalForCurrentThread();
if (threadLocal) {
const auto& idbThreadLocal = threadLocal->mIndexedDBThreadLocal;
if (idbThreadLocal) {
Assign(idbThreadLocal->IdString());
}
}
}
}
template <bool CheckLoggingMode>
LoggingIdString<CheckLoggingMode>::LoggingIdString(const nsID& aID) {
static_assert(NSID_LENGTH > 1, "NSID_LENGTH is set incorrectly!");
static_assert(NSID_LENGTH <= kStorageSize,
"nsID string won't fit in our storage!");
// Capacity() excludes the null terminator; NSID_LENGTH includes it.
MOZ_ASSERT(Capacity() + 1 == NSID_LENGTH);
if (!CheckLoggingMode || IndexedDatabaseManager::GetLoggingMode() !=
IndexedDatabaseManager::Logging_Disabled) {
// NSID_LENGTH counts the null terminator, SetLength() does not.
SetLength(NSID_LENGTH - 1);
aID.ToProvidedString(
*reinterpret_cast<char(*)[NSID_LENGTH]>(BeginWriting()));
}
}
template class LoggingIdString<false>;
template class LoggingIdString<true>;
LoggingString::LoggingString(IDBDatabase* aDatabase) : nsAutoCString(kQuote) {
MOZ_ASSERT(aDatabase);
AppendUTF16toUTF8(aDatabase->Name(), *this);
Append(kQuote);
}
LoggingString::LoggingString(const IDBTransaction& aTransaction)
: nsAutoCString(kOpenBracket) {
constexpr auto kCommaSpace = ", "_ns;
const nsTArray<nsString>& stores = aTransaction.ObjectStoreNamesInternal();
for (uint32_t count = stores.Length(), index = 0; index < count; index++) {
Append(kQuote);
AppendUTF16toUTF8(stores[index], *this);
Append(kQuote);
if (index != count - 1) {
Append(kCommaSpace);
}
}
Append(kCloseBracket);
Append(kCommaSpace);
switch (aTransaction.GetMode()) {
case IDBTransaction::Mode::ReadOnly:
AppendLiteral("\"readonly\"");
break;
case IDBTransaction::Mode::ReadWrite:
AppendLiteral("\"readwrite\"");
break;
case IDBTransaction::Mode::ReadWriteFlush:
AppendLiteral("\"readwriteflush\"");
break;
case IDBTransaction::Mode::Cleanup:
AppendLiteral("\"cleanup\"");
break;
case IDBTransaction::Mode::VersionChange:
AppendLiteral("\"versionchange\"");
break;
default:
MOZ_CRASH("Unknown mode!");
};
}
LoggingString::LoggingString(IDBObjectStore* aObjectStore)
: nsAutoCString(kQuote) {
MOZ_ASSERT(aObjectStore);
AppendUTF16toUTF8(aObjectStore->Name(), *this);
Append(kQuote);
}
LoggingString::LoggingString(IDBIndex* aIndex) : nsAutoCString(kQuote) {
MOZ_ASSERT(aIndex);
AppendUTF16toUTF8(aIndex->Name(), *this);
Append(kQuote);
}
LoggingString::LoggingString(IDBKeyRange* aKeyRange) {
if (aKeyRange) {
if (aKeyRange->IsOnly()) {
Assign(LoggingString(aKeyRange->Lower()));
} else {
if (aKeyRange->LowerOpen()) {
Assign(kOpenParen);
} else {
Assign(kOpenBracket);
}
Append(LoggingString(aKeyRange->Lower()));
AppendLiteral(", ");
Append(LoggingString(aKeyRange->Upper()));
if (aKeyRange->UpperOpen()) {
Append(kCloseParen);
} else {
Append(kCloseBracket);
}
}
} else {
AssignLiteral("<undefined>");
}
}
LoggingString::LoggingString(const Key& aKey) {
if (aKey.IsUnset()) {
AssignLiteral("<undefined>");
} else if (aKey.IsFloat()) {
AppendPrintf("%g", aKey.ToFloat());
} else if (aKey.IsDate()) {
AppendPrintf("<Date %g>", aKey.ToDateMsec());
} else if (aKey.IsString()) {
AppendPrintf("\"%s\"", NS_ConvertUTF16toUTF8(aKey.ToString()).get());
} else if (aKey.IsBinary()) {
AssignLiteral("[object ArrayBuffer]");
} else {
MOZ_ASSERT(aKey.IsArray());
AssignLiteral("[...]");
}
}
LoggingString::LoggingString(const IDBCursorDirection aDirection) {
switch (aDirection) {
case IDBCursorDirection::Next:
AssignLiteral("\"next\"");
break;
case IDBCursorDirection::Nextunique:
AssignLiteral("\"nextunique\"");
break;
case IDBCursorDirection::Prev:
AssignLiteral("\"prev\"");
break;
case IDBCursorDirection::Prevunique:
AssignLiteral("\"prevunique\"");
break;
default:
MOZ_CRASH("Unknown direction!");
};
}
LoggingString::LoggingString(const Optional<uint64_t>& aVersion) {
if (aVersion.WasPassed()) {
AppendInt(aVersion.Value());
} else {
AssignLiteral("<undefined>");
}
}
LoggingString::LoggingString(const Optional<uint32_t>& aLimit) {
if (aLimit.WasPassed()) {
AppendInt(aLimit.Value());
} else {
AssignLiteral("<undefined>");
}
}
LoggingString::LoggingString(IDBObjectStore* aObjectStore, const Key& aKey) {
MOZ_ASSERT(aObjectStore);
if (!aObjectStore->HasValidKeyPath()) {
Append(LoggingString(aKey));
}
}
LoggingString::LoggingString(Event* aEvent, const char16_t* aDefault)
: nsAutoCString(kQuote) {
MOZ_ASSERT(aDefault);
nsAutoString eventType;
if (aEvent) {
aEvent->GetType(eventType);
} else {
eventType = nsDependentString(aDefault);
}
AppendUTF16toUTF8(eventType, *this);
Append(kQuote);
}
void LoggingHelper(const char* aDetailedFmt, const char* aConciseFmt, ...) {
const IndexedDatabaseManager::LoggingMode mode =
IndexedDatabaseManager::GetLoggingMode();
if (mode != IndexedDatabaseManager::Logging_Disabled) {
const char* fmt;
if (mode == IndexedDatabaseManager::Logging_Concise ||
mode == IndexedDatabaseManager::Logging_ConciseProfilerMarks) {
fmt = aConciseFmt;
} else {
MOZ_ASSERT(mode == IndexedDatabaseManager::Logging_Detailed ||
mode == IndexedDatabaseManager::Logging_DetailedProfilerMarks);
fmt = aDetailedFmt;
}
const bool useProfiler =
mode == IndexedDatabaseManager::Logging_ConciseProfilerMarks ||
mode == IndexedDatabaseManager::Logging_DetailedProfilerMarks;
va_list args;
va_start(args, aConciseFmt);
LoggingHelper(useProfiler, fmt, args);
va_end(args);
}
}
} // namespace indexedDB
} // namespace dom
} // namespace mozilla

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

@ -10,66 +10,315 @@
// This file is not exported and is only meant to be included in IndexedDB
// source files.
#include "BackgroundChildImpl.h"
#include "GeckoProfiler.h"
#include "IDBCursorType.h"
#include "IDBDatabase.h"
#include "IDBIndex.h"
#include "IDBKeyRange.h"
#include "IDBObjectStore.h"
#include "IDBTransaction.h"
#include "IndexedDatabaseManager.h"
#include "Key.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "mozilla/dom/Event.h"
#include "nsDebug.h"
#include "nsID.h"
#include "nsString.h"
#include "mozilla/Logging.h"
// Include this last to avoid path problems on Windows.
#include "ActorsChild.h"
namespace mozilla {
namespace dom {
class Event;
class IDBDatabase;
class IDBIndex;
class IDBKeyRange;
class IDBObjectStore;
class IDBTransaction;
namespace indexedDB {
class Key;
template <bool CheckLoggingMode>
class LoggingIdString final : public nsAutoCStringN<NSID_LENGTH> {
class MOZ_STACK_CLASS LoggingIdString final
: public nsAutoCStringN<NSID_LENGTH> {
public:
LoggingIdString();
LoggingIdString() {
using mozilla::ipc::BackgroundChildImpl;
explicit LoggingIdString(const nsID& aID);
if (IndexedDatabaseManager::GetLoggingMode() !=
IndexedDatabaseManager::Logging_Disabled) {
const BackgroundChildImpl::ThreadLocal* threadLocal =
BackgroundChildImpl::GetThreadLocalForCurrentThread();
if (threadLocal) {
const auto& idbThreadLocal = threadLocal->mIndexedDBThreadLocal;
if (idbThreadLocal) {
Assign(idbThreadLocal->IdString());
}
}
}
}
explicit LoggingIdString(const nsID& aID) {
static_assert(NSID_LENGTH > 1, "NSID_LENGTH is set incorrectly!");
static_assert(NSID_LENGTH <= kStorageSize,
"nsID string won't fit in our storage!");
// Capacity() excludes the null terminator; NSID_LENGTH includes it.
MOZ_ASSERT(Capacity() + 1 == NSID_LENGTH);
if (IndexedDatabaseManager::GetLoggingMode() !=
IndexedDatabaseManager::Logging_Disabled) {
// NSID_LENGTH counts the null terminator, SetLength() does not.
SetLength(NSID_LENGTH - 1);
aID.ToProvidedString(
*reinterpret_cast<char(*)[NSID_LENGTH]>(BeginWriting()));
}
}
};
class MOZ_STACK_CLASS LoggingString final : public nsAutoCString {
public:
explicit LoggingString(IDBDatabase* aDatabase);
explicit LoggingString(const IDBTransaction& aTransaction);
explicit LoggingString(IDBObjectStore* aObjectStore);
explicit LoggingString(IDBIndex* aIndex);
explicit LoggingString(IDBKeyRange* aKeyRange);
explicit LoggingString(const Key& aKey);
explicit LoggingString(const IDBCursorDirection aDirection);
explicit LoggingString(const Optional<uint64_t>& aVersion);
explicit LoggingString(const Optional<uint32_t>& aLimit);
static const char kQuote = '\"';
static const char kOpenBracket = '[';
static const char kCloseBracket = ']';
static const char kOpenParen = '(';
static const char kCloseParen = ')';
LoggingString(IDBObjectStore* aObjectStore, const Key& aKey);
LoggingString(Event* aEvent, const char16_t* aDefault);
public:
explicit LoggingString(IDBDatabase* aDatabase) : nsAutoCString(kQuote) {
MOZ_ASSERT(aDatabase);
AppendUTF16toUTF8(aDatabase->Name(), *this);
Append(kQuote);
}
explicit LoggingString(const IDBTransaction& aTransaction)
: nsAutoCString(kOpenBracket) {
constexpr auto kCommaSpace = ", "_ns;
const nsTArray<nsString>& stores = aTransaction.ObjectStoreNamesInternal();
for (uint32_t count = stores.Length(), index = 0; index < count; index++) {
Append(kQuote);
AppendUTF16toUTF8(stores[index], *this);
Append(kQuote);
if (index != count - 1) {
Append(kCommaSpace);
}
}
Append(kCloseBracket);
Append(kCommaSpace);
switch (aTransaction.GetMode()) {
case IDBTransaction::Mode::ReadOnly:
AppendLiteral("\"readonly\"");
break;
case IDBTransaction::Mode::ReadWrite:
AppendLiteral("\"readwrite\"");
break;
case IDBTransaction::Mode::ReadWriteFlush:
AppendLiteral("\"readwriteflush\"");
break;
case IDBTransaction::Mode::Cleanup:
AppendLiteral("\"cleanup\"");
break;
case IDBTransaction::Mode::VersionChange:
AppendLiteral("\"versionchange\"");
break;
default:
MOZ_CRASH("Unknown mode!");
};
}
explicit LoggingString(IDBObjectStore* aObjectStore) : nsAutoCString(kQuote) {
MOZ_ASSERT(aObjectStore);
AppendUTF16toUTF8(aObjectStore->Name(), *this);
Append(kQuote);
}
explicit LoggingString(IDBIndex* aIndex) : nsAutoCString(kQuote) {
MOZ_ASSERT(aIndex);
AppendUTF16toUTF8(aIndex->Name(), *this);
Append(kQuote);
}
explicit LoggingString(IDBKeyRange* aKeyRange) {
if (aKeyRange) {
if (aKeyRange->IsOnly()) {
Assign(LoggingString(aKeyRange->Lower()));
} else {
if (aKeyRange->LowerOpen()) {
Assign(kOpenParen);
} else {
Assign(kOpenBracket);
}
Append(LoggingString(aKeyRange->Lower()));
AppendLiteral(", ");
Append(LoggingString(aKeyRange->Upper()));
if (aKeyRange->UpperOpen()) {
Append(kCloseParen);
} else {
Append(kCloseBracket);
}
}
} else {
AssignLiteral("<undefined>");
}
}
explicit LoggingString(const Key& aKey) {
if (aKey.IsUnset()) {
AssignLiteral("<undefined>");
} else if (aKey.IsFloat()) {
AppendPrintf("%g", aKey.ToFloat());
} else if (aKey.IsDate()) {
AppendPrintf("<Date %g>", aKey.ToDateMsec());
} else if (aKey.IsString()) {
AppendPrintf("\"%s\"", NS_ConvertUTF16toUTF8(aKey.ToString()).get());
} else if (aKey.IsBinary()) {
AssignLiteral("[object ArrayBuffer]");
} else {
MOZ_ASSERT(aKey.IsArray());
AssignLiteral("[...]");
}
}
explicit LoggingString(const IDBCursorDirection aDirection) {
switch (aDirection) {
case IDBCursorDirection::Next:
AssignLiteral("\"next\"");
break;
case IDBCursorDirection::Nextunique:
AssignLiteral("\"nextunique\"");
break;
case IDBCursorDirection::Prev:
AssignLiteral("\"prev\"");
break;
case IDBCursorDirection::Prevunique:
AssignLiteral("\"prevunique\"");
break;
default:
MOZ_CRASH("Unknown direction!");
};
}
explicit LoggingString(const Optional<uint64_t>& aVersion) {
if (aVersion.WasPassed()) {
AppendInt(aVersion.Value());
} else {
AssignLiteral("<undefined>");
}
}
explicit LoggingString(const Optional<uint32_t>& aLimit) {
if (aLimit.WasPassed()) {
AppendInt(aLimit.Value());
} else {
AssignLiteral("<undefined>");
}
}
LoggingString(IDBObjectStore* aObjectStore, const Key& aKey) {
MOZ_ASSERT(aObjectStore);
if (!aObjectStore->HasValidKeyPath()) {
Append(LoggingString(aKey));
}
}
LoggingString(Event* aEvent, const char16_t* aDefault)
: nsAutoCString(kQuote) {
MOZ_ASSERT(aDefault);
nsAutoString eventType;
if (aEvent) {
aEvent->GetType(eventType);
} else {
eventType = nsDependentString(aDefault);
}
AppendUTF16toUTF8(eventType, *this);
Append(kQuote);
}
};
// Both the aDetailedFmt and the aConciseFmt need to match the variable argument
// list, so we use MOZ_FORMAT_PRINTF twice here.
void MOZ_FORMAT_PRINTF(1, 3) MOZ_FORMAT_PRINTF(2, 3)
LoggingHelper(const char* aDetailedFmt, const char* aConciseFmt, ...);
inline void MOZ_FORMAT_PRINTF(2, 3)
LoggingHelper(bool aUseProfiler, const char* aFmt, ...) {
MOZ_ASSERT(IndexedDatabaseManager::GetLoggingMode() !=
IndexedDatabaseManager::Logging_Disabled);
MOZ_ASSERT(aFmt);
mozilla::LogModule* logModule = IndexedDatabaseManager::GetLoggingModule();
MOZ_ASSERT(logModule);
static const mozilla::LogLevel logLevel = LogLevel::Warning;
if (MOZ_LOG_TEST(logModule, logLevel) ||
#ifdef MOZ_GECKO_PROFILER
(aUseProfiler && profiler_thread_is_being_profiled())
#else
false
#endif
) {
nsAutoCString message;
{
va_list args;
va_start(args, aFmt);
message.AppendPrintf(aFmt, args);
va_end(args);
}
MOZ_LOG(logModule, logLevel, ("%s", message.get()));
if (aUseProfiler) {
PROFILER_ADD_MARKER(message.get(), DOM);
}
}
}
} // namespace indexedDB
} // namespace dom
} // namespace mozilla
#define IDB_LOG_MARK(_detailedFmt, _conciseFmt, _loggingId, ...) \
mozilla::dom::indexedDB::LoggingHelper("IndexedDB %s: " _detailedFmt, \
"IndexedDB %s: " _conciseFmt, \
_loggingId, ##__VA_ARGS__)
#define IDB_LOG_MARK2(_detailedFmt, _conciseFmt, ...) \
do { \
using namespace mozilla::dom::indexedDB; \
\
const IndexedDatabaseManager::LoggingMode mode = \
IndexedDatabaseManager::GetLoggingMode(); \
\
if (mode != IndexedDatabaseManager::Logging_Disabled) { \
const char* _fmt; \
if (mode == IndexedDatabaseManager::Logging_Concise || \
mode == IndexedDatabaseManager::Logging_ConciseProfilerMarks) { \
_fmt = _conciseFmt; \
} else { \
MOZ_ASSERT(mode == IndexedDatabaseManager::Logging_Detailed || \
mode == \
IndexedDatabaseManager::Logging_DetailedProfilerMarks); \
_fmt = _detailedFmt; \
} \
\
const bool _useProfiler = \
mode == IndexedDatabaseManager::Logging_ConciseProfilerMarks || \
mode == IndexedDatabaseManager::Logging_DetailedProfilerMarks; \
\
LoggingHelper(_useProfiler, _fmt, ##__VA_ARGS__); \
} \
} while (0)
#define IDB_LOG_MARK(_detailedFmt, _conciseFmt, _loggingId, ...) \
IDB_LOG_MARK2("IndexedDB %s: " _detailedFmt, "IndexedDB %s: " _conciseFmt, \
_loggingId, ##__VA_ARGS__)
#define IDB_LOG_ID_STRING(...) \
mozilla::dom::indexedDB::LoggingIdString<true>(__VA_ARGS__).get()
mozilla::dom::indexedDB::LoggingIdString(__VA_ARGS__).get()
#define IDB_LOG_STRINGIFY(...) \
mozilla::dom::indexedDB::LoggingString(__VA_ARGS__).get()
@ -82,11 +331,11 @@ void MOZ_FORMAT_PRINTF(1, 3) MOZ_FORMAT_PRINTF(2, 3)
#define IDB_LOG_MARK_CONCISE_PARENT "P"
#define IDB_LOG_MARK_CONCISE_CHILD "C"
#define IDB_LOG_MARK_DETAILED_TRANSACTION "Transaction[%" PRIi64 "]"
#define IDB_LOG_MARK_DETAILED_REQUEST "Request[%" PRIu64 "]"
#define IDB_LOG_MARK_DETAILED_TRANSACTION "Transaction[%lld]"
#define IDB_LOG_MARK_DETAILED_REQUEST "Request[%llu]"
#define IDB_LOG_MARK_CONCISE_TRANSACTION "T[%" PRIi64 "]"
#define IDB_LOG_MARK_CONCISE_REQUEST "R[%" PRIu64 "]"
#define IDB_LOG_MARK_CONCISE_TRANSACTION "T[%lld]"
#define IDB_LOG_MARK_CONCISE_REQUEST "R[%llu]"
#define IDB_LOG_MARK_TRANSACTION_REQUEST( \
_detailedPeer, _concisePeer, _detailedFmt, _conciseFmt, _loggingId, \

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

@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_indexeddb_threadlocal_h__
#define mozilla_dom_indexeddb_threadlocal_h__
#include "IDBTransaction.h"
#include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
#include "ProfilerHelpers.h"
namespace mozilla {
namespace dom {
class IDBFactory;
namespace indexedDB {
class ThreadLocal {
friend class DefaultDelete<ThreadLocal>;
friend IDBFactory;
LoggingInfo mLoggingInfo;
Maybe<IDBTransaction&> mCurrentTransaction;
LoggingIdString<false> mLoggingIdString;
NS_DECL_OWNINGTHREAD
public:
ThreadLocal() = delete;
ThreadLocal(const ThreadLocal& aOther) = delete;
void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(ThreadLocal); }
const LoggingInfo& GetLoggingInfo() const {
AssertIsOnOwningThread();
return mLoggingInfo;
}
const nsID& Id() const {
AssertIsOnOwningThread();
return mLoggingInfo.backgroundChildLoggingId();
}
const nsCString& IdString() const {
AssertIsOnOwningThread();
return mLoggingIdString;
}
int64_t NextTransactionSN(IDBTransaction::Mode aMode) {
AssertIsOnOwningThread();
MOZ_ASSERT(mLoggingInfo.nextTransactionSerialNumber() < INT64_MAX);
MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() >
INT64_MIN);
if (aMode == IDBTransaction::Mode::VersionChange) {
return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--;
}
return mLoggingInfo.nextTransactionSerialNumber()++;
}
uint64_t NextRequestSN() {
AssertIsOnOwningThread();
MOZ_ASSERT(mLoggingInfo.nextRequestSerialNumber() < UINT64_MAX);
return mLoggingInfo.nextRequestSerialNumber()++;
}
void SetCurrentTransaction(Maybe<IDBTransaction&> aCurrentTransaction) {
AssertIsOnOwningThread();
mCurrentTransaction = aCurrentTransaction;
}
Maybe<IDBTransaction&> MaybeCurrentTransactionRef() const {
AssertIsOnOwningThread();
return mCurrentTransaction;
}
private:
explicit ThreadLocal(const nsID& aBackgroundChildLoggingId);
~ThreadLocal();
};
} // namespace indexedDB
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_indexeddb_threadlocal_h__

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

@ -52,7 +52,6 @@ EXPORTS.mozilla.dom.indexedDB += [
'KeyPath.h',
'PermissionRequestBase.h',
'SerializationHelpers.h',
'ThreadLocal.h',
]
UNIFIED_SOURCES += [
@ -75,7 +74,6 @@ UNIFIED_SOURCES += [
'IndexedDatabaseManager.cpp',
'KeyPath.cpp',
'PermissionRequestBase.cpp',
'ProfilerHelpers.cpp',
'ReportInternalError.cpp',
'ScriptErrorHelper.cpp',
]

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

@ -30,7 +30,6 @@
#include "mozilla/dom/cache/ActorUtils.h"
#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryChild.h"
#include "mozilla/dom/indexedDB/PBackgroundIndexedDBUtilsChild.h"
#include "mozilla/dom/indexedDB/ThreadLocal.h"
#include "mozilla/dom/quota/PQuotaChild.h"
#include "mozilla/dom/RemoteWorkerChild.h"
#include "mozilla/dom/RemoteWorkerControllerChild.h"