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
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class ContentParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-08-01 23:02:29 -07:00
|
|
|
typedef mozilla::dom::ContentParent ContentParent;
|
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-07-14 04:24:20 -07:00
|
|
|
// Called when using IndexedDB from a window in a different process.
|
2012-06-01 10:21:12 -07:00
|
|
|
static nsresult Create(nsPIDOMWindow* aWindow,
|
|
|
|
const nsACString& aASCIIOrigin,
|
2012-08-01 23:02:29 -07:00
|
|
|
ContentParent* aContentParent,
|
2012-06-01 10:21:12 -07:00
|
|
|
IDBFactory** aFactory);
|
|
|
|
|
2012-07-14 04:24:20 -07:00
|
|
|
// Called when using IndexedDB from a window in the current process.
|
2012-06-01 10:21:12 -07:00
|
|
|
static nsresult Create(nsPIDOMWindow* aWindow,
|
2012-08-01 23:02:29 -07:00
|
|
|
ContentParent* aContentParent,
|
2012-06-01 10:21:12 -07:00
|
|
|
nsIIDBFactory** aFactory)
|
|
|
|
{
|
|
|
|
nsRefPtr<IDBFactory> factory;
|
2012-08-01 23:02:29 -07:00
|
|
|
nsresult rv =
|
|
|
|
Create(aWindow, EmptyCString(), aContentParent, getter_AddRefs(factory));
|
2012-06-01 10:21:12 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-07-14 04:24:20 -07:00
|
|
|
// Called when using IndexedDB from a JS component or a JSM in the current
|
|
|
|
// process.
|
2012-06-01 10:21:12 -07:00
|
|
|
static nsresult Create(JSContext* aCx,
|
|
|
|
JSObject* aOwningObject,
|
2012-08-01 23:02:29 -07:00
|
|
|
ContentParent* aContentParent,
|
2012-06-01 10:21:12 -07:00
|
|
|
IDBFactory** aFactory);
|
2012-01-24 02:03:37 -08:00
|
|
|
|
2012-07-14 04:24:20 -07:00
|
|
|
// Called when using IndexedDB from a JS component or a JSM in a different
|
|
|
|
// process.
|
2012-08-01 23:02:29 -07:00
|
|
|
static nsresult Create(ContentParent* aContentParent,
|
|
|
|
IDBFactory** aFactory);
|
2012-07-14 04:24:20 -07: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,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t* aVersion,
|
2010-10-19 10:58:52 -07:00
|
|
|
ObjectStoreInfoArray& aObjectStores);
|
|
|
|
|
|
|
|
static nsresult
|
2011-12-16 16:40:47 -08:00
|
|
|
SetDatabaseMetadata(DatabaseInfo* aDatabaseInfo,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t aVersion,
|
2011-12-16 16:40:47 -08:00
|
|
|
ObjectStoreInfoArray& aObjectStores);
|
2010-10-19 10:58:52 -07:00
|
|
|
|
2011-11-07 16:15:45 -08:00
|
|
|
nsresult
|
|
|
|
OpenCommon(const nsAString& aName,
|
2012-08-22 08:56:38 -07:00
|
|
|
int64_t aVersion,
|
2012-10-29 23:07:09 -07:00
|
|
|
const nsACString& aASCIIOrigin,
|
2011-11-07 16:15:45 -08:00
|
|
|
bool aDeleting,
|
2012-06-29 09:48:34 -07:00
|
|
|
JSContext* aCallingCx,
|
2012-06-01 10:21:12 -07:00
|
|
|
IDBOpenDBRequest** _retval);
|
|
|
|
|
2012-10-29 23:11:58 -07:00
|
|
|
nsresult
|
|
|
|
OpenCommon(const nsAString& aName,
|
|
|
|
int64_t aVersion,
|
|
|
|
bool aDeleting,
|
|
|
|
JSContext* aCallingCx,
|
|
|
|
IDBOpenDBRequest** _retval)
|
|
|
|
{
|
|
|
|
return OpenCommon(aName, aVersion, mASCIIOrigin, aDeleting, aCallingCx,
|
|
|
|
_retval);
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
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 04:24:20 -07:00
|
|
|
const nsCString&
|
|
|
|
GetASCIIOrigin() const
|
|
|
|
{
|
|
|
|
return mASCIIOrigin;
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
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;
|
2012-07-14 04:24:20 -07:00
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
mozilla::dom::ContentParent* mContentParent;
|
|
|
|
|
2012-07-14 04:24:20 -07:00
|
|
|
bool mRootedOwningObject;
|
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__
|