2012-06-03 16:33:52 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 19:32:37 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-06-03 16:33:52 +00: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/. */
|
|
|
|
|
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
|
|
|
|
2014-07-17 16:40:54 +00:00
|
|
|
#include "js/TypeDecls.h"
|
2014-09-26 23:21:57 +00:00
|
|
|
#include "mozilla/Atomics.h"
|
2014-05-07 14:33:02 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-09-17 23:36:01 +00:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2014-09-26 23:21:57 +00:00
|
|
|
#include "mozilla/dom/FileModeBinding.h"
|
2015-09-09 11:15:05 +00:00
|
|
|
#include "mozilla/dom/MutableFileBase.h"
|
2014-07-17 16:40:54 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2014-05-07 14:33:02 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2015-09-09 11:15:05 +00:00
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTHashtable.h"
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-07-17 16:40:54 +00:00
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class DOMRequest;
|
2015-05-18 13:52:26 +00:00
|
|
|
class File;
|
2014-07-17 16:40:54 +00:00
|
|
|
|
|
|
|
namespace indexedDB {
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
class BackgroundMutableFileChild;
|
2013-07-31 15:48:46 +00:00
|
|
|
class IDBDatabase;
|
2014-07-17 16:40:54 +00:00
|
|
|
class IDBFileHandle;
|
2013-07-31 15:48:46 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class IDBMutableFile final
|
2014-09-26 23:21:57 +00:00
|
|
|
: public DOMEventTargetHelper
|
|
|
|
, public MutableFileBase
|
2012-06-03 16:33:52 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDBDatabase> mDatabase;
|
2015-09-09 11:15:05 +00:00
|
|
|
|
|
|
|
nsTHashtable<nsPtrHashKey<IDBFileHandle>> mFileHandles;
|
2014-05-07 14:33:02 +00:00
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
nsString mName;
|
|
|
|
nsString mType;
|
|
|
|
|
|
|
|
Atomic<bool> mInvalidated;
|
|
|
|
|
|
|
|
public:
|
2015-09-09 11:15:05 +00:00
|
|
|
IDBMutableFile(IDBDatabase* aDatabase,
|
|
|
|
BackgroundMutableFileChild* aActor,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aType);
|
2014-02-24 20:56:13 +00:00
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
void
|
|
|
|
SetLazyData(const nsAString& aName,
|
|
|
|
const nsAString& aType)
|
2014-07-17 16:40:54 +00:00
|
|
|
{
|
2015-09-09 11:15:05 +00:00
|
|
|
mName = aName;
|
|
|
|
mType = aType;
|
2014-07-17 16:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int64_t
|
2014-09-26 23:21:57 +00:00
|
|
|
GetFileId() const;
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
void
|
|
|
|
Invalidate();
|
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
void
|
|
|
|
RegisterFileHandle(IDBFileHandle* aFileHandle);
|
2014-05-07 14:33:02 +00:00
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
void
|
|
|
|
UnregisterFileHandle(IDBFileHandle* aFileHandle);
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
void
|
|
|
|
AbortFileHandles();
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-02-24 20:56:13 +00:00
|
|
|
// WebIDL
|
2014-07-17 16:40:54 +00:00
|
|
|
nsPIDOMWindow*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetName(nsString& aName) const
|
|
|
|
{
|
|
|
|
aName = mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetType(nsString& aType) const
|
|
|
|
{
|
|
|
|
aType = mType;
|
|
|
|
}
|
|
|
|
|
2013-07-31 15:48:46 +00:00
|
|
|
IDBDatabase*
|
2014-09-26 23:21:57 +00:00
|
|
|
Database() const;
|
2013-07-01 07:02:37 +00:00
|
|
|
|
2014-07-17 16:40:54 +00:00
|
|
|
already_AddRefed<IDBFileHandle>
|
|
|
|
Open(FileMode aMode, ErrorResult& aError);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetFile(ErrorResult& aError);
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(abort)
|
|
|
|
IMPL_EVENT_HANDLER(error)
|
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBMutableFile, DOMEventTargetHelper)
|
2014-09-17 23:36:01 +00:00
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
// nsWrapperCache
|
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
// MutableFileBase
|
|
|
|
virtual const nsString&
|
|
|
|
Name() const override;
|
|
|
|
|
|
|
|
virtual const nsString&
|
|
|
|
Type() const override;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsInvalidated() override;
|
|
|
|
|
|
|
|
virtual already_AddRefed<File>
|
|
|
|
CreateFileFor(BlobImpl* aBlobImpl,
|
|
|
|
FileHandleBase* aFileHandle) override;
|
|
|
|
|
|
|
|
private:
|
2014-09-26 23:21:57 +00:00
|
|
|
~IDBMutableFile();
|
2012-06-03 16:33:52 +00:00
|
|
|
};
|
|
|
|
|
2014-07-17 16:40:54 +00:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-06-12 03:35:29 +00:00
|
|
|
#endif // mozilla_dom_indexeddb_idbmutablefile_h__
|