no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / indexedDB / ThreadLocal.h
blobc780c9a2507dcbda6ab546832172f5eb9de84e1f
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 mozilla_dom_indexeddb_threadlocal_h__
8 #define mozilla_dom_indexeddb_threadlocal_h__
10 #include "IDBTransaction.h"
11 #include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
12 #include "ProfilerHelpers.h"
14 namespace mozilla::dom {
16 class IDBFactory;
18 namespace indexedDB {
20 class ThreadLocal {
21 friend class DefaultDelete<ThreadLocal>;
22 friend IDBFactory;
24 LoggingInfo mLoggingInfo;
25 Maybe<IDBTransaction&> mCurrentTransaction;
26 LoggingIdString<false> mLoggingIdString;
28 NS_DECL_OWNINGTHREAD
30 public:
31 ThreadLocal() = delete;
32 ThreadLocal(const ThreadLocal& aOther) = delete;
34 void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(ThreadLocal); }
36 const LoggingInfo& GetLoggingInfo() const {
37 AssertIsOnOwningThread();
39 return mLoggingInfo;
42 const nsID& Id() const {
43 AssertIsOnOwningThread();
45 return mLoggingInfo.backgroundChildLoggingId();
48 const nsCString& IdString() const {
49 AssertIsOnOwningThread();
51 return mLoggingIdString;
54 int64_t NextTransactionSN(IDBTransaction::Mode aMode) {
55 AssertIsOnOwningThread();
56 MOZ_ASSERT(mLoggingInfo.nextTransactionSerialNumber() < INT64_MAX);
57 MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() >
58 INT64_MIN);
60 if (aMode == IDBTransaction::Mode::VersionChange) {
61 return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--;
64 return mLoggingInfo.nextTransactionSerialNumber()++;
67 uint64_t NextRequestSN() {
68 AssertIsOnOwningThread();
69 MOZ_ASSERT(mLoggingInfo.nextRequestSerialNumber() < UINT64_MAX);
71 return mLoggingInfo.nextRequestSerialNumber()++;
74 void SetCurrentTransaction(Maybe<IDBTransaction&> aCurrentTransaction) {
75 AssertIsOnOwningThread();
77 mCurrentTransaction = aCurrentTransaction;
80 Maybe<IDBTransaction&> MaybeCurrentTransactionRef() const {
81 AssertIsOnOwningThread();
83 return mCurrentTransaction;
86 private:
87 explicit ThreadLocal(const nsID& aBackgroundChildLoggingId);
88 ~ThreadLocal();
91 } // namespace indexedDB
92 } // namespace mozilla::dom
94 #endif // mozilla_dom_indexeddb_threadlocal_h__