2010-06-23 12:46:08 -07: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 04:12:37 -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/. */
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2010-06-28 09:44:30 -07:00
|
|
|
#ifndef mozilla_dom_indexeddb_idbfactory_h__
|
|
|
|
#define mozilla_dom_indexeddb_idbfactory_h__
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2010-09-09 15:15:38 -07:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
|
|
|
|
#include "mozIStorageConnection.h"
|
2010-06-28 09:44:30 -07:00
|
|
|
#include "nsIIDBFactory.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2012-01-24 02:03:37 -08:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2011-01-26 17:53:02 -08:00
|
|
|
|
2012-01-23 08:18:14 -08:00
|
|
|
class nsIAtom;
|
2012-01-24 02:03:37 -08:00
|
|
|
class nsPIDOMWindow;
|
2011-01-26 17:53:02 -08:00
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-10-19 10:58:52 -07:00
|
|
|
struct DatabaseInfo;
|
2010-09-09 15:15:40 -07:00
|
|
|
class IDBDatabase;
|
2012-06-01 10:21:12 -07:00
|
|
|
class IDBOpenDBRequest;
|
|
|
|
class IndexedDBChild;
|
|
|
|
class IndexedDBParent;
|
|
|
|
|
2010-10-19 10:58:52 -07:00
|
|
|
struct ObjectStoreInfo;
|
2010-09-09 15:15:40 -07:00
|
|
|
|
2012-05-14 21:50:29 -07:00
|
|
|
class IDBFactory MOZ_FINAL : public nsIIDBFactory
|
2010-06-23 12:46:08 -07:00
|
|
|
{
|
2011-12-16 16:40:47 -08:00
|
|
|
typedef nsTArray<nsRefPtr<ObjectStoreInfo> > ObjectStoreInfoArray;
|
2012-01-24 02:03:37 -08:00
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
public:
|
2012-01-24 02:03:37 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
|
2010-06-28 09:44:30 -07:00
|
|
|
NS_DECL_NSIIDBFACTORY
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
static nsresult Create(nsPIDOMWindow* aWindow,
|
|
|
|
const nsACString& aASCIIOrigin,
|
|
|
|
IDBFactory** aFactory);
|
|
|
|
|
|
|
|
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 12:46:08 -07:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
factory.forget(aFactory);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult Create(JSContext* aCx,
|
|
|
|
JSObject* aOwningObject,
|
|
|
|
IDBFactory** aFactory);
|
2012-01-24 02:03:37 -08:00
|
|
|
|
2010-09-09 15:15:40 -07:00
|
|
|
static already_AddRefed<mozIStorageConnection>
|
2010-06-23 12:46:08 -07:00
|
|
|
GetConnection(const nsAString& aDatabaseFilePath);
|
|
|
|
|
2010-10-19 10:58:52 -07:00
|
|
|
static nsresult
|
|
|
|
LoadDatabaseInformation(mozIStorageConnection* aConnection,
|
2011-11-02 05:53:12 -07:00
|
|
|
nsIAtom* aDatabaseId,
|
2011-10-20 09:10:56 -07:00
|
|
|
PRUint64* aVersion,
|
2010-10-19 10:58:52 -07:00
|
|
|
ObjectStoreInfoArray& aObjectStores);
|
|
|
|
|
|
|
|
static nsresult
|
2011-12-16 16:40:47 -08:00
|
|
|
SetDatabaseMetadata(DatabaseInfo* aDatabaseInfo,
|
|
|
|
PRUint64 aVersion,
|
|
|
|
ObjectStoreInfoArray& aObjectStores);
|
2010-10-19 10:58:52 -07:00
|
|
|
|
2011-11-07 16:15:45 -08:00
|
|
|
nsresult
|
|
|
|
OpenCommon(const nsAString& aName,
|
|
|
|
PRInt64 aVersion,
|
|
|
|
bool aDeleting,
|
2012-06-01 10:21:12 -07: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
IDBFactory();
|
|
|
|
~IDBFactory();
|
|
|
|
|
|
|
|
nsCString mASCIIOrigin;
|
2011-11-07 16:15:45 -08:00
|
|
|
|
2012-01-24 02:03:37 -08: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 10:21:12 -07:00
|
|
|
|
|
|
|
IndexedDBChild* mActorChild;
|
|
|
|
IndexedDBParent* mActorParent;
|
2010-06-23 12:46:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-06-28 09:44:30 -07:00
|
|
|
#endif // mozilla_dom_indexeddb_idbfactory_h__
|