2011-12-15 23:34:24 -08: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 04:12:37 -07: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-15 23:34:24 -08:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_indexeddb_fileinfo_h__
|
|
|
|
#define mozilla_dom_indexeddb_fileinfo_h__
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2012-06-19 18:50:39 -07:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
class FileManager;
|
2011-12-15 23:34:24 -08:00
|
|
|
|
|
|
|
class FileInfo
|
|
|
|
{
|
|
|
|
friend class FileManager;
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
ThreadSafeAutoRefCnt mRefCnt;
|
|
|
|
ThreadSafeAutoRefCnt mDBRefCnt;
|
|
|
|
ThreadSafeAutoRefCnt mSliceRefCnt;
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
nsRefPtr<FileManager> mFileManager;
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
public:
|
2011-12-15 23:34:24 -08:00
|
|
|
static
|
2012-08-22 08:56:38 -07:00
|
|
|
FileInfo* Create(FileManager* aFileManager, int64_t aId);
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
explicit FileInfo(FileManager* aFileManager);
|
|
|
|
|
|
|
|
void
|
|
|
|
AddRef()
|
2011-12-15 23:34:24 -08:00
|
|
|
{
|
2014-09-13 09:12:19 -07:00
|
|
|
UpdateReferences(mRefCnt, 1);
|
2011-12-15 23:34:24 -08:00
|
|
|
}
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
void
|
|
|
|
Release()
|
2011-12-15 23:34:24 -08:00
|
|
|
{
|
2014-09-13 09:12:19 -07:00
|
|
|
UpdateReferences(mRefCnt, -1);
|
2011-12-15 23:34:24 -08:00
|
|
|
}
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
void
|
|
|
|
UpdateDBRefs(int32_t aDelta)
|
2011-12-15 23:34:24 -08:00
|
|
|
{
|
|
|
|
UpdateReferences(mDBRefCnt, aDelta);
|
|
|
|
}
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
void
|
|
|
|
ClearDBRefs()
|
2011-12-15 23:34:24 -08:00
|
|
|
{
|
|
|
|
UpdateReferences(mDBRefCnt, 0, true);
|
|
|
|
}
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
void
|
|
|
|
UpdateSliceRefs(int32_t aDelta)
|
2011-12-15 23:34:24 -08:00
|
|
|
{
|
|
|
|
UpdateReferences(mSliceRefCnt, aDelta);
|
|
|
|
}
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
void
|
|
|
|
GetReferences(int32_t* aRefCnt, int32_t* aDBRefCnt, int32_t* aSliceRefCnt);
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
FileManager*
|
|
|
|
Manager() const
|
2011-12-15 23:34:24 -08:00
|
|
|
{
|
|
|
|
return mFileManager;
|
|
|
|
}
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
virtual int64_t
|
|
|
|
Id() const = 0;
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
protected:
|
|
|
|
virtual ~FileInfo();
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
private:
|
|
|
|
void
|
|
|
|
UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
|
|
|
|
int32_t aDelta,
|
|
|
|
bool aClear = false);
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
void
|
|
|
|
Cleanup();
|
2011-12-15 23:34:24 -08:00
|
|
|
};
|
|
|
|
|
2014-09-13 09:12:19 -07:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-12-15 23:34:24 -08:00
|
|
|
|
|
|
|
#endif // mozilla_dom_indexeddb_fileinfo_h__
|