dom/indexedDB/FileInfo.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_indexeddb_fileinfo_h__
michael@0 8 #define mozilla_dom_indexeddb_fileinfo_h__
michael@0 9
michael@0 10 #include "IndexedDatabase.h"
michael@0 11
michael@0 12 #include "FileManager.h"
michael@0 13 #include "IndexedDatabaseManager.h"
michael@0 14
michael@0 15 BEGIN_INDEXEDDB_NAMESPACE
michael@0 16
michael@0 17 class FileInfo
michael@0 18 {
michael@0 19 friend class FileManager;
michael@0 20
michael@0 21 public:
michael@0 22 FileInfo(FileManager* aFileManager)
michael@0 23 : mFileManager(aFileManager)
michael@0 24 { }
michael@0 25
michael@0 26 virtual ~FileInfo()
michael@0 27 { }
michael@0 28
michael@0 29 static
michael@0 30 FileInfo* Create(FileManager* aFileManager, int64_t aId);
michael@0 31
michael@0 32 void AddRef()
michael@0 33 {
michael@0 34 if (IndexedDatabaseManager::IsClosed()) {
michael@0 35 ++mRefCnt;
michael@0 36 }
michael@0 37 else {
michael@0 38 UpdateReferences(mRefCnt, 1);
michael@0 39 }
michael@0 40 }
michael@0 41
michael@0 42 void Release()
michael@0 43 {
michael@0 44 if (IndexedDatabaseManager::IsClosed()) {
michael@0 45 nsrefcnt count = --mRefCnt;
michael@0 46 if (count == 0) {
michael@0 47 mRefCnt = 1;
michael@0 48 delete this;
michael@0 49 }
michael@0 50 }
michael@0 51 else {
michael@0 52 UpdateReferences(mRefCnt, -1);
michael@0 53 }
michael@0 54 }
michael@0 55
michael@0 56 void UpdateDBRefs(int32_t aDelta)
michael@0 57 {
michael@0 58 UpdateReferences(mDBRefCnt, aDelta);
michael@0 59 }
michael@0 60
michael@0 61 void ClearDBRefs()
michael@0 62 {
michael@0 63 UpdateReferences(mDBRefCnt, 0, true);
michael@0 64 }
michael@0 65
michael@0 66 void UpdateSliceRefs(int32_t aDelta)
michael@0 67 {
michael@0 68 UpdateReferences(mSliceRefCnt, aDelta);
michael@0 69 }
michael@0 70
michael@0 71 void GetReferences(int32_t* aRefCnt, int32_t* aDBRefCnt,
michael@0 72 int32_t* aSliceRefCnt);
michael@0 73
michael@0 74 FileManager* Manager() const
michael@0 75 {
michael@0 76 return mFileManager;
michael@0 77 }
michael@0 78
michael@0 79 virtual int64_t Id() const = 0;
michael@0 80
michael@0 81 private:
michael@0 82 void UpdateReferences(ThreadSafeAutoRefCnt& aRefCount, int32_t aDelta,
michael@0 83 bool aClear = false);
michael@0 84 void Cleanup();
michael@0 85
michael@0 86 ThreadSafeAutoRefCnt mRefCnt;
michael@0 87 ThreadSafeAutoRefCnt mDBRefCnt;
michael@0 88 ThreadSafeAutoRefCnt mSliceRefCnt;
michael@0 89
michael@0 90 nsRefPtr<FileManager> mFileManager;
michael@0 91 };
michael@0 92
michael@0 93 #define FILEINFO_SUBCLASS(_bits) \
michael@0 94 class FileInfo##_bits : public FileInfo \
michael@0 95 { \
michael@0 96 public: \
michael@0 97 FileInfo##_bits(FileManager* aFileManager, int##_bits##_t aId) \
michael@0 98 : FileInfo(aFileManager), mId(aId) \
michael@0 99 { } \
michael@0 100 \
michael@0 101 virtual int64_t Id() const \
michael@0 102 { \
michael@0 103 return mId; \
michael@0 104 } \
michael@0 105 \
michael@0 106 private: \
michael@0 107 int##_bits##_t mId; \
michael@0 108 };
michael@0 109
michael@0 110 FILEINFO_SUBCLASS(16)
michael@0 111 FILEINFO_SUBCLASS(32)
michael@0 112 FILEINFO_SUBCLASS(64)
michael@0 113
michael@0 114 #undef FILEINFO_SUBCLASS
michael@0 115
michael@0 116 END_INDEXEDDB_NAMESPACE
michael@0 117
michael@0 118 #endif // mozilla_dom_indexeddb_fileinfo_h__

mercurial