2012-06-03 16:33:52 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2014-06-12 03:35:29 +00:00
|
|
|
#ifndef mozilla_dom_indexeddb_idbmutablefile_h__
|
|
|
|
#define mozilla_dom_indexeddb_idbmutablefile_h__
|
2012-06-03 16:33:52 +00:00
|
|
|
|
|
|
|
#include "IndexedDatabase.h"
|
|
|
|
|
2014-05-07 14:33:02 +00:00
|
|
|
#include "MainThreadUtils.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
2012-06-03 16:33:52 +00:00
|
|
|
#include "mozilla/dom/indexedDB/FileInfo.h"
|
2014-06-12 03:35:29 +00:00
|
|
|
#include "mozilla/dom/MutableFile.h"
|
2014-05-07 14:33:02 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-06-03 16:33:52 +00:00
|
|
|
|
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2013-07-31 15:48:46 +00:00
|
|
|
class IDBDatabase;
|
|
|
|
|
2014-06-12 03:35:29 +00:00
|
|
|
class IDBMutableFile : public MutableFile
|
2012-06-03 16:33:52 +00:00
|
|
|
{
|
2014-06-12 03:35:29 +00:00
|
|
|
typedef mozilla::dom::FileHandle FileHandle;
|
2014-02-24 20:56:13 +00:00
|
|
|
|
2012-06-03 16:33:52 +00:00
|
|
|
public:
|
2014-05-07 14:33:02 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2014-06-12 03:35:29 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBMutableFile, MutableFile)
|
2014-05-07 14:33:02 +00:00
|
|
|
|
2014-06-12 03:35:29 +00:00
|
|
|
static already_AddRefed<IDBMutableFile>
|
2014-05-07 14:33:02 +00:00
|
|
|
Create(const nsAString& aName, const nsAString& aType,
|
|
|
|
IDBDatabase* aDatabase, already_AddRefed<FileInfo> aFileInfo);
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-02-24 20:56:13 +00:00
|
|
|
|
|
|
|
virtual int64_t
|
|
|
|
GetFileId() MOZ_OVERRIDE
|
2012-06-03 16:33:52 +00:00
|
|
|
{
|
|
|
|
return mFileInfo->Id();
|
|
|
|
}
|
|
|
|
|
2014-02-24 20:56:13 +00:00
|
|
|
virtual FileInfo*
|
|
|
|
GetFileInfo() MOZ_OVERRIDE
|
2012-06-03 16:33:52 +00:00
|
|
|
{
|
|
|
|
return mFileInfo;
|
|
|
|
}
|
|
|
|
|
2014-05-07 14:33:02 +00:00
|
|
|
virtual bool
|
|
|
|
IsShuttingDown() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsInvalid() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual nsIOfflineStorage*
|
|
|
|
Storage() MOZ_OVERRIDE;
|
|
|
|
|
2012-06-03 16:33:52 +00:00
|
|
|
virtual already_AddRefed<nsISupports>
|
2014-02-24 20:56:13 +00:00
|
|
|
CreateStream(nsIFile* aFile, bool aReadOnly) MOZ_OVERRIDE;
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-05-07 14:33:02 +00:00
|
|
|
virtual void
|
|
|
|
SetThreadLocals() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
UnsetThreadLocals() MOZ_OVERRIDE;
|
|
|
|
|
2012-06-03 16:33:52 +00:00
|
|
|
virtual already_AddRefed<nsIDOMFile>
|
2014-06-12 03:35:29 +00:00
|
|
|
CreateFileObject(FileHandle* aFileHandle, uint32_t aFileSize) MOZ_OVERRIDE;
|
2014-02-24 20:56:13 +00:00
|
|
|
|
|
|
|
// nsWrapperCache
|
|
|
|
virtual JSObject*
|
2014-04-08 22:27:18 +00:00
|
|
|
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-02-24 20:56:13 +00:00
|
|
|
// WebIDL
|
2013-07-31 15:48:46 +00:00
|
|
|
IDBDatabase*
|
2014-05-07 14:33:02 +00:00
|
|
|
Database()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
return mDatabase;
|
|
|
|
}
|
2013-07-01 07:02:37 +00:00
|
|
|
|
2012-06-03 16:33:52 +00:00
|
|
|
private:
|
2014-06-12 03:35:29 +00:00
|
|
|
IDBMutableFile(IDBDatabase* aOwner);
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-06-12 03:35:29 +00:00
|
|
|
~IDBMutableFile()
|
2014-02-24 20:56:13 +00:00
|
|
|
{
|
|
|
|
}
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-05-07 14:33:02 +00:00
|
|
|
nsRefPtr<IDBDatabase> mDatabase;
|
2012-06-03 16:33:52 +00:00
|
|
|
nsRefPtr<FileInfo> mFileInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2014-06-12 03:35:29 +00:00
|
|
|
#endif // mozilla_dom_indexeddb_idbmutablefile_h__
|