dom/indexedDB/FileManager.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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_filemanager_h__
michael@0 8 #define mozilla_dom_indexeddb_filemanager_h__
michael@0 9
michael@0 10 #include "IndexedDatabase.h"
michael@0 11
michael@0 12 #include "nsIDOMFile.h"
michael@0 13 #include "nsIFile.h"
michael@0 14
michael@0 15 #include "mozilla/dom/quota/PersistenceType.h"
michael@0 16 #include "mozilla/dom/quota/StoragePrivilege.h"
michael@0 17 #include "nsDataHashtable.h"
michael@0 18
michael@0 19 class mozIStorageConnection;
michael@0 20
michael@0 21 BEGIN_INDEXEDDB_NAMESPACE
michael@0 22
michael@0 23 class FileInfo;
michael@0 24
michael@0 25 class FileManager MOZ_FINAL
michael@0 26 {
michael@0 27 friend class FileInfo;
michael@0 28
michael@0 29 typedef mozilla::dom::quota::PersistenceType PersistenceType;
michael@0 30 typedef mozilla::dom::quota::StoragePrivilege StoragePrivilege;
michael@0 31
michael@0 32 public:
michael@0 33 FileManager(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 34 const nsACString& aOrigin, StoragePrivilege aPrivilege,
michael@0 35 const nsAString& aDatabaseName)
michael@0 36 : mPersistenceType(aPersistenceType), mGroup(aGroup), mOrigin(aOrigin),
michael@0 37 mPrivilege(aPrivilege), mDatabaseName(aDatabaseName), mLastFileId(0),
michael@0 38 mInvalidated(false)
michael@0 39 { }
michael@0 40
michael@0 41 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileManager)
michael@0 42
michael@0 43 PersistenceType Type()
michael@0 44 {
michael@0 45 return mPersistenceType;
michael@0 46 }
michael@0 47
michael@0 48 const nsACString& Group() const
michael@0 49 {
michael@0 50 return mGroup;
michael@0 51 }
michael@0 52
michael@0 53 const nsACString& Origin() const
michael@0 54 {
michael@0 55 return mOrigin;
michael@0 56 }
michael@0 57
michael@0 58 const StoragePrivilege& Privilege() const
michael@0 59 {
michael@0 60 return mPrivilege;
michael@0 61 }
michael@0 62
michael@0 63 const nsAString& DatabaseName() const
michael@0 64 {
michael@0 65 return mDatabaseName;
michael@0 66 }
michael@0 67
michael@0 68 bool Invalidated() const
michael@0 69 {
michael@0 70 return mInvalidated;
michael@0 71 }
michael@0 72
michael@0 73 nsresult Init(nsIFile* aDirectory,
michael@0 74 mozIStorageConnection* aConnection);
michael@0 75
michael@0 76 nsresult Invalidate();
michael@0 77
michael@0 78 already_AddRefed<nsIFile> GetDirectory();
michael@0 79
michael@0 80 already_AddRefed<nsIFile> GetJournalDirectory();
michael@0 81
michael@0 82 already_AddRefed<nsIFile> EnsureJournalDirectory();
michael@0 83
michael@0 84 already_AddRefed<FileInfo> GetFileInfo(int64_t aId);
michael@0 85
michael@0 86 already_AddRefed<FileInfo> GetNewFileInfo();
michael@0 87
michael@0 88 static already_AddRefed<nsIFile> GetFileForId(nsIFile* aDirectory,
michael@0 89 int64_t aId);
michael@0 90
michael@0 91 static nsresult InitDirectory(nsIFile* aDirectory,
michael@0 92 nsIFile* aDatabaseFile,
michael@0 93 PersistenceType aPersistenceType,
michael@0 94 const nsACString& aGroup,
michael@0 95 const nsACString& aOrigin);
michael@0 96
michael@0 97 static nsresult GetUsage(nsIFile* aDirectory, uint64_t* aUsage);
michael@0 98
michael@0 99 private:
michael@0 100 // Private destructor, to discourage deletion outside of Release():
michael@0 101 ~FileManager()
michael@0 102 {
michael@0 103 }
michael@0 104
michael@0 105 PersistenceType mPersistenceType;
michael@0 106 nsCString mGroup;
michael@0 107 nsCString mOrigin;
michael@0 108 StoragePrivilege mPrivilege;
michael@0 109 nsString mDatabaseName;
michael@0 110
michael@0 111 nsString mDirectoryPath;
michael@0 112 nsString mJournalDirectoryPath;
michael@0 113
michael@0 114 int64_t mLastFileId;
michael@0 115
michael@0 116 // Protected by IndexedDatabaseManager::FileMutex()
michael@0 117 nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos;
michael@0 118
michael@0 119 bool mInvalidated;
michael@0 120 };
michael@0 121
michael@0 122 END_INDEXEDDB_NAMESPACE
michael@0 123
michael@0 124 #endif // mozilla_dom_indexeddb_filemanager_h__

mercurial