1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_QUOTA_SCOPEDLOGEXTRAINFO_H_
8 #define DOM_QUOTA_SCOPEDLOGEXTRAINFO_H_
10 #include "mozilla/dom/quota/Config.h"
13 #include "mozilla/Assertions.h"
14 #include "mozilla/Attributes.h"
15 #include "mozilla/ThreadLocal.h"
17 #include "nsXULAppAPI.h"
19 namespace mozilla::dom::quota
{
21 struct MOZ_STACK_CLASS ScopedLogExtraInfo
{
22 static constexpr const char kTagQuery
[] = "query";
23 static constexpr const char kTagContext
[] = "context";
25 #ifdef QM_SCOPED_LOG_EXTRA_INFO_ENABLED
27 static auto FindSlot(const char* aTag
);
31 ScopedLogExtraInfo(const char (&aTag
)[N
], const nsACString
& aExtraInfo
)
32 : mTag
{aTag
}, mPreviousValue(nullptr), mCurrentValue
{aExtraInfo
} {
36 ~ScopedLogExtraInfo();
38 ScopedLogExtraInfo(ScopedLogExtraInfo
&& aOther
) noexcept
;
39 ScopedLogExtraInfo
& operator=(ScopedLogExtraInfo
&& aOther
) = delete;
41 ScopedLogExtraInfo(const ScopedLogExtraInfo
&) = delete;
42 ScopedLogExtraInfo
& operator=(const ScopedLogExtraInfo
&) = delete;
44 using ScopedLogExtraInfoMap
= std::map
<const char*, const nsACString
*>;
45 static ScopedLogExtraInfoMap
GetExtraInfoMap();
47 static void Initialize();
51 const nsACString
* mPreviousValue
;
52 nsCString mCurrentValue
;
54 static MOZ_THREAD_LOCAL(const nsACString
*) sQueryValue
;
55 static MOZ_THREAD_LOCAL(const nsACString
*) sContextValue
;
60 ScopedLogExtraInfo(const char (&aTag
)[N
], const nsACString
& aExtraInfo
) {}
62 // user-defined to silence unused variable warnings
63 ~ScopedLogExtraInfo() {}
67 } // namespace mozilla::dom::quota
69 #endif // DOM_QUOTA_SCOPEDLOGEXTRAINFO_H_