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-09-26 16:21:57 -07:00
|
|
|
#include "mozilla/Atomics.h"
|
2014-05-07 07:33:02 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-07-17 09:40:54 -07:00
|
|
|
#include "mozilla/dom/FileModeBinding.h"
|
2014-09-17 16:36:01 -07:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2014-09-26 16:21:57 -07:00
|
|
|
#include "mozilla/dom/FileModeBinding.h"
|
|
|
|
#include "mozilla/dom/MutableFile.h"
|
|
|
|
#include "mozilla/dom/quota/PersistenceType.h"
|
2014-07-17 09:40:54 -07:00
|
|
|
#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;
|
2014-09-26 16:21:57 -07:00
|
|
|
class MetadataParameters;
|
2014-07-17 09:40:54 -07:00
|
|
|
|
|
|
|
namespace indexedDB {
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-09-26 16:21:57 -07:00
|
|
|
class FileInfo;
|
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
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class IDBMutableFile final
|
2014-09-26 16:21:57 -07:00
|
|
|
: public DOMEventTargetHelper
|
|
|
|
, public MutableFileBase
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
2014-09-26 16:21:57 -07:00
|
|
|
typedef mozilla::dom::MetadataParameters MetadataParameters;
|
|
|
|
typedef mozilla::dom::quota::PersistenceType PersistenceType;
|
2014-05-07 07:33:02 -07:00
|
|
|
|
2014-09-26 16:21:57 -07:00
|
|
|
nsString mName;
|
|
|
|
nsString mType;
|
|
|
|
|
|
|
|
nsRefPtr<IDBDatabase> mDatabase;
|
|
|
|
nsRefPtr<FileInfo> mFileInfo;
|
|
|
|
|
|
|
|
const nsCString mGroup;
|
|
|
|
const nsCString mOrigin;
|
|
|
|
const PersistenceType mPersistenceType;
|
2014-09-13 09:12:19 -07:00
|
|
|
|
2014-09-26 16:21:57 -07:00
|
|
|
Atomic<bool> mInvalidated;
|
|
|
|
|
|
|
|
public:
|
2014-06-11 20:35:29 -07:00
|
|
|
static already_AddRefed<IDBMutableFile>
|
2014-09-26 16:21:57 -07:00
|
|
|
Create(IDBDatabase* aDatabase,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aType,
|
|
|
|
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
|
2014-09-26 16:21:57 -07:00
|
|
|
GetFileId() const;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-07-17 09:40:54 -07:00
|
|
|
FileInfo*
|
|
|
|
GetFileInfo() const
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
|
|
|
return mFileInfo;
|
|
|
|
}
|
|
|
|
|
2014-09-26 16:21:57 -07:00
|
|
|
already_AddRefed<nsIDOMFile>
|
|
|
|
CreateFileObject(IDBFileHandle* aFileHandle,
|
|
|
|
MetadataParameters* aMetadataParams);
|
|
|
|
|
|
|
|
void
|
|
|
|
Invalidate();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBMutableFile, DOMEventTargetHelper)
|
|
|
|
|
2014-05-07 07:33:02 -07:00
|
|
|
virtual bool
|
2015-03-21 09:28:04 -07:00
|
|
|
IsInvalid() override;
|
2014-05-07 07:33:02 -07:00
|
|
|
|
|
|
|
virtual nsIOfflineStorage*
|
2015-03-21 09:28:04 -07:00
|
|
|
Storage() override;
|
2014-05-07 07:33:02 -07:00
|
|
|
|
2012-06-03 09:33:52 -07:00
|
|
|
virtual already_AddRefed<nsISupports>
|
2015-03-21 09:28:04 -07:00
|
|
|
CreateStream(bool aReadOnly) override;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-02-24 12:56:13 -08:00
|
|
|
// nsWrapperCache
|
|
|
|
virtual JSObject*
|
2015-03-21 09:28:04 -07:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) 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-09-26 16:21:57 -07:00
|
|
|
Database() const;
|
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-09-26 16:21:57 -07:00
|
|
|
IDBMutableFile(IDBDatabase* aDatabase,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aType,
|
|
|
|
already_AddRefed<FileInfo> aFileInfo,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
|
|
|
const nsACString& aStorageId,
|
|
|
|
PersistenceType aPersistenceType,
|
|
|
|
already_AddRefed<nsIFile> aFile);
|
2014-09-17 16:36:01 -07:00
|
|
|
|
2014-09-26 16:21:57 -07:00
|
|
|
~IDBMutableFile();
|
2012-06-03 09:33:52 -07:00
|
|
|
};
|
|
|
|
|
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__
|