// static nsresult IDBFactory::Create(JSContext* aCx, JSObject* aOwningObject, IDBFactory** aFactory) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(aCx, "Null context!"); NS_ASSERTION(aOwningObject, "Null object!"); NS_ASSERTION(JS_GetGlobalForObject(aCx, aOwningObject) == aOwningObject, "Not a global object!"); NS_ASSERTION(nsContentUtils::IsCallerChrome(), "Only for chrome!"); nsCString origin; nsresult rv = IndexedDatabaseManager::GetASCIIOriginFromWindow(nsnull, origin); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsRefPtr<IDBFactory> factory = new IDBFactory(); factory->mASCIIOrigin = origin; factory->mOwningObject = aOwningObject; if (!IndexedDatabaseManager::IsMainProcess()) { ContentChild* contentChild = ContentChild::GetSingleton(); NS_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IndexedDBChild* actor = new IndexedDBChild(origin); contentChild->SendPIndexedDBConstructor(actor); actor->SetFactory(factory); } factory.forget(aFactory); return NS_OK; }
// static nsresult IDBFactory::Create(JSContext* aCx, JS::Handle<JSObject*> aOwningObject, ContentParent* aContentParent, IDBFactory** aFactory) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(aCx, "Null context!"); NS_ASSERTION(aOwningObject, "Null object!"); NS_ASSERTION(JS_GetGlobalForObject(aCx, aOwningObject) == aOwningObject, "Not a global object!"); NS_ASSERTION(nsContentUtils::IsCallerChrome(), "Only for chrome!"); // Make sure that the manager is up before we do anything here since lots of // decisions depend on which process we're running in. IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate(); IDB_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsCString group; nsCString origin; StoragePrivilege privilege; PersistenceType defaultPersistenceType; QuotaManager::GetInfoForChrome(&group, &origin, &privilege, &defaultPersistenceType); nsRefPtr<IDBFactory> factory = new IDBFactory(); factory->mGroup = group; factory->mASCIIOrigin = origin; factory->mPrivilege = privilege; factory->mDefaultPersistenceType = defaultPersistenceType; factory->mOwningObject = aOwningObject; factory->mContentParent = aContentParent; mozilla::HoldJSObjects(factory.get()); factory->mRootedOwningObject = true; if (!IndexedDatabaseManager::IsMainProcess()) { ContentChild* contentChild = ContentChild::GetSingleton(); IDB_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IndexedDBChild* actor = new IndexedDBChild(origin); contentChild->SendPIndexedDBConstructor(actor); actor->SetFactory(factory); } factory.forget(aFactory); return NS_OK; }
// static nsresult IDBFactory::Create(JSContext* aCx, JS::Handle<JSObject*> aOwningObject, ContentParent* aContentParent, IDBFactory** aFactory) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(aCx, "Null context!"); NS_ASSERTION(aOwningObject, "Null object!"); NS_ASSERTION(JS_GetGlobalForObject(aCx, aOwningObject) == aOwningObject, "Not a global object!"); NS_ASSERTION(nsContentUtils::IsCallerChrome(), "Only for chrome!"); nsCString group; nsCString origin; StoragePrivilege privilege; PersistenceType defaultPersistenceType; QuotaManager::GetInfoForChrome(&group, &origin, &privilege, &defaultPersistenceType); nsRefPtr<IDBFactory> factory = new IDBFactory(); factory->mGroup = group; factory->mASCIIOrigin = origin; factory->mPrivilege = privilege; factory->mDefaultPersistenceType = defaultPersistenceType; factory->mOwningObject = aOwningObject; factory->mContentParent = aContentParent; if (!IndexedDatabaseManager::IsMainProcess()) { ContentChild* contentChild = ContentChild::GetSingleton(); NS_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IndexedDBChild* actor = new IndexedDBChild(origin); contentChild->SendPIndexedDBConstructor(actor); actor->SetFactory(factory); } factory.forget(aFactory); return NS_OK; }