2011-12-16 11:34:24 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=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:
|
|
|
|
static already_AddRefed<nsIFile>
|
|
|
|
GetFileForId(nsIFile* aDirectory, int64_t aId);
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
InitDirectory(nsIFile* aDirectory,
|
|
|
|
nsIFile* aDatabaseFile,
|
|
|
|
PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin);
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
GetUsage(nsIFile* aDirectory, uint64_t* aUsage);
|
|
|
|
|
|
|
|
FileManager(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2014-10-28 22:06:54 +03:00
|
|
|
const nsAString& aDatabaseName,
|
|
|
|
bool aEnforcingQuota);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
PersistenceType
|
|
|
|
Type() const
|
2013-09-11 08:18:36 +04:00
|
|
|
{
|
|
|
|
return mPersistenceType;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const nsACString&
|
|
|
|
Group() const
|
2013-09-11 08:18:36 +04:00
|
|
|
{
|
|
|
|
return mGroup;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const nsACString&
|
|
|
|
Origin() const
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
|
|
|
return mOrigin;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const nsAString&
|
|
|
|
DatabaseName() const
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
|
|
|
return mDatabaseName;
|
|
|
|
}
|
|
|
|
|
2014-10-28 22:06:54 +03:00
|
|
|
bool
|
|
|
|
EnforcingQuota() const
|
|
|
|
{
|
|
|
|
return mEnforcingQuota;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
bool
|
|
|
|
Invalidated() const
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<nsIFile>
|
|
|
|
GetDirectory();
|
2012-08-24 22:51:33 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<nsIFile>
|
|
|
|
GetJournalDirectory();
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<nsIFile>
|
|
|
|
EnsureJournalDirectory();
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<FileInfo>
|
|
|
|
GetFileInfo(int64_t aId);
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<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:
|
2014-09-27 03:21:57 +04:00
|
|
|
~FileManager();
|
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__
|