2012-06-01 10:21:12 -07: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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_indexeddb_ipc_indexeddbparent_h__
|
|
|
|
#define mozilla_dom_indexeddb_ipc_indexeddbparent_h__
|
|
|
|
|
2012-12-14 15:58:45 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
|
|
|
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBParent.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBCursorParent.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBDatabaseParent.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBDeleteDatabaseRequestParent.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBIndexParent.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBObjectStoreParent.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBRequestParent.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBTransactionParent.h"
|
|
|
|
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-07-14 04:24:20 -07:00
|
|
|
class ContentParent;
|
2012-08-01 23:02:29 -07:00
|
|
|
class PBlobParent;
|
2012-06-01 10:21:12 -07:00
|
|
|
class TabParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
class nsIDOMBlob;
|
2012-06-01 10:21:12 -07:00
|
|
|
class nsIDOMEvent;
|
|
|
|
|
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
|
|
|
class IDBCursor;
|
|
|
|
class IDBDatabase;
|
|
|
|
class IDBFactory;
|
|
|
|
class IDBIndex;
|
|
|
|
class IDBObjectStore;
|
|
|
|
class IDBOpenDBRequest;
|
|
|
|
class IDBTransaction;
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
class IndexedDBCursorParent;
|
|
|
|
class IndexedDBDatabaseParent;
|
|
|
|
class IndexedDBDeleteDatabaseRequestParent;
|
|
|
|
class IndexedDBIndexParent;
|
|
|
|
class IndexedDBObjectStoreParent;
|
|
|
|
class IndexedDBTransactionParent;
|
|
|
|
class IndexedDBVersionChangeTransactionParent;
|
|
|
|
class IndexedDBVersionChangeObjectStoreParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
/*******************************************************************************
|
|
|
|
* AutoSetCurrentTransaction
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class AutoSetCurrentTransaction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoSetCurrentTransaction(IDBTransaction* aTransaction);
|
|
|
|
~AutoSetCurrentTransaction();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* WeakEventListener
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WeakEventListenerBase : public nsIDOMEventListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
|
|
|
|
protected:
|
|
|
|
WeakEventListenerBase()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual ~WeakEventListenerBase()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
class WeakEventListener : public WeakEventListenerBase
|
|
|
|
{
|
|
|
|
T* mActor;
|
|
|
|
|
|
|
|
public:
|
|
|
|
WeakEventListener(T* aActor)
|
|
|
|
: mActor(aActor)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void
|
|
|
|
NoteDyingActor()
|
|
|
|
{
|
2013-11-25 11:01:59 -08:00
|
|
|
mActor = nullptr;
|
2012-06-01 10:21:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD
|
2013-06-05 09:15:48 -07:00
|
|
|
HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
|
|
|
return mActor ? mActor->HandleEvent(aEvent) : NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~WeakEventListener()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
class AutoWeakEventListener
|
|
|
|
{
|
|
|
|
nsRefPtr<WeakEventListener<T> > mEventListener;
|
|
|
|
|
|
|
|
public:
|
|
|
|
AutoWeakEventListener(T* aActor)
|
|
|
|
{
|
|
|
|
mEventListener = new WeakEventListener<T>(aActor);
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoWeakEventListener()
|
|
|
|
{
|
|
|
|
mEventListener->NoteDyingActor();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class U>
|
|
|
|
operator U*()
|
|
|
|
{
|
|
|
|
return mEventListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
T*
|
|
|
|
operator ->()
|
|
|
|
{
|
|
|
|
return mEventListener;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
class IndexedDBParent : private PIndexedDBParent
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-07-14 04:24:20 -07:00
|
|
|
friend class mozilla::dom::ContentParent;
|
2012-06-01 10:21:12 -07:00
|
|
|
friend class mozilla::dom::TabParent;
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBDatabaseParent;
|
|
|
|
friend class IndexedDBDeleteDatabaseRequestParent;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
nsRefPtr<IDBFactory> mFactory;
|
|
|
|
nsCString mASCIIOrigin;
|
2012-10-25 10:12:14 -07:00
|
|
|
|
|
|
|
ContentParent* mManagerContent;
|
|
|
|
TabParent* mManagerTab;
|
|
|
|
|
2012-10-05 12:09:33 -07:00
|
|
|
bool mDisconnected;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
public:
|
2012-10-25 10:12:14 -07:00
|
|
|
IndexedDBParent(ContentParent* aContentParent);
|
|
|
|
IndexedDBParent(TabParent* aTabParent);
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
virtual ~IndexedDBParent();
|
|
|
|
|
|
|
|
const nsCString&
|
|
|
|
GetASCIIOrigin() const
|
|
|
|
{
|
|
|
|
return mASCIIOrigin;
|
|
|
|
}
|
|
|
|
|
2012-10-05 12:09:33 -07:00
|
|
|
void
|
|
|
|
Disconnect();
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
return mDisconnected;
|
|
|
|
}
|
|
|
|
|
2012-10-25 10:12:14 -07:00
|
|
|
ContentParent*
|
|
|
|
GetManagerContent() const
|
|
|
|
{
|
|
|
|
return mManagerContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
TabParent*
|
|
|
|
GetManagerTab() const
|
|
|
|
{
|
|
|
|
return mManagerTab;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CheckReadPermission(const nsAString& aDatabaseName);
|
|
|
|
|
|
|
|
bool
|
|
|
|
CheckWritePermission(const nsAString& aDatabaseName);
|
|
|
|
|
2013-06-03 03:14:37 -07:00
|
|
|
mozilla::ipc::IProtocol*
|
|
|
|
CloneProtocol(Channel* aChannel,
|
|
|
|
mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
protected:
|
2012-10-25 10:12:14 -07:00
|
|
|
bool
|
|
|
|
CheckPermissionInternal(const nsAString& aDatabaseName,
|
2014-01-08 12:51:38 -08:00
|
|
|
const nsACString& aPermission);
|
2012-10-25 10:12:14 -07:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBDatabaseConstructor(PIndexedDBDatabaseParent* aActor,
|
|
|
|
const nsString& aName,
|
2013-09-10 21:18:36 -07:00
|
|
|
const uint64_t& aVersion,
|
|
|
|
const PersistenceType& aPersistenceType)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBDeleteDatabaseRequestConstructor(
|
|
|
|
PIndexedDBDeleteDatabaseRequestParent* aActor,
|
2013-09-10 21:18:36 -07:00
|
|
|
const nsString& aName,
|
|
|
|
const PersistenceType& aPersistenceType)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual PIndexedDBDatabaseParent*
|
2013-09-10 21:18:36 -07:00
|
|
|
AllocPIndexedDBDatabaseParent(const nsString& aName, const uint64_t& aVersion,
|
|
|
|
const PersistenceType& aPersistenceType)
|
2013-07-08 08:48:39 -07:00
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBDatabaseParent(PIndexedDBDatabaseParent* aActor) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual PIndexedDBDeleteDatabaseRequestParent*
|
2013-09-10 21:18:36 -07:00
|
|
|
AllocPIndexedDBDeleteDatabaseRequestParent(
|
|
|
|
const nsString& aName,
|
|
|
|
const PersistenceType& aPersistenceType)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBDeleteDatabaseRequestParent(
|
2012-06-01 10:21:12 -07:00
|
|
|
PIndexedDBDeleteDatabaseRequestParent* aActor)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBDatabaseParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
class IndexedDBDatabaseParent : private PIndexedDBDatabaseParent
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBParent;
|
|
|
|
friend class IndexedDBTransactionParent;
|
|
|
|
friend class IndexedDBVersionChangeTransactionParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
AutoWeakEventListener<IndexedDBDatabaseParent> mEventListener;
|
|
|
|
|
|
|
|
nsRefPtr<IDBOpenDBRequest> mOpenRequest;
|
|
|
|
nsRefPtr<IDBDatabase> mDatabase;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IndexedDBDatabaseParent();
|
|
|
|
virtual ~IndexedDBDatabaseParent();
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
SetOpenRequest(IDBOpenDBRequest* aRequest);
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
HandleEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
2012-10-05 12:09:33 -07:00
|
|
|
void
|
|
|
|
Disconnect();
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
return static_cast<IndexedDBParent*>(Manager())->IsDisconnected();
|
|
|
|
}
|
|
|
|
|
2012-10-25 10:12:14 -07:00
|
|
|
bool
|
|
|
|
CheckWritePermission(const nsAString& aDatabaseName);
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
void
|
|
|
|
Invalidate();
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
protected:
|
|
|
|
nsresult
|
|
|
|
HandleRequestEvent(nsIDOMEvent* aEvent, const nsAString& aType);
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
HandleDatabaseEvent(nsIDOMEvent* aEvent, const nsAString& aType);
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvClose(const bool& aUnlinked) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBTransactionConstructor(PIndexedDBTransactionParent* aActor,
|
|
|
|
const TransactionParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual PIndexedDBTransactionParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBTransactionParent(const TransactionParams& aParams) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBTransactionParent(PIndexedDBTransactionParent* aActor)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBTransactionParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
class IndexedDBTransactionParent : protected PIndexedDBTransactionParent
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBCursorParent;
|
|
|
|
friend class IndexedDBDatabaseParent;
|
|
|
|
friend class IndexedDBObjectStoreParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
protected:
|
|
|
|
AutoWeakEventListener<IndexedDBTransactionParent> mEventListener;
|
|
|
|
|
|
|
|
nsRefPtr<IDBTransaction> mTransaction;
|
|
|
|
|
|
|
|
bool mArtificialRequestCount;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IndexedDBTransactionParent();
|
|
|
|
virtual ~IndexedDBTransactionParent();
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
return static_cast<IndexedDBDatabaseParent*>(Manager())->IsDisconnected();
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
nsresult
|
|
|
|
SetTransaction(IDBTransaction* aTransaction);
|
|
|
|
|
|
|
|
IDBTransaction*
|
|
|
|
GetTransaction() const
|
|
|
|
{
|
|
|
|
return mTransaction;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
HandleEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvAbort(const nsresult& aAbortCode) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvAllRequestsFinished() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvDeleteObjectStore(const nsString& aName) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBObjectStoreConstructor(
|
|
|
|
PIndexedDBObjectStoreParent* aActor,
|
|
|
|
const ObjectStoreConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual PIndexedDBObjectStoreParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBObjectStoreParent(const ObjectStoreConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBObjectStoreParent(PIndexedDBObjectStoreParent* aActor)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBVersionChangeTransactionParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class IndexedDBVersionChangeTransactionParent :
|
|
|
|
public IndexedDBTransactionParent
|
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBVersionChangeObjectStoreParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
public:
|
|
|
|
IndexedDBVersionChangeTransactionParent();
|
|
|
|
virtual ~IndexedDBVersionChangeTransactionParent();
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
return static_cast<IndexedDBDatabaseParent*>(Manager())->IsDisconnected();
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
protected:
|
|
|
|
virtual bool
|
|
|
|
RecvDeleteObjectStore(const nsString& aName) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBObjectStoreConstructor(
|
|
|
|
PIndexedDBObjectStoreParent* aActor,
|
|
|
|
const ObjectStoreConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual PIndexedDBObjectStoreParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBObjectStoreParent(const ObjectStoreConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBCursorParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class IndexedDBCursorParent : private PIndexedDBCursorParent
|
|
|
|
{
|
|
|
|
friend class IndexedDBIndexParent;
|
|
|
|
friend class IndexedDBObjectStoreParent;
|
|
|
|
|
|
|
|
nsRefPtr<IDBCursor> mCursor;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IDBCursor*
|
|
|
|
GetCursor() const
|
|
|
|
{
|
|
|
|
return mCursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsDisconnected() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
IndexedDBCursorParent(IDBCursor* aCursor);
|
|
|
|
virtual ~IndexedDBCursorParent();
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor,
|
|
|
|
const CursorRequestParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual PIndexedDBRequestParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBRequestParent(const CursorRequestParams& aParams) MOZ_OVERRIDE;
|
2012-11-09 19:29:07 -08:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE;
|
2012-11-09 19:29:07 -08:00
|
|
|
};
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBObjectStoreParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
class IndexedDBObjectStoreParent : protected PIndexedDBObjectStoreParent
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBIndexParent;
|
|
|
|
friend class IndexedDBTransactionParent;
|
|
|
|
friend class IndexedDBVersionChangeTransactionParent;
|
|
|
|
|
|
|
|
typedef mozilla::dom::indexedDB::ipc::OpenCursorResponse OpenCursorResponse;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
protected:
|
|
|
|
nsRefPtr<IDBObjectStore> mObjectStore;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IndexedDBObjectStoreParent();
|
|
|
|
virtual ~IndexedDBObjectStoreParent();
|
|
|
|
|
|
|
|
void
|
|
|
|
SetObjectStore(IDBObjectStore* aObjectStore);
|
|
|
|
|
|
|
|
IDBObjectStore*
|
|
|
|
GetObjectStore() const
|
|
|
|
{
|
|
|
|
return mObjectStore;
|
|
|
|
}
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
IndexedDBTransactionParent* manager =
|
|
|
|
static_cast<IndexedDBTransactionParent*>(Manager());
|
|
|
|
return manager->IsDisconnected();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ordinarily callers could just do this manually using
|
|
|
|
// PIndexedDBObjectStoreParent::SendPIndexedDBCursorConstructor but we're
|
|
|
|
// inheriting the abstract protocol class privately to prevent outside code
|
|
|
|
// from sending messages without checking the disconnected state. Therefore
|
|
|
|
// we need a helper method.
|
|
|
|
bool
|
|
|
|
OpenCursor(IDBCursor* aCursor,
|
|
|
|
const ObjectStoreCursorConstructorParams& aParams,
|
|
|
|
OpenCursorResponse& aResponse) NS_WARN_UNUSED_RESULT
|
|
|
|
{
|
|
|
|
if (IsDisconnected()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
IndexedDBCursorParent* cursorActor = new IndexedDBCursorParent(aCursor);
|
|
|
|
|
|
|
|
if (!SendPIndexedDBCursorConstructor(cursorActor, aParams)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aResponse = cursorActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
protected:
|
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvDeleteIndex(const nsString& aName) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor,
|
|
|
|
const ObjectStoreRequestParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBIndexConstructor(PIndexedDBIndexParent* aActor,
|
|
|
|
const IndexConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual PIndexedDBRequestParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBRequestParent(const ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual PIndexedDBIndexParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBIndexParent(const IndexConstructorParams& aParams) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBIndexParent(PIndexedDBIndexParent* aActor) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual PIndexedDBCursorParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBCursorParent(const ObjectStoreCursorConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBCursorParent(PIndexedDBCursorParent* aActor) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBVersionChangeObjectStoreParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class IndexedDBVersionChangeObjectStoreParent :
|
|
|
|
public IndexedDBObjectStoreParent
|
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBVersionChangeTransactionParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
public:
|
|
|
|
IndexedDBVersionChangeObjectStoreParent();
|
|
|
|
virtual ~IndexedDBVersionChangeObjectStoreParent();
|
|
|
|
|
|
|
|
protected:
|
2012-11-09 19:29:07 -08:00
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
IndexedDBVersionChangeTransactionParent* manager =
|
|
|
|
static_cast<IndexedDBVersionChangeTransactionParent*>(Manager());
|
|
|
|
return manager->IsDisconnected();
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
virtual bool
|
|
|
|
RecvDeleteIndex(const nsString& aName) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBIndexConstructor(PIndexedDBIndexParent* aActor,
|
|
|
|
const IndexConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBIndexParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
class IndexedDBIndexParent : private PIndexedDBIndexParent
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBObjectStoreParent;
|
|
|
|
friend class IndexedDBVersionChangeObjectStoreParent;
|
|
|
|
|
|
|
|
typedef mozilla::dom::indexedDB::ipc::OpenCursorResponse OpenCursorResponse;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
nsRefPtr<IDBIndex> mIndex;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IndexedDBIndexParent();
|
|
|
|
virtual ~IndexedDBIndexParent();
|
|
|
|
|
|
|
|
void
|
|
|
|
SetIndex(IDBIndex* aObjectStore);
|
|
|
|
|
|
|
|
IDBIndex*
|
|
|
|
GetIndex() const
|
|
|
|
{
|
|
|
|
return mIndex;
|
|
|
|
}
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
// Ordinarily callers could just do this manually using
|
|
|
|
// PIndexedDBIndexParent::SendPIndexedDBCursorConstructor but we're
|
|
|
|
// inheriting the abstract protocol class privately to prevent outside code
|
|
|
|
// from sending messages without checking the disconnected state. Therefore
|
|
|
|
// we need a helper method.
|
|
|
|
bool
|
|
|
|
OpenCursor(IDBCursor* aCursor, const IndexCursorConstructorParams& aParams,
|
|
|
|
OpenCursorResponse& aResponse) NS_WARN_UNUSED_RESULT
|
|
|
|
{
|
|
|
|
if (IsDisconnected()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
IndexedDBCursorParent* cursorActor = new IndexedDBCursorParent(aCursor);
|
|
|
|
|
|
|
|
if (!SendPIndexedDBCursorConstructor(cursorActor, aParams)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aResponse = cursorActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
IndexedDBObjectStoreParent* manager =
|
|
|
|
static_cast<IndexedDBObjectStoreParent*>(Manager());
|
|
|
|
return manager->IsDisconnected();
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
protected:
|
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor,
|
|
|
|
const IndexRequestParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual PIndexedDBRequestParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBRequestParent(const IndexRequestParams& aParams) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual PIndexedDBCursorParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
AllocPIndexedDBCursorParent(const IndexCursorConstructorParams& aParams)
|
|
|
|
MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-07-08 08:48:39 -07:00
|
|
|
DeallocPIndexedDBCursorParent(PIndexedDBCursorParent* aActor) MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2012-11-09 19:29:07 -08:00
|
|
|
* IndexedDBRequestParentBase
|
2012-06-01 10:21:12 -07:00
|
|
|
******************************************************************************/
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
class IndexedDBRequestParentBase : public PIndexedDBRequestParent
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-11-09 19:29:07 -08:00
|
|
|
bool
|
|
|
|
SendResponse(const ResponseValue& aResponse) NS_WARN_UNUSED_RESULT
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
if (IsDisconnected()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Send__delete__(this, aResponse);
|
2012-06-01 10:21:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2012-11-09 19:29:07 -08:00
|
|
|
// Don't let anyone call this directly, instead go through SendResponse.
|
|
|
|
using PIndexedDBRequestParent::Send__delete__;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
typedef ipc::ResponseValue ResponseValue;
|
2012-11-09 19:29:07 -08:00
|
|
|
typedef PIndexedDBRequestParent::PBlobParent PBlobParent;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
nsRefPtr<IDBRequest> mRequest;
|
|
|
|
|
|
|
|
IndexedDBRequestParentBase();
|
|
|
|
virtual ~IndexedDBRequestParentBase();
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
2012-11-09 19:29:07 -08:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsDisconnected() = 0;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBObjectStoreRequestParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class IndexedDBObjectStoreRequestParent : public IndexedDBRequestParentBase
|
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBObjectStoreParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
nsRefPtr<IDBObjectStore> mObjectStore;
|
|
|
|
|
|
|
|
typedef ipc::ObjectStoreRequestParams ParamsUnionType;
|
|
|
|
typedef ParamsUnionType::Type RequestType;
|
2012-08-07 00:06:29 -07:00
|
|
|
DebugOnly<RequestType> mRequestType;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
typedef ipc::AddParams AddParams;
|
|
|
|
typedef ipc::PutParams PutParams;
|
|
|
|
typedef ipc::ClearParams ClearParams;
|
|
|
|
typedef ipc::DeleteParams DeleteParams;
|
2013-08-06 05:44:01 -07:00
|
|
|
typedef ipc::GetParams GetParams;
|
|
|
|
typedef ipc::GetAllParams GetAllParams;
|
2013-09-24 10:14:16 -07:00
|
|
|
typedef ipc::GetAllKeysParams GetAllKeysParams;
|
2013-08-06 05:44:01 -07:00
|
|
|
typedef ipc::CountParams CountParams;
|
|
|
|
typedef ipc::OpenCursorParams OpenCursorParams;
|
2013-09-25 16:11:47 -07:00
|
|
|
typedef ipc::OpenKeyCursorParams OpenKeyCursorParams;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
IndexedDBObjectStoreRequestParent(IDBObjectStore* aObjectStore,
|
|
|
|
RequestType aRequestType);
|
|
|
|
virtual ~IndexedDBObjectStoreRequestParent();
|
|
|
|
|
|
|
|
bool
|
|
|
|
Get(const GetParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetAll(const GetAllParams& aParams);
|
|
|
|
|
2013-09-24 10:14:16 -07:00
|
|
|
bool
|
|
|
|
GetAllKeys(const GetAllKeysParams& aParams);
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
bool
|
|
|
|
Add(const AddParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
Put(const PutParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
Delete(const DeleteParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
Clear(const ClearParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
Count(const CountParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
OpenCursor(const OpenCursorParams& aParams);
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2013-09-25 16:11:47 -07:00
|
|
|
bool
|
|
|
|
OpenKeyCursor(const OpenKeyCursorParams& aParams);
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
protected:
|
|
|
|
void
|
|
|
|
ConvertBlobActors(const InfallibleTArray<PBlobParent*>& aActors,
|
|
|
|
nsTArray<nsCOMPtr<nsIDOMBlob> >& aBlobs);
|
2012-11-09 19:29:07 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool
|
|
|
|
IsDisconnected() MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBIndexRequestParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class IndexedDBIndexRequestParent : public IndexedDBRequestParentBase
|
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBIndexParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
nsRefPtr<IDBIndex> mIndex;
|
|
|
|
|
|
|
|
typedef ipc::IndexRequestParams ParamsUnionType;
|
|
|
|
typedef ParamsUnionType::Type RequestType;
|
2012-08-07 00:06:29 -07:00
|
|
|
DebugOnly<RequestType> mRequestType;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
typedef ipc::GetKeyParams GetKeyParams;
|
|
|
|
typedef ipc::GetAllKeysParams GetAllKeysParams;
|
|
|
|
typedef ipc::OpenKeyCursorParams OpenKeyCursorParams;
|
2013-08-06 05:44:01 -07:00
|
|
|
typedef ipc::GetParams GetParams;
|
|
|
|
typedef ipc::GetAllParams GetAllParams;
|
|
|
|
typedef ipc::CountParams CountParams;
|
|
|
|
typedef ipc::OpenCursorParams OpenCursorParams;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
IndexedDBIndexRequestParent(IDBIndex* aIndex, RequestType aRequestType);
|
|
|
|
virtual ~IndexedDBIndexRequestParent();
|
|
|
|
|
|
|
|
bool
|
|
|
|
Get(const GetParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetKey(const GetKeyParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetAll(const GetAllParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetAllKeys(const GetAllKeysParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
Count(const CountParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
OpenCursor(const OpenCursorParams& aParams);
|
|
|
|
|
|
|
|
bool
|
|
|
|
OpenKeyCursor(const OpenKeyCursorParams& aParams);
|
2012-11-09 19:29:07 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool
|
|
|
|
IsDisconnected() MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBCursorRequestParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class IndexedDBCursorRequestParent : public IndexedDBRequestParentBase
|
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBCursorParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
nsRefPtr<IDBCursor> mCursor;
|
|
|
|
|
|
|
|
typedef ipc::CursorRequestParams ParamsUnionType;
|
|
|
|
typedef ParamsUnionType::Type RequestType;
|
2012-08-07 00:06:29 -07:00
|
|
|
DebugOnly<RequestType> mRequestType;
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
typedef ipc::ContinueParams ContinueParams;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IndexedDBCursorRequestParent(IDBCursor* aCursor, RequestType aRequestType);
|
|
|
|
virtual ~IndexedDBCursorRequestParent();
|
|
|
|
|
|
|
|
bool
|
|
|
|
Continue(const ContinueParams& aParams);
|
2012-11-09 19:29:07 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool
|
|
|
|
IsDisconnected() MOZ_OVERRIDE;
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IndexedDBDeleteDatabaseRequestParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class IndexedDBDeleteDatabaseRequestParent :
|
2012-11-09 19:29:07 -08:00
|
|
|
private PIndexedDBDeleteDatabaseRequestParent
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-11-09 19:29:07 -08:00
|
|
|
friend class IndexedDBParent;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
AutoWeakEventListener<IndexedDBDeleteDatabaseRequestParent> mEventListener;
|
|
|
|
|
|
|
|
nsRefPtr<IDBFactory> mFactory;
|
|
|
|
nsRefPtr<IDBOpenDBRequest> mOpenRequest;
|
|
|
|
|
|
|
|
public:
|
2012-11-09 19:29:07 -08:00
|
|
|
nsresult
|
|
|
|
HandleEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
|
|
|
protected:
|
2012-06-01 10:21:12 -07:00
|
|
|
IndexedDBDeleteDatabaseRequestParent(IDBFactory* aFactory);
|
|
|
|
virtual ~IndexedDBDeleteDatabaseRequestParent();
|
|
|
|
|
2014-05-02 11:44:13 -07:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
nsresult
|
|
|
|
SetOpenRequest(IDBOpenDBRequest* aOpenRequest);
|
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
bool
|
|
|
|
IsDisconnected() const
|
|
|
|
{
|
|
|
|
return static_cast<IndexedDBParent*>(Manager())->IsDisconnected();
|
|
|
|
}
|
2012-06-01 10:21:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_indexeddb_ipc_indexeddbparent_h__
|