2011-12-16 11:34:24 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_indexeddb_filemanager_h__
|
|
|
|
#define mozilla_dom_indexeddb_filemanager_h__
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-11 08:18:36 +04:00
|
|
|
#include "mozilla/dom/quota/PersistenceType.h"
|
2011-12-16 11:34:24 +04:00
|
|
|
#include "nsDataHashtable.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
class nsIFile;
|
2011-12-16 11:34:24 +04:00
|
|
|
class mozIStorageConnection;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
class FileInfo;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// Implemented in ActorsParent.cpp.
|
2015-03-21 19:28:04 +03:00
|
|
|
class FileManager final {
|
2011-12-16 11:34:24 +04:00
|
|
|
friend class FileInfo;
|
|
|
|
|
2013-09-11 08:18:36 +04:00
|
|
|
typedef mozilla::dom::quota::PersistenceType PersistenceType;
|
2013-03-26 15:13:17 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
PersistenceType mPersistenceType;
|
|
|
|
nsCString mGroup;
|
|
|
|
nsCString mOrigin;
|
|
|
|
nsString mDatabaseName;
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsString mDirectoryPath;
|
|
|
|
nsString mJournalDirectoryPath;
|
|
|
|
|
|
|
|
int64_t mLastFileId;
|
|
|
|
|
|
|
|
// Protected by IndexedDatabaseManager::FileMutex()
|
|
|
|
nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos;
|
|
|
|
|
2014-10-28 22:06:54 +03:00
|
|
|
const bool mEnforcingQuota;
|
2014-09-27 03:21:57 +04:00
|
|
|
bool mInvalidated;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
public:
|
2019-12-16 16:17:46 +03:00
|
|
|
static MOZ_MUST_USE nsCOMPtr<nsIFile> GetFileForId(nsIFile* aDirectory,
|
|
|
|
int64_t aId);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2019-12-16 16:17:46 +03:00
|
|
|
static MOZ_MUST_USE nsCOMPtr<nsIFile> GetCheckedFileForId(nsIFile* aDirectory,
|
|
|
|
int64_t aId);
|
2016-10-25 22:18:58 +03:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
static nsresult InitDirectory(nsIFile* aDirectory, nsIFile* aDatabaseFile,
|
2015-05-19 19:25:50 +03:00
|
|
|
const nsACString& aOrigin,
|
|
|
|
uint32_t aTelemetryId);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2019-08-22 23:52:09 +03:00
|
|
|
static nsresult GetUsage(nsIFile* aDirectory, Maybe<uint64_t>& aUsage);
|
|
|
|
|
|
|
|
static nsresult GetUsage(nsIFile* aDirectory, uint64_t& aUsage);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
FileManager(PersistenceType aPersistenceType, const nsACString& aGroup,
|
2014-10-28 22:06:54 +03:00
|
|
|
const nsACString& aOrigin, const nsAString& aDatabaseName,
|
|
|
|
bool aEnforcingQuota);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2013-09-11 08:18:36 +04:00
|
|
|
PersistenceType Type() const { return mPersistenceType; }
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const nsACString& Group() const { return mGroup; }
|
2013-09-11 08:18:36 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const nsACString& Origin() const { return mOrigin; }
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
const nsAString& DatabaseName() const { return mDatabaseName; }
|
|
|
|
|
2014-10-28 22:06:54 +03:00
|
|
|
bool EnforcingQuota() const { return mEnforcingQuota; }
|
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
bool Invalidated() const { return mInvalidated; }
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsresult Init(nsIFile* aDirectory, mozIStorageConnection* aConnection);
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsresult Invalidate();
|
2012-08-24 22:51:33 +04:00
|
|
|
|
2019-12-16 16:17:46 +03:00
|
|
|
MOZ_MUST_USE nsCOMPtr<nsIFile> GetDirectory();
|
2012-08-24 22:51:33 +04:00
|
|
|
|
2019-12-16 16:17:46 +03:00
|
|
|
MOZ_MUST_USE nsCOMPtr<nsIFile> GetCheckedDirectory();
|
2016-10-25 22:18:58 +03:00
|
|
|
|
2019-12-16 16:17:46 +03:00
|
|
|
MOZ_MUST_USE nsCOMPtr<nsIFile> GetJournalDirectory();
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2019-12-16 16:17:46 +03:00
|
|
|
MOZ_MUST_USE nsCOMPtr<nsIFile> EnsureJournalDirectory();
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2019-12-16 16:17:46 +03:00
|
|
|
MOZ_MUST_USE RefPtr<FileInfo> GetFileInfo(int64_t aId) const;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2019-12-16 16:17:46 +03:00
|
|
|
MOZ_MUST_USE RefPtr<FileInfo> GetNewFileInfo();
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileManager)
|
2012-08-24 22:51:33 +04:00
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
private:
|
2016-11-14 12:40:37 +03:00
|
|
|
~FileManager() = default;
|
2011-12-16 11:34:24 +04:00
|
|
|
};
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
#endif // mozilla_dom_indexeddb_filemanager_h__
|