2012-06-03 20:33:52 +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-06-03 20:33:52 +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/. */
|
|
|
|
|
2016-02-17 00:46:08 +03:00
|
|
|
#ifndef mozilla_dom_idbmutablefile_h__
|
|
|
|
#define mozilla_dom_idbmutablefile_h__
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-07-17 20:40:54 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/Atomics.h"
|
2014-05-07 18:33:02 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-09-18 03:36:01 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/dom/FileModeBinding.h"
|
2014-05-07 18:33:02 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2015-09-09 14:15:05 +03:00
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTHashtable.h"
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowInner;
|
2014-07-17 20:40:54 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class DOMRequest;
|
2015-05-18 16:52:26 +03:00
|
|
|
class File;
|
2016-02-17 00:46:08 +03:00
|
|
|
class IDBDatabase;
|
|
|
|
class IDBFileHandle;
|
2014-07-17 20:40:54 +04:00
|
|
|
|
|
|
|
namespace indexedDB {
|
2015-09-09 14:15:05 +03:00
|
|
|
class BackgroundMutableFileChild;
|
2016-02-17 00:46:08 +03:00
|
|
|
}
|
2013-07-31 19:48:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class IDBMutableFile final
|
2014-09-27 03:21:57 +04:00
|
|
|
: public DOMEventTargetHelper
|
2012-06-03 20:33:52 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBDatabase> mDatabase;
|
2015-09-09 14:15:05 +03:00
|
|
|
|
2017-06-07 13:36:42 +03:00
|
|
|
indexedDB::BackgroundMutableFileChild* mBackgroundActor;
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
nsTHashtable<nsPtrHashKey<IDBFileHandle>> mFileHandles;
|
2014-05-07 18:33:02 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsString mName;
|
|
|
|
nsString mType;
|
|
|
|
|
|
|
|
Atomic<bool> mInvalidated;
|
|
|
|
|
|
|
|
public:
|
2015-09-09 14:15:05 +03:00
|
|
|
IDBMutableFile(IDBDatabase* aDatabase,
|
2016-02-17 00:46:08 +03:00
|
|
|
indexedDB::BackgroundMutableFileChild* aActor,
|
2015-09-09 14:15:05 +03:00
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aType);
|
2014-02-25 00:56:13 +04:00
|
|
|
|
2017-06-07 13:36:42 +03:00
|
|
|
void
|
|
|
|
AssertIsOnOwningThread() const
|
|
|
|
#ifdef DEBUG
|
|
|
|
;
|
|
|
|
#else
|
|
|
|
{ }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
indexedDB::BackgroundMutableFileChild*
|
|
|
|
GetBackgroundActor() const
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return mBackgroundActor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClearBackgroundActor()
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
mBackgroundActor = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsString&
|
|
|
|
Name() const
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsString&
|
|
|
|
Type() const
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
void
|
|
|
|
SetLazyData(const nsAString& aName,
|
|
|
|
const nsAString& aType)
|
2014-07-17 20:40:54 +04:00
|
|
|
{
|
2015-09-09 14:15:05 +03:00
|
|
|
mName = aName;
|
|
|
|
mType = aType;
|
2014-07-17 20:40:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int64_t
|
2014-09-27 03:21:57 +04:00
|
|
|
GetFileId() const;
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
Invalidate();
|
|
|
|
|
2017-06-07 13:36:42 +03:00
|
|
|
bool
|
|
|
|
IsInvalidated() const
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return mInvalidated;
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
void
|
|
|
|
RegisterFileHandle(IDBFileHandle* aFileHandle);
|
2014-05-07 18:33:02 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
void
|
|
|
|
UnregisterFileHandle(IDBFileHandle* aFileHandle);
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
void
|
|
|
|
AbortFileHandles();
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-02-25 00:56:13 +04:00
|
|
|
// WebIDL
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner*
|
2014-07-17 20:40:54 +04:00
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetName(nsString& aName) const
|
|
|
|
{
|
|
|
|
aName = mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetType(nsString& aType) const
|
|
|
|
{
|
|
|
|
aType = mType;
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:48:46 +04:00
|
|
|
IDBDatabase*
|
2014-09-27 03:21:57 +04:00
|
|
|
Database() const;
|
2013-07-01 11:02:37 +04:00
|
|
|
|
2014-07-17 20:40:54 +04: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 14:15:05 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBMutableFile, DOMEventTargetHelper)
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
// nsWrapperCache
|
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
private:
|
2014-09-27 03:21:57 +04:00
|
|
|
~IDBMutableFile();
|
2012-06-03 20:33:52 +04:00
|
|
|
};
|
|
|
|
|
2014-07-17 20:40:54 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2016-02-17 00:46:08 +03:00
|
|
|
#endif // mozilla_dom_idbmutablefile_h__
|