2013-03-16 10:58:50 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-16 10:58:50 +04:00
|
|
|
/* 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_profilerhelpers_h__
|
|
|
|
#define mozilla_dom_indexeddb_profilerhelpers_h__
|
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
// This file is not exported and is only meant to be included in IndexedDB
|
|
|
|
// source files.
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
#include "IndexedDatabaseManager.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2020-07-03 12:38:41 +03:00
|
|
|
#include "mozilla/dom/IDBCursorBinding.h"
|
2014-10-16 08:56:52 +04:00
|
|
|
#include "nsID.h"
|
|
|
|
#include "nsString.h"
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2020-07-03 12:38:41 +03:00
|
|
|
|
|
|
|
class Event;
|
|
|
|
class IDBDatabase;
|
|
|
|
class IDBIndex;
|
|
|
|
class IDBKeyRange;
|
|
|
|
class IDBObjectStore;
|
|
|
|
class IDBTransaction;
|
|
|
|
|
2020-07-03 11:49:58 +03:00
|
|
|
namespace indexedDB {
|
2020-07-03 11:06:59 +03:00
|
|
|
|
2020-07-03 12:38:41 +03:00
|
|
|
class Key;
|
|
|
|
|
2020-07-03 11:49:58 +03:00
|
|
|
class MOZ_STACK_CLASS LoggingIdString final
|
|
|
|
: public nsAutoCStringN<NSID_LENGTH> {
|
|
|
|
public:
|
2020-07-03 12:38:41 +03:00
|
|
|
LoggingIdString();
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2020-07-03 12:38:41 +03:00
|
|
|
explicit LoggingIdString(const nsID& aID);
|
2014-10-16 08:56:52 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class MOZ_STACK_CLASS LoggingString final : public nsAutoCString {
|
2013-03-16 10:58:50 +04:00
|
|
|
public:
|
2020-07-03 12:38:41 +03:00
|
|
|
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);
|
|
|
|
|
|
|
|
LoggingString(IDBObjectStore* aObjectStore, const Key& aKey);
|
|
|
|
LoggingString(Event* aEvent, const char16_t* aDefault);
|
2013-03-16 10:58:50 +04:00
|
|
|
};
|
|
|
|
|
2020-07-03 12:38:41 +03:00
|
|
|
void MOZ_FORMAT_PRINTF(2, 3)
|
|
|
|
LoggingHelper(bool aUseProfiler, const char* aFmt, ...);
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-03 11:49:58 +03:00
|
|
|
#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__)
|
2019-09-27 13:11:45 +03:00
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
#define IDB_LOG_ID_STRING(...) \
|
2020-07-03 11:49:58 +03:00
|
|
|
mozilla::dom::indexedDB::LoggingIdString(__VA_ARGS__).get()
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
#define IDB_LOG_STRINGIFY(...) \
|
|
|
|
mozilla::dom::indexedDB::LoggingString(__VA_ARGS__).get()
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2019-09-27 13:11:45 +03:00
|
|
|
// IDB_LOG_MARK_DETAILED_PARENT and IDB_LOG_MARK_DETAILED_CHILD should have the
|
|
|
|
// same width.
|
|
|
|
#define IDB_LOG_MARK_DETAILED_PARENT "Parent"
|
|
|
|
#define IDB_LOG_MARK_DETAILED_CHILD "Child "
|
|
|
|
|
|
|
|
#define IDB_LOG_MARK_CONCISE_PARENT "P"
|
|
|
|
#define IDB_LOG_MARK_CONCISE_CHILD "C"
|
|
|
|
|
2020-07-03 12:39:24 +03:00
|
|
|
#define IDB_LOG_MARK_DETAILED_TRANSACTION "Transaction[%" PRIi64 "]"
|
|
|
|
#define IDB_LOG_MARK_DETAILED_REQUEST "Request[%" PRIu64 "]"
|
2019-09-27 13:11:45 +03:00
|
|
|
|
2020-07-03 12:39:24 +03:00
|
|
|
#define IDB_LOG_MARK_CONCISE_TRANSACTION "T[%" PRIi64 "]"
|
|
|
|
#define IDB_LOG_MARK_CONCISE_REQUEST "R[%" PRIu64 "]"
|
2019-09-27 13:11:45 +03:00
|
|
|
|
|
|
|
#define IDB_LOG_MARK_TRANSACTION_REQUEST( \
|
|
|
|
_detailedPeer, _concisePeer, _detailedFmt, _conciseFmt, _loggingId, \
|
|
|
|
_transactionSerialNumber, _requestSerialNumber, ...) \
|
|
|
|
IDB_LOG_MARK(_detailedPeer " " IDB_LOG_MARK_DETAILED_TRANSACTION \
|
|
|
|
" " IDB_LOG_MARK_DETAILED_REQUEST \
|
|
|
|
": " _detailedFmt, \
|
|
|
|
_concisePeer " " IDB_LOG_MARK_CONCISE_TRANSACTION \
|
|
|
|
" " IDB_LOG_MARK_CONCISE_REQUEST ": " _conciseFmt, \
|
|
|
|
_loggingId, _transactionSerialNumber, _requestSerialNumber, \
|
|
|
|
##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define IDB_LOG_MARK_PARENT_TRANSACTION_REQUEST( \
|
|
|
|
_detailedFmt, _conciseFmt, _loggingId, _transactionSerialNumber, \
|
|
|
|
_requestSerialNumber, ...) \
|
|
|
|
IDB_LOG_MARK_TRANSACTION_REQUEST( \
|
|
|
|
IDB_LOG_MARK_DETAILED_PARENT, IDB_LOG_MARK_CONCISE_PARENT, _detailedFmt, \
|
|
|
|
_conciseFmt, _loggingId, _transactionSerialNumber, _requestSerialNumber, \
|
|
|
|
##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(_detailedFmt, _conciseFmt, \
|
|
|
|
_transactionSerialNumber, \
|
|
|
|
_requestSerialNumber, ...) \
|
|
|
|
IDB_LOG_MARK_TRANSACTION_REQUEST( \
|
|
|
|
IDB_LOG_MARK_DETAILED_CHILD, IDB_LOG_MARK_CONCISE_CHILD, _detailedFmt, \
|
|
|
|
_conciseFmt, IDB_LOG_ID_STRING(), _transactionSerialNumber, \
|
|
|
|
_requestSerialNumber, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define IDB_LOG_MARK_CHILD_REQUEST(_detailedFmt, _conciseFmt, \
|
|
|
|
_requestSerialNumber, ...) \
|
|
|
|
IDB_LOG_MARK(IDB_LOG_MARK_DETAILED_CHILD " " IDB_LOG_MARK_DETAILED_REQUEST \
|
|
|
|
": " _detailedFmt, \
|
|
|
|
IDB_LOG_MARK_CONCISE_CHILD " " IDB_LOG_MARK_CONCISE_REQUEST \
|
|
|
|
": " _conciseFmt, \
|
|
|
|
IDB_LOG_ID_STRING(), _requestSerialNumber, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define IDB_LOG_MARK_TRANSACTION(_detailedPeer, _concisePeer, _detailedFmt, \
|
|
|
|
_conciseFmt, _loggingId, \
|
|
|
|
_transactionSerialNumber, ...) \
|
|
|
|
IDB_LOG_MARK( \
|
|
|
|
_detailedPeer " " IDB_LOG_MARK_DETAILED_TRANSACTION ": " _detailedFmt, \
|
|
|
|
_concisePeer " " IDB_LOG_MARK_CONCISE_TRANSACTION ": " _conciseFmt, \
|
|
|
|
_loggingId, _transactionSerialNumber, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define IDB_LOG_MARK_PARENT_TRANSACTION(_detailedFmt, _conciseFmt, _loggingId, \
|
|
|
|
_transactionSerialNumber, ...) \
|
|
|
|
IDB_LOG_MARK_TRANSACTION( \
|
|
|
|
IDB_LOG_MARK_DETAILED_PARENT, IDB_LOG_MARK_CONCISE_PARENT, _detailedFmt, \
|
|
|
|
_conciseFmt, _loggingId, _transactionSerialNumber, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define IDB_LOG_MARK_CHILD_TRANSACTION(_detailedFmt, _conciseFmt, \
|
|
|
|
_transactionSerialNumber, ...) \
|
|
|
|
IDB_LOG_MARK_TRANSACTION(IDB_LOG_MARK_DETAILED_CHILD, \
|
|
|
|
IDB_LOG_MARK_CONCISE_CHILD, _detailedFmt, \
|
|
|
|
_conciseFmt, IDB_LOG_ID_STRING(), \
|
|
|
|
_transactionSerialNumber, ##__VA_ARGS__)
|
|
|
|
|
2013-03-16 10:58:50 +04:00
|
|
|
#endif // mozilla_dom_indexeddb_profilerhelpers_h__
|