2010-06-23 19:46:08 +00: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 11:12:37 +00: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 19:46:08 +00:00
|
|
|
|
|
|
|
#include "IDBRequest.h"
|
|
|
|
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
|
|
|
|
#include "nsComponentManagerUtils.h"
|
2011-10-03 19:11:31 +00:00
|
|
|
#include "nsDOMClassInfoID.h"
|
2010-08-26 20:57:25 +00:00
|
|
|
#include "nsDOMJSUtils.h"
|
2011-10-03 19:11:31 +00:00
|
|
|
#include "nsContentUtils.h"
|
2013-05-22 16:05:26 +00:00
|
|
|
#include "nsCxPusher.h"
|
2010-11-10 23:26:03 +00:00
|
|
|
#include "nsEventDispatcher.h"
|
2012-06-29 16:48:34 +00:00
|
|
|
#include "nsJSUtils.h"
|
2010-08-26 20:57:25 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2012-01-03 15:27:39 +00:00
|
|
|
#include "nsWrapperCacheInlines.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2011-01-07 06:21:36 +00:00
|
|
|
#include "AsyncConnectionHelper.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
#include "IDBEvents.h"
|
2012-08-30 00:50:28 +00:00
|
|
|
#include "IDBFactory.h"
|
2010-11-10 23:26:03 +00:00
|
|
|
#include "IDBTransaction.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2013-03-16 06:58:50 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
uint64_t gNextSerialNumber = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
USING_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-11-10 23:26:03 +00:00
|
|
|
IDBRequest::IDBRequest()
|
2011-01-07 06:21:36 +00:00
|
|
|
: mResultVal(JSVAL_VOID),
|
2012-07-30 14:20:58 +00:00
|
|
|
mActorParent(nullptr),
|
2013-03-16 06:58:50 +00:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
mSerialNumber(gNextSerialNumber++),
|
|
|
|
#endif
|
2012-06-01 17:21:12 +00:00
|
|
|
mErrorCode(NS_OK),
|
2013-03-16 06:58:50 +00:00
|
|
|
mLineNo(0),
|
|
|
|
mHaveResultOrErrorCode(false)
|
2010-11-10 23:26:03 +00:00
|
|
|
{
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2010-11-10 23:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IDBRequest::~IDBRequest()
|
|
|
|
{
|
2012-11-28 01:37:57 +00:00
|
|
|
mResultVal = JSVAL_VOID;
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2010-11-10 23:26:03 +00:00
|
|
|
}
|
|
|
|
|
2010-09-09 22:15:38 +00:00
|
|
|
// static
|
2010-08-26 20:57:25 +00:00
|
|
|
already_AddRefed<IDBRequest>
|
2010-09-09 22:15:38 +00:00
|
|
|
IDBRequest::Create(nsISupports* aSource,
|
2012-01-24 10:03:37 +00:00
|
|
|
IDBWrapperCache* aOwnerCache,
|
2013-06-20 18:05:33 +00:00
|
|
|
IDBTransaction* aTransaction)
|
2010-06-23 19:46:08 +00:00
|
|
|
{
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2010-08-26 20:57:25 +00:00
|
|
|
nsRefPtr<IDBRequest> request(new IDBRequest());
|
|
|
|
|
2010-09-09 22:15:38 +00:00
|
|
|
request->mSource = aSource;
|
2010-11-10 23:26:03 +00:00
|
|
|
request->mTransaction = aTransaction;
|
2012-03-13 00:56:07 +00:00
|
|
|
request->BindToOwner(aOwnerCache);
|
2012-11-29 22:54:14 +00:00
|
|
|
request->SetScriptOwner(aOwnerCache->GetScriptOwner());
|
2013-06-20 18:05:33 +00:00
|
|
|
request->CaptureCaller();
|
2012-06-29 16:48:34 +00:00
|
|
|
|
2010-08-26 20:57:25 +00:00
|
|
|
return request.forget();
|
2010-06-23 19:46:08 +00:00
|
|
|
}
|
|
|
|
|
2011-01-07 06:21:36 +00:00
|
|
|
void
|
|
|
|
IDBRequest::Reset()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
mResultVal = JSVAL_VOID;
|
|
|
|
mHaveResultOrErrorCode = false;
|
2012-07-30 14:20:58 +00:00
|
|
|
mError = nullptr;
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
|
|
|
|
2011-01-27 01:53:02 +00:00
|
|
|
nsresult
|
2011-10-20 16:10:56 +00:00
|
|
|
IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
2011-01-07 06:21:36 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2011-01-27 01:53:02 +00:00
|
|
|
NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
|
|
|
|
NS_ASSERTION(JSVAL_IS_VOID(mResultVal), "Should be undefined!");
|
|
|
|
|
|
|
|
mHaveResultOrErrorCode = true;
|
|
|
|
|
|
|
|
nsresult rv = aHelper->GetResultCode();
|
|
|
|
|
|
|
|
// If the request failed then set the error code and return.
|
|
|
|
if (NS_FAILED(rv)) {
|
2012-06-01 17:21:12 +00:00
|
|
|
SetError(rv);
|
2011-01-27 01:53:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-20 18:20:15 +00:00
|
|
|
// See if our window is still valid. If not then we're going to pretend that
|
|
|
|
// we never completed.
|
|
|
|
if (NS_FAILED(CheckInnerWindowCorrectness())) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-27 01:53:02 +00:00
|
|
|
// Otherwise we need to get the result from the helper.
|
2013-02-26 19:04:13 +00:00
|
|
|
AutoPushJSContext cx(GetJSContext());
|
2012-06-01 17:21:12 +00:00
|
|
|
if (!cx) {
|
|
|
|
NS_WARNING("Failed to get safe JSContext!");
|
|
|
|
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
|
|
SetError(rv);
|
|
|
|
return rv;
|
2012-01-23 16:18:14 +00:00
|
|
|
}
|
2012-01-24 10:03:37 +00:00
|
|
|
|
2013-05-02 09:12:47 +00:00
|
|
|
JS::Rooted<JSObject*> global(cx, GetParentObject());
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_ASSERTION(global, "This should never be null!");
|
2011-01-27 01:53:02 +00:00
|
|
|
|
2012-08-22 01:42:53 +00:00
|
|
|
JSAutoCompartment ac(cx, global);
|
|
|
|
AssertIsRooted();
|
|
|
|
|
2013-06-18 10:00:37 +00:00
|
|
|
JS::Rooted<JS::Value> value(cx);
|
2013-06-21 13:12:46 +00:00
|
|
|
rv = aHelper->GetSuccessResult(cx, &value);
|
2012-08-22 01:42:53 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("GetSuccessResult failed!");
|
2012-01-24 10:03:37 +00:00
|
|
|
}
|
2011-01-07 06:21:36 +00:00
|
|
|
|
2011-01-27 01:53:02 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mError = nullptr;
|
2013-06-18 10:00:37 +00:00
|
|
|
mResultVal = value;
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-06-01 17:21:12 +00:00
|
|
|
SetError(rv);
|
2011-01-27 01:53:02 +00:00
|
|
|
mResultVal = JSVAL_VOID;
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
2011-01-27 01:53:02 +00:00
|
|
|
|
|
|
|
return rv;
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-11 21:55:21 +00:00
|
|
|
void
|
2012-06-01 17:21:12 +00:00
|
|
|
IDBRequest::NotifyHelperSentResultsToChildProcess(nsresult aRv)
|
2012-04-11 21:55:21 +00:00
|
|
|
{
|
2012-06-01 17:21:12 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
|
|
|
|
NS_ASSERTION(JSVAL_IS_VOID(mResultVal), "Should be undefined!");
|
|
|
|
|
|
|
|
// See if our window is still valid. If not then we're going to pretend that
|
|
|
|
// we never completed.
|
|
|
|
if (NS_FAILED(CheckInnerWindowCorrectness())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mHaveResultOrErrorCode = true;
|
|
|
|
|
|
|
|
if (NS_FAILED(aRv)) {
|
|
|
|
SetError(aRv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::SetError(nsresult aRv)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_FAILED(aRv), "Er, what?");
|
2012-04-11 21:55:21 +00:00
|
|
|
NS_ASSERTION(!mError, "Already have an error?");
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
mHaveResultOrErrorCode = true;
|
2013-05-18 17:52:06 +00:00
|
|
|
mError = new mozilla::dom::DOMError(GetOwner(), aRv);
|
2012-06-01 17:21:12 +00:00
|
|
|
mErrorCode = aRv;
|
|
|
|
|
|
|
|
mResultVal = JSVAL_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsresult
|
|
|
|
IDBRequest::GetErrorCode() const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(mHaveResultOrErrorCode, "Don't call me yet!");
|
|
|
|
return mErrorCode;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
JSContext*
|
|
|
|
IDBRequest::GetJSContext()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
JSContext* cx;
|
|
|
|
|
|
|
|
if (GetScriptOwner()) {
|
2013-04-18 15:36:03 +00:00
|
|
|
return nsContentUtils::GetSafeJSContext();
|
2012-06-01 17:21:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
|
|
NS_ENSURE_TRUE(sc, nullptr);
|
2012-06-01 17:21:12 +00:00
|
|
|
|
|
|
|
cx = sc->GetNativeContext();
|
|
|
|
NS_ASSERTION(cx, "Failed to get a context!");
|
|
|
|
|
|
|
|
return cx;
|
2012-04-11 21:55:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 16:48:34 +00:00
|
|
|
void
|
2013-06-20 18:05:33 +00:00
|
|
|
IDBRequest::CaptureCaller()
|
2012-06-29 16:48:34 +00:00
|
|
|
{
|
2013-06-20 18:05:33 +00:00
|
|
|
AutoJSContext cx;
|
2012-06-29 16:48:34 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
const char* filename = nullptr;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t lineNo = 0;
|
2013-06-20 18:05:33 +00:00
|
|
|
if (!nsJSUtils::GetCallingLocation(cx, &filename, &lineNo)) {
|
|
|
|
// If our caller is in another process, we won't have a JSContext on the
|
|
|
|
// stack, and AutoJSContext will push the SafeJSContext. But that won't have
|
|
|
|
// any script on it (certainly not after the push), so GetCallingLocation
|
|
|
|
// will fail when it calls JS_DescribeScriptedCaller. That's fine.
|
2012-06-29 16:48:34 +00:00
|
|
|
NS_WARNING("Failed to get caller.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFilename.Assign(NS_ConvertUTF8toUTF16(filename));
|
|
|
|
mLineNo = lineNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::FillScriptErrorEvent(nsScriptErrorEvent* aEvent) const
|
|
|
|
{
|
|
|
|
aEvent->lineNr = mLineNo;
|
|
|
|
aEvent->fileName = mFilename.get();
|
|
|
|
}
|
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
NS_IMETHODIMP
|
2012-03-13 04:44:45 +00:00
|
|
|
IDBRequest::GetReadyState(nsAString& aReadyState)
|
2010-06-23 19:46:08 +00:00
|
|
|
{
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2012-11-10 03:29:07 +00:00
|
|
|
if (IsPending()) {
|
|
|
|
aReadyState.AssignLiteral("pending");
|
2012-03-13 04:44:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-11-10 03:29:07 +00:00
|
|
|
aReadyState.AssignLiteral("done");
|
2012-03-13 04:44:45 +00:00
|
|
|
}
|
2011-10-20 16:10:56 +00:00
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-10 02:14:09 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
IDBRequest::GetSource(nsISupports** aSource)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> source(mSource);
|
|
|
|
source.forget(aSource);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
IDBRequest::GetTransaction(nsIIDBTransaction** aTransaction)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIIDBTransaction> transaction(mTransaction);
|
|
|
|
transaction.forget(aTransaction);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-01-27 01:53:02 +00:00
|
|
|
IDBRequest::GetResult(jsval* aResult)
|
2011-01-07 06:21:36 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
if (!mHaveResultOrErrorCode) {
|
2011-01-27 01:53:02 +00:00
|
|
|
// XXX Need a real error code here.
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = mResultVal;
|
2011-01-27 01:53:02 +00:00
|
|
|
return NS_OK;
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
|
|
|
|
2013-05-18 17:52:06 +00:00
|
|
|
mozilla::dom::DOMError*
|
|
|
|
IDBRequest::GetError(mozilla::ErrorResult& aRv)
|
2011-01-07 06:21:36 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-01-27 01:53:02 +00:00
|
|
|
if (!mHaveResultOrErrorCode) {
|
2013-05-18 17:52:06 +00:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return nullptr;
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
|
|
|
|
2013-05-18 17:52:06 +00:00
|
|
|
return mError;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
IDBRequest::GetError(nsISupports** aError)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
*aError = GetError(rv);
|
|
|
|
NS_IF_ADDREF(*aError);
|
|
|
|
return rv.ErrorCode();
|
2011-01-07 06:21:36 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because
|
|
|
|
// nsDOMEventTargetHelper does it for us.
|
2012-11-15 07:32:40 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSource)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransaction)
|
2013-05-27 20:43:09 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
2010-06-23 19:46:08 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
tmp->mResultVal = JSVAL_VOID;
|
2012-11-15 07:32:40 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSource)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTransaction)
|
2013-05-27 20:43:09 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
2010-06-23 19:46:08 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
|
|
|
// nsDOMEventTargetHelper does it for us.
|
2012-06-10 23:44:50 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mResultVal)
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBRequest)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIIDBRequest)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBRequest)
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
|
2010-06-23 19:46:08 +00:00
|
|
|
|
|
|
|
DOMCI_DATA(IDBRequest, IDBRequest)
|
2010-10-19 17:58:52 +00:00
|
|
|
|
2012-08-31 03:45:16 +00:00
|
|
|
NS_IMPL_EVENT_HANDLER(IDBRequest, success)
|
|
|
|
NS_IMPL_EVENT_HANDLER(IDBRequest, error)
|
2012-01-24 10:03:37 +00:00
|
|
|
|
2010-11-10 23:26:03 +00:00
|
|
|
nsresult
|
|
|
|
IDBRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|
|
|
{
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
aVisitor.mCanHandle = true;
|
2010-11-10 23:26:03 +00:00
|
|
|
aVisitor.mParentTarget = mTransaction;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-20 16:10:56 +00:00
|
|
|
IDBOpenDBRequest::~IDBOpenDBRequest()
|
2011-01-07 06:21:36 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
}
|
|
|
|
|
2010-10-19 17:58:52 +00:00
|
|
|
// static
|
2011-10-20 16:10:56 +00:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
2012-08-30 00:50:28 +00:00
|
|
|
IDBOpenDBRequest::Create(IDBFactory* aFactory,
|
|
|
|
nsPIDOMWindow* aOwner,
|
2013-06-20 18:05:33 +00:00
|
|
|
JS::Handle<JSObject*> aScriptOwner)
|
2010-10-19 17:58:52 +00:00
|
|
|
{
|
2011-01-07 06:21:36 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2012-08-30 00:50:28 +00:00
|
|
|
NS_ASSERTION(aFactory, "Null pointer!");
|
|
|
|
|
|
|
|
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest();
|
2010-10-19 17:58:52 +00:00
|
|
|
|
2012-03-13 00:56:07 +00:00
|
|
|
request->BindToOwner(aOwner);
|
2012-11-29 22:54:14 +00:00
|
|
|
request->SetScriptOwner(aScriptOwner);
|
2013-06-20 18:05:33 +00:00
|
|
|
request->CaptureCaller();
|
2012-08-30 00:50:28 +00:00
|
|
|
request->mFactory = aFactory;
|
2012-06-29 16:48:34 +00:00
|
|
|
|
2010-10-19 17:58:52 +00:00
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
2011-01-07 06:21:36 +00:00
|
|
|
void
|
2011-10-20 16:10:56 +00:00
|
|
|
IDBOpenDBRequest::SetTransaction(IDBTransaction* aTransaction)
|
|
|
|
{
|
2012-06-01 17:21:12 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
NS_ASSERTION(!aTransaction || !mTransaction,
|
|
|
|
"Shouldn't have a transaction here!");
|
|
|
|
|
2011-10-20 16:10:56 +00:00
|
|
|
mTransaction = aTransaction;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBOpenDBRequest,
|
2010-10-19 17:58:52 +00:00
|
|
|
IDBRequest)
|
2012-11-15 07:32:40 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFactory)
|
2010-10-19 17:58:52 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2011-10-20 16:10:56 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBOpenDBRequest,
|
2010-10-19 17:58:52 +00:00
|
|
|
IDBRequest)
|
2012-08-30 00:50:28 +00:00
|
|
|
// Don't unlink mFactory!
|
2010-10-19 17:58:52 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2011-10-20 16:10:56 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBOpenDBRequest)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIIDBOpenDBRequest)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBOpenDBRequest)
|
2010-10-19 17:58:52 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(IDBRequest)
|
|
|
|
|
2011-10-20 16:10:56 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBOpenDBRequest, IDBRequest)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBOpenDBRequest, IDBRequest)
|
2010-10-19 17:58:52 +00:00
|
|
|
|
2011-10-20 16:10:56 +00:00
|
|
|
DOMCI_DATA(IDBOpenDBRequest, IDBOpenDBRequest)
|
2012-01-24 10:03:37 +00:00
|
|
|
|
2012-08-31 03:45:16 +00:00
|
|
|
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, blocked)
|
|
|
|
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, upgradeneeded)
|
2012-06-01 17:21:12 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
IDBOpenDBRequest::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
|
|
|
{
|
2012-06-29 16:48:34 +00:00
|
|
|
return IndexedDatabaseManager::FireWindowOnError(GetOwner(), aVisitor);
|
2012-06-01 17:21:12 +00:00
|
|
|
}
|