2010-06-23 23:46:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +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/. */
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-06-28 20:44:30 +04:00
|
|
|
#ifndef mozilla_dom_indexeddb_idbfactory_h__
|
|
|
|
#define mozilla_dom_indexeddb_idbfactory_h__
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-09-10 02:15:38 +04:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
|
|
|
#include "mozIStorageConnection.h"
|
2010-06-28 20:44:30 +04:00
|
|
|
#include "nsIIDBFactory.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2011-01-27 04:53:02 +03:00
|
|
|
|
2012-01-23 20:18:14 +04:00
|
|
|
class nsIAtom;
|
2012-01-24 14:03:37 +04:00
|
|
|
class nsPIDOMWindow;
|
2011-01-27 04:53:02 +03:00
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-10-19 21:58:52 +04:00
|
|
|
struct DatabaseInfo;
|
2010-09-10 02:15:40 +04:00
|
|
|
class IDBDatabase;
|
2012-06-01 21:21:12 +04:00
|
|
|
class IDBOpenDBRequest;
|
|
|
|
class IndexedDBChild;
|
|
|
|
class IndexedDBParent;
|
|
|
|
|
2010-10-19 21:58:52 +04:00
|
|
|
struct ObjectStoreInfo;
|
2010-09-10 02:15:40 +04:00
|
|
|
|
2012-05-15 08:50:29 +04:00
|
|
|
class IDBFactory MOZ_FINAL : public nsIIDBFactory
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
2011-12-17 04:40:47 +04:00
|
|
|
typedef nsTArray<nsRefPtr<ObjectStoreInfo> > ObjectStoreInfoArray;
|
2012-01-24 14:03:37 +04:00
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
public:
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
|
2010-06-28 20:44:30 +04:00
|
|
|
NS_DECL_NSIIDBFACTORY
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2012-07-14 15:24:20 +04:00
|
|
|
// Called when using IndexedDB from a window in a different process.
|
2012-06-01 21:21:12 +04:00
|
|
|
static nsresult Create(nsPIDOMWindow* aWindow,
|
|
|
|
const nsACString& aASCIIOrigin,
|
|
|
|
IDBFactory** aFactory);
|
|
|
|
|
2012-07-14 15:24:20 +04:00
|
|
|
// Called when using IndexedDB from a window in the current process.
|
2012-06-01 21:21:12 +04:00
|
|
|
static nsresult Create(nsPIDOMWindow* aWindow,
|
|
|
|
nsIIDBFactory** aFactory)
|
|
|
|
{
|
|
|
|
nsRefPtr<IDBFactory> factory;
|
|
|
|
nsresult rv = Create(aWindow, EmptyCString(), getter_AddRefs(factory));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
factory.forget(aFactory);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-14 15:24:20 +04:00
|
|
|
// Called when using IndexedDB from a JS component or a JSM in the current
|
|
|
|
// process.
|
2012-06-01 21:21:12 +04:00
|
|
|
static nsresult Create(JSContext* aCx,
|
|
|
|
JSObject* aOwningObject,
|
|
|
|
IDBFactory** aFactory);
|
2012-01-24 14:03:37 +04:00
|
|
|
|
2012-07-14 15:24:20 +04:00
|
|
|
// Called when using IndexedDB from a JS component or a JSM in a different
|
|
|
|
// process.
|
|
|
|
static nsresult Create(IDBFactory** aFactory);
|
|
|
|
|
2010-09-10 02:15:40 +04:00
|
|
|
static already_AddRefed<mozIStorageConnection>
|
2010-06-23 23:46:08 +04:00
|
|
|
GetConnection(const nsAString& aDatabaseFilePath);
|
|
|
|
|
2010-10-19 21:58:52 +04:00
|
|
|
static nsresult
|
|
|
|
LoadDatabaseInformation(mozIStorageConnection* aConnection,
|
2011-11-02 16:53:12 +04:00
|
|
|
nsIAtom* aDatabaseId,
|
2011-10-20 20:10:56 +04:00
|
|
|
PRUint64* aVersion,
|
2010-10-19 21:58:52 +04:00
|
|
|
ObjectStoreInfoArray& aObjectStores);
|
|
|
|
|
|
|
|
static nsresult
|
2011-12-17 04:40:47 +04:00
|
|
|
SetDatabaseMetadata(DatabaseInfo* aDatabaseInfo,
|
|
|
|
PRUint64 aVersion,
|
|
|
|
ObjectStoreInfoArray& aObjectStores);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2011-11-08 04:15:45 +04:00
|
|
|
nsresult
|
|
|
|
OpenCommon(const nsAString& aName,
|
|
|
|
PRInt64 aVersion,
|
|
|
|
bool aDeleting,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCallingCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBOpenDBRequest** _retval);
|
|
|
|
|
|
|
|
void
|
|
|
|
SetActor(IndexedDBChild* aActorChild)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aActorChild || !mActorChild, "Shouldn't have more than one!");
|
|
|
|
mActorChild = aActorChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetActor(IndexedDBParent* aActorParent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aActorParent || !mActorParent, "Shouldn't have more than one!");
|
|
|
|
mActorParent = aActorParent;
|
|
|
|
}
|
|
|
|
|
2012-07-14 15:24:20 +04:00
|
|
|
const nsCString&
|
|
|
|
GetASCIIOrigin() const
|
|
|
|
{
|
|
|
|
return mASCIIOrigin;
|
|
|
|
}
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
private:
|
|
|
|
IDBFactory();
|
|
|
|
~IDBFactory();
|
|
|
|
|
|
|
|
nsCString mASCIIOrigin;
|
2011-11-08 04:15:45 +04:00
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
// If this factory lives on a window then mWindow must be non-null. Otherwise
|
|
|
|
// mOwningObject must be non-null.
|
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
|
|
|
JSObject* mOwningObject;
|
2012-06-01 21:21:12 +04:00
|
|
|
|
|
|
|
IndexedDBChild* mActorChild;
|
|
|
|
IndexedDBParent* mActorParent;
|
2012-07-14 15:24:20 +04:00
|
|
|
|
|
|
|
bool mRootedOwningObject;
|
2010-06-23 23:46:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-06-28 20:44:30 +04:00
|
|
|
#endif // mozilla_dom_indexeddb_idbfactory_h__
|