1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_indexeddb_fileinfo_h__
8 #define mozilla_dom_indexeddb_fileinfo_h__
10 #include "IndexedDatabase.h"
12 #include "FileManager.h"
13 #include "IndexedDatabaseManager.h"
15 BEGIN_INDEXEDDB_NAMESPACE
19 friend class FileManager
;
22 explicit FileInfo(FileManager
* aFileManager
)
23 : mFileManager(aFileManager
)
30 FileInfo
* Create(FileManager
* aFileManager
, int64_t aId
);
34 if (IndexedDatabaseManager::IsClosed()) {
38 UpdateReferences(mRefCnt
, 1);
44 if (IndexedDatabaseManager::IsClosed()) {
45 nsrefcnt count
= --mRefCnt
;
52 UpdateReferences(mRefCnt
, -1);
56 void UpdateDBRefs(int32_t aDelta
)
58 UpdateReferences(mDBRefCnt
, aDelta
);
63 UpdateReferences(mDBRefCnt
, 0, true);
66 void UpdateSliceRefs(int32_t aDelta
)
68 UpdateReferences(mSliceRefCnt
, aDelta
);
71 void GetReferences(int32_t* aRefCnt
, int32_t* aDBRefCnt
,
72 int32_t* aSliceRefCnt
);
74 FileManager
* Manager() const
79 virtual int64_t Id() const = 0;
82 void UpdateReferences(ThreadSafeAutoRefCnt
& aRefCount
, int32_t aDelta
,
86 ThreadSafeAutoRefCnt mRefCnt
;
87 ThreadSafeAutoRefCnt mDBRefCnt
;
88 ThreadSafeAutoRefCnt mSliceRefCnt
;
90 nsRefPtr
<FileManager
> mFileManager
;
93 #define FILEINFO_SUBCLASS(_bits) \
94 class FileInfo##_bits : public FileInfo \
97 FileInfo##_bits(FileManager* aFileManager, int##_bits##_t aId) \
98 : FileInfo(aFileManager), mId(aId) \
101 virtual int64_t Id() const \
107 int##_bits##_t mId; \
110 FILEINFO_SUBCLASS(16)
111 FILEINFO_SUBCLASS(32)
112 FILEINFO_SUBCLASS(64)
114 #undef FILEINFO_SUBCLASS
116 END_INDEXEDDB_NAMESPACE
118 #endif // mozilla_dom_indexeddb_fileinfo_h__