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_fileinfo_h__
|
|
|
|
#define mozilla_dom_indexeddb_fileinfo_h__
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2012-06-20 05:50:39 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
class FileManager;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
class FileInfo
|
|
|
|
{
|
|
|
|
friend class FileManager;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
ThreadSafeAutoRefCnt mRefCnt;
|
|
|
|
ThreadSafeAutoRefCnt mDBRefCnt;
|
|
|
|
ThreadSafeAutoRefCnt mSliceRefCnt;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FileManager> mFileManager;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
public:
|
2016-03-15 09:00:15 +03:00
|
|
|
class CustomCleanupCallback;
|
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
static
|
2012-08-22 19:56:38 +04:00
|
|
|
FileInfo* Create(FileManager* aFileManager, int64_t aId);
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
explicit FileInfo(FileManager* aFileManager);
|
|
|
|
|
|
|
|
void
|
|
|
|
AddRef()
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
UpdateReferences(mRefCnt, 1);
|
2011-12-16 11:34:24 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
2016-03-15 09:00:15 +03:00
|
|
|
Release(CustomCleanupCallback* aCustomCleanupCallback = nullptr)
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
2016-03-15 09:00:15 +03:00
|
|
|
UpdateReferences(mRefCnt, -1, aCustomCleanupCallback);
|
2011-12-16 11:34:24 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
UpdateDBRefs(int32_t aDelta)
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
|
|
|
UpdateReferences(mDBRefCnt, aDelta);
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
UpdateSliceRefs(int32_t aDelta)
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
|
|
|
UpdateReferences(mSliceRefCnt, aDelta);
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
GetReferences(int32_t* aRefCnt, int32_t* aDBRefCnt, int32_t* aSliceRefCnt);
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
FileManager*
|
|
|
|
Manager() const
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
|
|
|
return mFileManager;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
virtual int64_t
|
|
|
|
Id() const = 0;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
protected:
|
|
|
|
virtual ~FileInfo();
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
private:
|
|
|
|
void
|
|
|
|
UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
|
2016-03-15 09:00:15 +03:00
|
|
|
int32_t aDelta,
|
|
|
|
CustomCleanupCallback* aCustomCleanupCallback = nullptr);
|
2014-11-13 12:43:22 +03:00
|
|
|
|
|
|
|
bool
|
|
|
|
LockedClearDBRefs();
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
Cleanup();
|
2014-09-18 03:36:01 +04:00
|
|
|
};
|
|
|
|
|
2016-03-15 09:00:15 +03:00
|
|
|
class NS_NO_VTABLE FileInfo::CustomCleanupCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual nsresult
|
|
|
|
Cleanup(FileManager* aFileManager, int64_t aId) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CustomCleanupCallback()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
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_fileinfo_h__
|