2012-06-03 09:33:52 -07: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-11 20:35:29 -07:00
|
|
|
#ifndef mozilla_dom_indexeddb_idbmutablefile_h__
|
|
|
|
#define mozilla_dom_indexeddb_idbmutablefile_h__
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
#include "js/TypeDecls.h"
|
2014-05-07 07:33:02 -07:00
|
|
|
#include "MainThreadUtils.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-07-17 09:40:54 -07:00
|
|
|
#include "mozilla/dom/FileModeBinding.h"
|
2012-06-03 09:33:52 -07:00
|
|
|
#include "mozilla/dom/indexedDB/FileInfo.h"
|
2014-06-11 20:35:29 -07:00
|
|
|
#include "mozilla/dom/MutableFile.h"
|
2014-07-17 09:40:54 -07:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2014-05-07 07:33:02 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
class nsIDOMFile;
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class DOMRequest;
|
|
|
|
|
|
|
|
namespace indexedDB {
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2013-07-31 08:48:46 -07:00
|
|
|
class IDBDatabase;
|
2014-07-17 09:40:54 -07:00
|
|
|
class IDBFileHandle;
|
2013-07-31 08:48:46 -07:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
class IDBMutableFile MOZ_FINAL : public DOMEventTargetHelper,
|
|
|
|
public MutableFileBase
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-05-07 07:33:02 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBMutableFile, DOMEventTargetHelper)
|
2014-05-07 07:33:02 -07:00
|
|
|
|
2014-06-11 20:35:29 -07:00
|
|
|
static already_AddRefed<IDBMutableFile>
|
2014-05-07 07:33:02 -07:00
|
|
|
Create(const nsAString& aName, const nsAString& aType,
|
|
|
|
IDBDatabase* aDatabase, already_AddRefed<FileInfo> aFileInfo);
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
const nsAString&
|
|
|
|
Name() const
|
|
|
|
{
|
|
|
|
return mName;
|
|
|
|
}
|
2014-02-24 12:56:13 -08:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
const nsAString&
|
|
|
|
Type() const
|
|
|
|
{
|
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t
|
|
|
|
GetFileId() const
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
|
|
|
return mFileInfo->Id();
|
|
|
|
}
|
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
FileInfo*
|
|
|
|
GetFileInfo() const
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
|
|
|
return mFileInfo;
|
|
|
|
}
|
|
|
|
|
2014-05-07 07:33:02 -07:00
|
|
|
virtual bool
|
|
|
|
IsInvalid() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual nsIOfflineStorage*
|
|
|
|
Storage() MOZ_OVERRIDE;
|
|
|
|
|
2012-06-03 09:33:52 -07:00
|
|
|
virtual already_AddRefed<nsISupports>
|
2014-07-17 09:40:54 -07:00
|
|
|
CreateStream(bool aReadOnly) MOZ_OVERRIDE;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-05-07 07:33:02 -07:00
|
|
|
virtual void
|
|
|
|
SetThreadLocals() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
UnsetThreadLocals() MOZ_OVERRIDE;
|
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
already_AddRefed<nsIDOMFile>
|
|
|
|
CreateFileObject(IDBFileHandle* aFileHandle, uint32_t aFileSize);
|
2014-02-24 12:56:13 -08:00
|
|
|
|
|
|
|
// nsWrapperCache
|
|
|
|
virtual JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-02-24 12:56:13 -08:00
|
|
|
// WebIDL
|
2014-07-17 09:40:54 -07:00
|
|
|
nsPIDOMWindow*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetName(nsString& aName) const
|
|
|
|
{
|
|
|
|
aName = mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetType(nsString& aType) const
|
|
|
|
{
|
|
|
|
aType = mType;
|
|
|
|
}
|
|
|
|
|
2013-07-31 08:48:46 -07:00
|
|
|
IDBDatabase*
|
2014-05-07 07:33:02 -07:00
|
|
|
Database()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
return mDatabase;
|
|
|
|
}
|
2013-07-01 00:02:37 -07:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
already_AddRefed<IDBFileHandle>
|
|
|
|
Open(FileMode aMode, ErrorResult& aError);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetFile(ErrorResult& aError);
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(abort)
|
|
|
|
IMPL_EVENT_HANDLER(error)
|
|
|
|
|
2012-06-03 09:33:52 -07:00
|
|
|
private:
|
2014-06-11 20:35:29 -07:00
|
|
|
IDBMutableFile(IDBDatabase* aOwner);
|
2014-07-17 09:40:54 -07:00
|
|
|
~IDBMutableFile();
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
nsString mName;
|
|
|
|
nsString mType;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-05-07 07:33:02 -07:00
|
|
|
nsRefPtr<IDBDatabase> mDatabase;
|
2012-06-03 09:33:52 -07:00
|
|
|
nsRefPtr<FileInfo> mFileInfo;
|
|
|
|
};
|
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-06-11 20:35:29 -07:00
|
|
|
#endif // mozilla_dom_indexeddb_idbmutablefile_h__
|