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
|
|
|
#include "IDBFactory.h"
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "IDBRequest.h"
|
|
|
|
#include "IndexedDatabaseManager.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-03-31 12:18:30 +04:00
|
|
|
#include "mozilla/dom/IDBFactoryBinding.h"
|
2012-07-14 15:24:20 +04:00
|
|
|
#include "mozilla/dom/TabChild.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/ipc/BackgroundChild.h"
|
|
|
|
#include "mozilla/ipc/BackgroundUtils.h"
|
|
|
|
#include "mozilla/ipc/PBackground.h"
|
|
|
|
#include "mozilla/ipc/PBackgroundChild.h"
|
2012-07-06 21:28:51 +04:00
|
|
|
#include "nsGlobalWindow.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "nsIIPCBackgroundChildCreateCallback.h"
|
|
|
|
#include "nsILoadContext.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIWebNavigation.h"
|
2013-03-16 10:58:50 +04:00
|
|
|
#include "ProfilerHelpers.h"
|
2014-01-28 04:37:05 +04:00
|
|
|
#include "ReportInternalError.h"
|
2011-05-29 03:42:57 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// Include this last to avoid path problems on Windows.
|
|
|
|
#include "ActorsChild.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include "nsContentUtils.h" // For IsCallerChrome assertions.
|
|
|
|
#endif
|
2013-09-13 15:19:25 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
using namespace mozilla::dom::quota;
|
|
|
|
using namespace mozilla::ipc;
|
2012-07-14 15:24:20 +04:00
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
namespace {
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const char kPrefIndexedDBEnabled[] = "dom.indexedDB.enabled";
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
GetPrincipalInfoFromPrincipal(nsIPrincipal* aPrincipal,
|
|
|
|
PrincipalInfo* aPrincipalInfo)
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aPrincipal);
|
|
|
|
MOZ_ASSERT(aPrincipalInfo);
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
bool isNullPrincipal;
|
|
|
|
nsresult rv = aPrincipal->GetIsNullPrincipal(&isNullPrincipal);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isNullPrincipal) {
|
|
|
|
NS_WARNING("IndexedDB not supported from this principal!");
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = PrincipalToPrincipalInfo(aPrincipal, aPrincipalInfo);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-18 03:36:01 +04:00
|
|
|
} // anonymous namespace
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
class IDBFactory::BackgroundCreateCallback MOZ_FINAL
|
|
|
|
: public nsIIPCBackgroundChildCreateCallback
|
|
|
|
{
|
|
|
|
nsRefPtr<IDBFactory> mFactory;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit BackgroundCreateCallback(IDBFactory* aFactory)
|
|
|
|
: mFactory(aFactory)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFactory);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
private:
|
|
|
|
~BackgroundCreateCallback()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IDBFactory::PendingRequestInfo
|
|
|
|
{
|
|
|
|
nsRefPtr<IDBOpenDBRequest> mRequest;
|
|
|
|
FactoryRequestParams mParams;
|
|
|
|
|
|
|
|
PendingRequestInfo(IDBOpenDBRequest* aRequest,
|
|
|
|
const FactoryRequestParams& aParams)
|
|
|
|
: mRequest(aRequest), mParams(aParams)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aRequest);
|
|
|
|
MOZ_ASSERT(aParams.type() != FactoryRequestParams::T__None);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-04-30 03:46:20 +04:00
|
|
|
IDBFactory::IDBFactory()
|
2014-09-27 03:21:57 +04:00
|
|
|
: mOwningObject(nullptr)
|
|
|
|
, mBackgroundActor(nullptr)
|
|
|
|
, mRootedOwningObject(false)
|
|
|
|
, mBackgroundActorFailed(false)
|
|
|
|
, mPrivateBrowsingMode(false)
|
2011-04-30 03:46:20 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
mOwningThread = PR_GetCurrentThread();
|
|
|
|
#endif
|
|
|
|
AssertIsOnOwningThread();
|
2011-04-30 03:46:20 +04:00
|
|
|
}
|
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
IDBFactory::~IDBFactory()
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT_IF(mBackgroundActorFailed, !mBackgroundActor);
|
|
|
|
|
2012-07-14 15:24:20 +04:00
|
|
|
if (mRootedOwningObject) {
|
2012-11-28 05:37:57 +04:00
|
|
|
mOwningObject = nullptr;
|
2013-08-17 00:10:17 +04:00
|
|
|
mozilla::DropJSObjects(this);
|
2012-07-14 15:24:20 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
if (mBackgroundActor) {
|
|
|
|
mBackgroundActor->SendDeleteMeInternal();
|
|
|
|
MOZ_ASSERT(!mBackgroundActor, "SendDeleteMeInternal should have cleared!");
|
|
|
|
}
|
2012-01-24 14:03:37 +04:00
|
|
|
}
|
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
// static
|
2012-06-01 21:21:12 +04:00
|
|
|
nsresult
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBFactory::CreateForWindow(nsPIDOMWindow* aWindow,
|
|
|
|
IDBFactory** aFactory)
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aWindow);
|
|
|
|
MOZ_ASSERT(aWindow->IsInnerWindow());
|
|
|
|
MOZ_ASSERT(aFactory);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
|
|
|
|
*aFactory = nullptr;
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
2014-09-13 20:12:19 +04:00
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aWindow);
|
|
|
|
if (NS_WARN_IF(!sop)) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
|
|
|
|
if (NS_WARN_IF(!principal)) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsAutoPtr<PrincipalInfo> principalInfo(new PrincipalInfo());
|
2013-09-11 08:18:36 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(NS_FAILED(GetPrincipalInfoFromPrincipal(principal,
|
|
|
|
principalInfo)))) {
|
2013-09-11 08:18:36 +04:00
|
|
|
// Not allowed.
|
|
|
|
*aFactory = nullptr;
|
|
|
|
return NS_OK;
|
2011-01-27 04:53:02 +03:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
|
|
|
|
if (NS_WARN_IF(!mgr)) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
bool privateBrowsingMode = loadContext && loadContext->UsePrivateBrowsing();
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsRefPtr<IDBFactory> factory = new IDBFactory();
|
|
|
|
factory->mPrincipalInfo = Move(principalInfo);
|
|
|
|
factory->mWindow = aWindow;
|
|
|
|
factory->mTabChild = TabChild::GetFrom(aWindow);
|
|
|
|
factory->mPrivateBrowsingMode = privateBrowsingMode;
|
2012-06-01 21:21:12 +04:00
|
|
|
|
|
|
|
factory.forget(aFactory);
|
|
|
|
return NS_OK;
|
2012-01-24 14:03:37 +04:00
|
|
|
}
|
2011-01-27 04:53:02 +03:00
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
// static
|
2012-06-01 21:21:12 +04:00
|
|
|
nsresult
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBFactory::CreateForChromeJS(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aOwningObject,
|
|
|
|
IDBFactory** aFactory)
|
2012-01-24 14:03:37 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
|
2011-01-27 04:53:02 +03:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsAutoPtr<PrincipalInfo> principalInfo(
|
|
|
|
new PrincipalInfo(SystemPrincipalInfo()));
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsresult rv =
|
|
|
|
CreateForJSInternal(aCx, aOwningObject, principalInfo, aFactory);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
2014-01-12 06:45:15 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(!principalInfo);
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
IDBFactory::CreateForDatastore(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aOwningObject,
|
|
|
|
IDBFactory** aFactory)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2012-07-14 15:24:20 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// There should be a null principal pushed here, but it's still chrome...
|
|
|
|
MOZ_ASSERT(!nsContentUtils::IsCallerChrome());
|
2012-07-14 15:24:20 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsAutoPtr<PrincipalInfo> principalInfo(
|
|
|
|
new PrincipalInfo(SystemPrincipalInfo()));
|
2012-07-14 15:24:20 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsresult rv =
|
|
|
|
CreateForJSInternal(aCx, aOwningObject, principalInfo, aFactory);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
2012-07-14 15:24:20 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(!principalInfo);
|
|
|
|
|
2012-07-14 15:24:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBFactory::CreateForJSInternal(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aOwningObject,
|
|
|
|
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
|
|
|
IDBFactory** aFactory)
|
2012-07-14 15:24:20 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aCx);
|
|
|
|
MOZ_ASSERT(aOwningObject);
|
|
|
|
MOZ_ASSERT(aPrincipalInfo);
|
|
|
|
MOZ_ASSERT(aFactory);
|
|
|
|
MOZ_ASSERT(JS_GetGlobalForObject(aCx, aOwningObject) == aOwningObject,
|
|
|
|
"Not a global object!");
|
2012-07-14 15:24:20 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
MOZ_CRASH("Not yet supported off the main thread!");
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
|
|
|
|
*aFactory = nullptr;
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
|
|
|
|
if (NS_WARN_IF(!mgr)) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
|
|
}
|
2012-07-14 15:24:20 +04:00
|
|
|
|
2013-09-19 16:45:25 +04:00
|
|
|
nsRefPtr<IDBFactory> factory = new IDBFactory();
|
2014-09-27 03:21:57 +04:00
|
|
|
factory->mPrincipalInfo = aPrincipalInfo.forget();
|
|
|
|
factory->mOwningObject = aOwningObject;
|
2012-07-14 15:24:20 +04:00
|
|
|
|
2013-08-17 00:10:17 +04:00
|
|
|
mozilla::HoldJSObjects(factory.get());
|
2012-07-14 15:24:20 +04:00
|
|
|
factory->mRootedOwningObject = true;
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
factory.forget(aFactory);
|
|
|
|
return NS_OK;
|
2010-06-23 23:46:08 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#ifdef DEBUG
|
2012-12-17 23:25:10 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
IDBFactory::AssertIsOnOwningThread() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mOwningThread);
|
|
|
|
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
|
|
|
|
}
|
2013-09-11 08:18:36 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#endif // DEBUG
|
2012-12-17 23:25:10 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
IDBFactory::SetBackgroundActor(BackgroundFactoryChild* aBackgroundActor)
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aBackgroundActor);
|
|
|
|
MOZ_ASSERT(!mBackgroundActor);
|
2012-12-17 23:25:10 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
mBackgroundActor = aBackgroundActor;
|
2014-09-13 20:12:19 +04:00
|
|
|
}
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBFactory::Open(const nsAString& aName,
|
|
|
|
uint64_t aVersion,
|
|
|
|
ErrorResult& aRv)
|
2014-09-13 20:12:19 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
return OpenInternal(/* aPrincipal */ nullptr,
|
|
|
|
aName,
|
|
|
|
Optional<uint64_t>(aVersion),
|
|
|
|
Optional<StorageType>(),
|
|
|
|
/* aDeleting */ false,
|
|
|
|
aRv);
|
|
|
|
}
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBFactory::Open(const nsAString& aName,
|
|
|
|
const IDBOpenDBOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
return OpenInternal(/* aPrincipal */ nullptr,
|
|
|
|
aName,
|
|
|
|
aOptions.mVersion,
|
|
|
|
aOptions.mStorage,
|
|
|
|
/* aDeleting */ false,
|
|
|
|
aRv);
|
|
|
|
}
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBFactory::DeleteDatabase(const nsAString& aName,
|
|
|
|
const IDBOpenDBOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
return OpenInternal(/* aPrincipal */ nullptr,
|
|
|
|
aName,
|
|
|
|
Optional<uint64_t>(),
|
|
|
|
aOptions.mStorage,
|
|
|
|
/* aDeleting */ true,
|
|
|
|
aRv);
|
|
|
|
}
|
2013-04-08 23:47:13 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
int16_t
|
|
|
|
IDBFactory::Cmp(JSContext* aCx, JS::Handle<JS::Value> aFirst,
|
|
|
|
JS::Handle<JS::Value> aSecond, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
Key first, second;
|
|
|
|
nsresult rv = first.SetFromJSVal(aCx, aFirst);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-08 23:47:13 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
rv = second.SetFromJSVal(aCx, aSecond);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (first.IsUnset() || second.IsUnset()) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return Key::CompareKeys(first, second);
|
2013-04-08 23:47:13 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBFactory::OpenForPrincipal(nsIPrincipal* aPrincipal,
|
|
|
|
const nsAString& aName,
|
|
|
|
uint64_t aVersion,
|
|
|
|
ErrorResult& aRv)
|
2011-12-20 14:59:07 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aPrincipal);
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
MOZ_CRASH("Figure out security checks for workers!");
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
|
|
|
|
|
|
|
|
return OpenInternal(aPrincipal,
|
|
|
|
aName,
|
|
|
|
Optional<uint64_t>(aVersion),
|
|
|
|
Optional<StorageType>(),
|
|
|
|
/* aDeleting */ false,
|
|
|
|
aRv);
|
2011-12-20 14:59:07 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBFactory::OpenForPrincipal(nsIPrincipal* aPrincipal,
|
|
|
|
const nsAString& aName,
|
|
|
|
const IDBOpenDBOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
2010-10-19 21:58:52 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aPrincipal);
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
MOZ_CRASH("Figure out security checks for workers!");
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
|
|
|
|
|
|
|
|
return OpenInternal(aPrincipal,
|
|
|
|
aName,
|
|
|
|
aOptions.mVersion,
|
|
|
|
aOptions.mStorage,
|
|
|
|
/* aDeleting */ false,
|
|
|
|
aRv);
|
2014-09-13 20:12:19 +04:00
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBFactory::DeleteForPrincipal(nsIPrincipal* aPrincipal,
|
|
|
|
const nsAString& aName,
|
|
|
|
const IDBOpenDBOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
2014-09-13 20:12:19 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aPrincipal);
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
MOZ_CRASH("Figure out security checks for workers!");
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
|
|
|
|
|
|
|
|
return OpenInternal(aPrincipal,
|
|
|
|
aName,
|
|
|
|
Optional<uint64_t>(),
|
|
|
|
aOptions.mStorage,
|
|
|
|
/* aDeleting */ true,
|
|
|
|
aRv);
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBFactory::OpenInternal(nsIPrincipal* aPrincipal,
|
|
|
|
const nsAString& aName,
|
|
|
|
const Optional<uint64_t>& aVersion,
|
|
|
|
const Optional<StorageType>& aStorageType,
|
|
|
|
bool aDeleting,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWindow || mOwningObject);
|
|
|
|
MOZ_ASSERT_IF(!mWindow, !mPrivateBrowsingMode);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
CommonFactoryRequestParams commonParams;
|
|
|
|
commonParams.privateBrowsingMode() = mPrivateBrowsingMode;
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
PrincipalInfo& principalInfo = commonParams.principalInfo();
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (aPrincipal) {
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
MOZ_CRASH("Figure out security checks for workers!");
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(NS_FAILED(GetPrincipalInfoFromPrincipal(aPrincipal,
|
|
|
|
&principalInfo)))) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
principalInfo = *mPrincipalInfo;
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
uint64_t version = 0;
|
|
|
|
if (!aDeleting && aVersion.WasPassed()) {
|
|
|
|
if (aVersion.Value() < 1) {
|
|
|
|
aRv.ThrowTypeError(MSG_INVALID_VERSION);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
version = aVersion.Value();
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// Nothing can be done here if we have previously failed to create a
|
|
|
|
// background actor.
|
|
|
|
if (mBackgroundActorFailed) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2012-06-22 02:27:13 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// XXX We need a bug to switch to temporary storage by default.
|
|
|
|
|
|
|
|
PersistenceType persistenceType;
|
|
|
|
bool persistenceTypeIsExplicit;
|
|
|
|
|
|
|
|
if (principalInfo.type() == PrincipalInfo::TSystemPrincipalInfo) {
|
|
|
|
// Chrome privilege always gets persistent storage.
|
|
|
|
persistenceType = PERSISTENCE_TYPE_PERSISTENT;
|
|
|
|
persistenceTypeIsExplicit = false;
|
|
|
|
} else {
|
2014-11-03 23:00:52 +03:00
|
|
|
persistenceType =
|
|
|
|
PersistenceTypeFromStorage(aStorageType, PERSISTENCE_TYPE_PERSISTENT);
|
2014-09-27 03:21:57 +04:00
|
|
|
persistenceTypeIsExplicit = aStorageType.WasPassed();
|
|
|
|
}
|
|
|
|
|
|
|
|
DatabaseMetadata& metadata = commonParams.metadata();
|
|
|
|
metadata.name() = aName;
|
|
|
|
metadata.persistenceType() = persistenceType;
|
|
|
|
metadata.persistenceTypeIsExplicit() = persistenceTypeIsExplicit;
|
|
|
|
|
|
|
|
FactoryRequestParams params;
|
|
|
|
if (aDeleting) {
|
|
|
|
metadata.version() = 0;
|
|
|
|
params = DeleteDatabaseRequestParams(commonParams);
|
|
|
|
} else {
|
|
|
|
metadata.version() = version;
|
|
|
|
params = OpenDatabaseRequestParams(commonParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mBackgroundActor) {
|
|
|
|
// If another consumer has already created a background actor for this
|
|
|
|
// thread then we can start this request immediately.
|
|
|
|
if (PBackgroundChild* bgActor = BackgroundChild::GetForCurrentThread()) {
|
|
|
|
nsresult rv = BackgroundActorCreated(bgActor);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mBackgroundActor);
|
|
|
|
} else if (mPendingRequests.IsEmpty()) {
|
|
|
|
// We need to start the sequence to create a background actor for this
|
|
|
|
// thread.
|
|
|
|
nsRefPtr<BackgroundCreateCallback> cb =
|
|
|
|
new BackgroundCreateCallback(this);
|
|
|
|
if (NS_WARN_IF(!BackgroundChild::GetOrCreateForCurrentThread(cb))) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-20 14:59:07 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
AutoJSAPI autoJS;
|
|
|
|
nsRefPtr<IDBOpenDBRequest> request;
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (mWindow) {
|
|
|
|
if (NS_WARN_IF(!autoJS.Init(mWindow))) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return nullptr;
|
2011-12-04 21:39:01 +04:00
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
JS::Rooted<JSObject*> scriptOwner(autoJS.cx(),
|
|
|
|
static_cast<nsGlobalWindow*>(mWindow.get())->FastGetGlobalJSObject());
|
|
|
|
MOZ_ASSERT(scriptOwner);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
request = IDBOpenDBRequest::CreateForWindow(this, mWindow, scriptOwner);
|
|
|
|
} else {
|
|
|
|
autoJS.Init();
|
|
|
|
JS::Rooted<JSObject*> scriptOwner(autoJS.cx(), mOwningObject);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
request = IDBOpenDBRequest::CreateForJS(this, scriptOwner);
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(request);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// If we already have a background actor then we can start this request now.
|
|
|
|
if (mBackgroundActor) {
|
|
|
|
nsresult rv = InitiateRequest(request, params);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return nullptr;
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
} else {
|
|
|
|
mPendingRequests.AppendElement(new PendingRequestInfo(request, params));
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#ifdef IDB_PROFILER_USE_MARKS
|
|
|
|
{
|
|
|
|
NS_ConvertUTF16toUTF8 profilerName(aName);
|
|
|
|
if (aDeleting) {
|
|
|
|
IDB_PROFILER_MARK("IndexedDB Request %llu: deleteDatabase(\"%s\")",
|
|
|
|
"MT IDBFactory.deleteDatabase()",
|
|
|
|
request->GetSerialNumber(), profilerName.get());
|
|
|
|
} else {
|
|
|
|
IDB_PROFILER_MARK("IndexedDB Request %llu: open(\"%s\", %lld)",
|
|
|
|
"MT IDBFactory.open()",
|
|
|
|
request->GetSerialNumber(), profilerName.get(),
|
|
|
|
aVersion);
|
2014-09-18 03:36:01 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
|
|
|
#endif
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
IDBFactory::BackgroundActorCreated(PBackgroundChild* aBackgroundActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aBackgroundActor);
|
|
|
|
MOZ_ASSERT(!mBackgroundActor);
|
|
|
|
MOZ_ASSERT(!mBackgroundActorFailed);
|
|
|
|
|
|
|
|
{
|
|
|
|
BackgroundFactoryChild* actor = new BackgroundFactoryChild(this);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Fix this windowId stuff for workers!");
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
OptionalWindowId windowId;
|
|
|
|
if (mWindow && IndexedDatabaseManager::IsMainProcess()) {
|
|
|
|
MOZ_ASSERT(mWindow->IsInnerWindow());
|
|
|
|
windowId = mWindow->WindowID();
|
|
|
|
} else {
|
|
|
|
windowId = void_t();
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
mBackgroundActor =
|
|
|
|
static_cast<BackgroundFactoryChild*>(
|
|
|
|
aBackgroundActor->SendPBackgroundIDBFactoryConstructor(actor,
|
|
|
|
windowId));
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(!mBackgroundActor)) {
|
|
|
|
BackgroundActorFailed();
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsresult rv = NS_OK;
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
for (uint32_t index = 0, count = mPendingRequests.Length();
|
|
|
|
index < count;
|
|
|
|
index++) {
|
|
|
|
nsAutoPtr<PendingRequestInfo> info(mPendingRequests[index].forget());
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsresult rv2 = InitiateRequest(info->mRequest, info->mParams);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// Warn for every failure, but just return the first failure if there are
|
|
|
|
// multiple failures.
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv2)) && NS_SUCCEEDED(rv)) {
|
|
|
|
rv = rv2;
|
|
|
|
}
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
mPendingRequests.Clear();
|
2011-10-20 20:10:56 +04:00
|
|
|
|
|
|
|
return rv;
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
IDBFactory::BackgroundActorFailed()
|
2010-10-19 21:58:52 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(!mPendingRequests.IsEmpty());
|
|
|
|
MOZ_ASSERT(!mBackgroundActor);
|
|
|
|
MOZ_ASSERT(!mBackgroundActorFailed);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
mBackgroundActorFailed = true;
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
for (uint32_t index = 0, count = mPendingRequests.Length();
|
|
|
|
index < count;
|
|
|
|
index++) {
|
|
|
|
nsAutoPtr<PendingRequestInfo> info(mPendingRequests[index].forget());
|
|
|
|
info->mRequest->
|
|
|
|
DispatchNonTransactionError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
mPendingRequests.Clear();
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsresult
|
|
|
|
IDBFactory::InitiateRequest(IDBOpenDBRequest* aRequest,
|
|
|
|
const FactoryRequestParams& aParams)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aRequest);
|
|
|
|
MOZ_ASSERT(mBackgroundActor);
|
|
|
|
MOZ_ASSERT(!mBackgroundActorFailed);
|
|
|
|
|
|
|
|
bool deleting;
|
|
|
|
uint64_t requestedVersion;
|
|
|
|
|
|
|
|
switch (aParams.type()) {
|
|
|
|
case FactoryRequestParams::TDeleteDatabaseRequestParams: {
|
|
|
|
const DatabaseMetadata& metadata =
|
|
|
|
aParams.get_DeleteDatabaseRequestParams().commonParams().metadata();
|
|
|
|
deleting = true;
|
|
|
|
requestedVersion = metadata.version();
|
|
|
|
break;
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
case FactoryRequestParams::TOpenDatabaseRequestParams: {
|
|
|
|
const DatabaseMetadata& metadata =
|
|
|
|
aParams.get_OpenDatabaseRequestParams().commonParams().metadata();
|
|
|
|
deleting = false;
|
|
|
|
requestedVersion = metadata.version();
|
|
|
|
break;
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("Should never get here!");
|
|
|
|
}
|
|
|
|
|
|
|
|
auto actor =
|
|
|
|
new BackgroundFactoryRequestChild(this,
|
|
|
|
aRequest,
|
|
|
|
deleting,
|
|
|
|
requestedVersion);
|
|
|
|
|
|
|
|
if (!mBackgroundActor->SendPBackgroundIDBFactoryRequestConstructor(actor,
|
|
|
|
aParams)) {
|
|
|
|
aRequest->DispatchNonTransactionError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBFactory)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBFactory)
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBFactory)
|
2013-03-31 12:18:30 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2010-09-10 02:15:38 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2010-06-23 23:46:08 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBFactory)
|
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBFactory)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBFactory)
|
2013-03-31 12:18:30 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
2012-01-24 14:03:37 +04:00
|
|
|
if (tmp->mOwningObject) {
|
2012-07-30 18:20:58 +04:00
|
|
|
tmp->mOwningObject = nullptr;
|
2012-01-24 14:03:37 +04:00
|
|
|
}
|
2012-07-14 15:24:20 +04:00
|
|
|
if (tmp->mRootedOwningObject) {
|
2013-08-17 00:10:17 +04:00
|
|
|
mozilla::DropJSObjects(tmp);
|
2012-07-14 15:24:20 +04:00
|
|
|
tmp->mRootedOwningObject = false;
|
|
|
|
}
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBFactory)
|
2013-03-31 12:18:30 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
2012-06-11 03:44:50 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mOwningObject)
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2013-03-31 12:18:30 +04:00
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
IDBFactory::WrapObject(JSContext* aCx)
|
2011-11-08 04:15:45 +04:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-09 02:27:17 +04:00
|
|
|
return IDBFactoryBinding::Wrap(aCx, this);
|
2013-03-31 12:18:30 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
NS_IMPL_ISUPPORTS(IDBFactory::BackgroundCreateCallback,
|
|
|
|
nsIIPCBackgroundChildCreateCallback)
|
2013-09-11 08:18:36 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
IDBFactory::BackgroundCreateCallback::ActorCreated(PBackgroundChild* aActor)
|
2013-09-11 08:18:36 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
MOZ_ASSERT(mFactory);
|
2011-11-08 04:15:45 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsRefPtr<IDBFactory> factory;
|
|
|
|
mFactory.swap(factory);
|
2013-09-11 08:18:36 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
factory->BackgroundActorCreated(aActor);
|
2013-09-11 08:18:36 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
IDBFactory::BackgroundCreateCallback::ActorFailed()
|
2011-11-08 04:15:45 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(mFactory);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsRefPtr<IDBFactory> factory;
|
|
|
|
mFactory.swap(factory);
|
2011-11-08 23:03:18 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
factory->BackgroundActorFailed();
|
2013-03-31 12:18:30 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|