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
|
|
|
|
|
|
|
#include "IDBRequest.h"
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
|
2013-09-25 04:21:20 -07:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2014-03-17 21:48:21 -07:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2014-02-22 21:01:12 -08:00
|
|
|
#include "mozilla/dom/ErrorEventBinding.h"
|
2013-07-31 15:28:15 -07:00
|
|
|
#include "mozilla/dom/IDBOpenDBRequestBinding.h"
|
2014-07-01 02:09:46 -07:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2013-08-22 22:17:10 -07:00
|
|
|
#include "mozilla/dom/UnionTypes.h"
|
2014-09-17 16:36:01 -07:00
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsDOMClassInfoID.h"
|
|
|
|
#include "nsDOMJSUtils.h"
|
2011-10-03 12:11:31 -07:00
|
|
|
#include "nsContentUtils.h"
|
2012-06-29 09:48:34 -07:00
|
|
|
#include "nsJSUtils.h"
|
2010-08-26 13:57:25 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
2013-09-23 10:25:00 -07:00
|
|
|
#include "nsString.h"
|
2014-09-17 16:36:01 -07:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsWrapperCacheInlines.h"
|
|
|
|
|
|
|
|
#include "AsyncConnectionHelper.h"
|
|
|
|
#include "IDBCursor.h"
|
|
|
|
#include "IDBEvents.h"
|
|
|
|
#include "IDBFactory.h"
|
|
|
|
#include "IDBIndex.h"
|
|
|
|
#include "IDBObjectStore.h"
|
|
|
|
#include "IDBTransaction.h"
|
2014-01-27 16:37:05 -08:00
|
|
|
#include "ReportInternalError.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
uint64_t gNextRequestSerialNumber = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // anonymous namespace
|
2013-03-15 23:58:50 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
USING_INDEXEDDB_NAMESPACE
|
|
|
|
using mozilla::dom::OwningIDBObjectStoreOrIDBIndexOrIDBCursor;
|
|
|
|
using mozilla::dom::ErrorEventInit;
|
|
|
|
using namespace mozilla;
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2014-01-06 21:32:20 -08:00
|
|
|
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
2014-09-17 16:36:01 -07:00
|
|
|
: IDBWrapperCache(aDatabase),
|
|
|
|
mResultVal(JSVAL_VOID),
|
|
|
|
mActorParent(nullptr),
|
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
mSerialNumber(gNextRequestSerialNumber++),
|
|
|
|
#endif
|
|
|
|
mErrorCode(NS_OK),
|
|
|
|
mLineNo(0),
|
|
|
|
mHaveResultOrErrorCode(false)
|
2010-11-10 15:26:03 -08:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2014-01-06 21:32:20 -08:00
|
|
|
}
|
2013-07-31 15:28:15 -07:00
|
|
|
|
2014-01-06 21:32:20 -08:00
|
|
|
IDBRequest::IDBRequest(nsPIDOMWindow* aOwner)
|
2014-09-17 16:36:01 -07:00
|
|
|
: IDBWrapperCache(aOwner),
|
|
|
|
mResultVal(JSVAL_VOID),
|
|
|
|
mActorParent(nullptr),
|
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
mSerialNumber(gNextRequestSerialNumber++),
|
|
|
|
#endif
|
|
|
|
mErrorCode(NS_OK),
|
|
|
|
mLineNo(0),
|
|
|
|
mHaveResultOrErrorCode(false)
|
2014-01-06 21:32:20 -08:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2010-11-10 15:26:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
IDBRequest::~IDBRequest()
|
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
mResultVal = JSVAL_VOID;
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2010-11-10 15:26:03 -08:00
|
|
|
}
|
|
|
|
|
2010-09-09 15:15:38 -07:00
|
|
|
// static
|
2010-08-26 13:57:25 -07:00
|
|
|
already_AddRefed<IDBRequest>
|
2013-11-04 04:57:53 -08:00
|
|
|
IDBRequest::Create(IDBDatabase* aDatabase,
|
2013-06-20 11:05:33 -07:00
|
|
|
IDBTransaction* aTransaction)
|
2010-06-23 12:46:08 -07:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
nsRefPtr<IDBRequest> request(new IDBRequest(aDatabase));
|
2010-08-26 13:57:25 -07:00
|
|
|
|
2010-11-10 15:26:03 -08:00
|
|
|
request->mTransaction = aTransaction;
|
2013-11-04 04:57:53 -08:00
|
|
|
request->SetScriptOwner(aDatabase->GetScriptOwner());
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
if (!aDatabase->Factory()->FromIPC()) {
|
|
|
|
request->CaptureCaller();
|
|
|
|
}
|
|
|
|
|
2012-06-29 09:48:34 -07:00
|
|
|
|
2010-08-26 13:57:25 -07:00
|
|
|
return request.forget();
|
2010-06-23 12:46:08 -07:00
|
|
|
}
|
|
|
|
|
2013-08-22 22:17:10 -07:00
|
|
|
// static
|
|
|
|
already_AddRefed<IDBRequest>
|
|
|
|
IDBRequest::Create(IDBObjectStore* aSourceAsObjectStore,
|
2013-11-04 04:57:53 -08:00
|
|
|
IDBDatabase* aDatabase,
|
2013-08-22 22:17:10 -07:00
|
|
|
IDBTransaction* aTransaction)
|
|
|
|
{
|
2013-11-04 04:57:53 -08:00
|
|
|
nsRefPtr<IDBRequest> request = Create(aDatabase, aTransaction);
|
2013-08-22 22:17:10 -07:00
|
|
|
|
|
|
|
request->mSourceAsObjectStore = aSourceAsObjectStore;
|
|
|
|
|
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
already_AddRefed<IDBRequest>
|
|
|
|
IDBRequest::Create(IDBIndex* aSourceAsIndex,
|
2013-11-04 04:57:53 -08:00
|
|
|
IDBDatabase* aDatabase,
|
2013-08-22 22:17:10 -07:00
|
|
|
IDBTransaction* aTransaction)
|
|
|
|
{
|
2013-11-04 04:57:53 -08:00
|
|
|
nsRefPtr<IDBRequest> request = Create(aDatabase, aTransaction);
|
2013-08-22 22:17:10 -07:00
|
|
|
|
|
|
|
request->mSourceAsIndex = aSourceAsIndex;
|
|
|
|
|
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
#ifdef DEBUG
|
2013-08-22 22:17:10 -07:00
|
|
|
void
|
2014-09-17 16:36:01 -07:00
|
|
|
IDBRequest::AssertSourceIsCorrect() const
|
2013-08-22 22:17:10 -07:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
// At most one of mSourceAs* is allowed to be non-null. Check that by
|
|
|
|
// summing the double negation of each one and asserting the sum is at most
|
|
|
|
// 1.
|
2013-08-22 22:17:10 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
MOZ_ASSERT(!!mSourceAsObjectStore + !!mSourceAsIndex + !!mSourceAsCursor <= 1);
|
|
|
|
}
|
|
|
|
#endif
|
2013-08-22 22:17:10 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
void
|
|
|
|
IDBRequest::GetSource(Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
AssertSourceIsCorrect();
|
|
|
|
|
|
|
|
if (mSourceAsObjectStore) {
|
2013-08-22 22:17:10 -07:00
|
|
|
aSource.SetValue().SetAsIDBObjectStore() = mSourceAsObjectStore;
|
|
|
|
} else if (mSourceAsIndex) {
|
|
|
|
aSource.SetValue().SetAsIDBIndex() = mSourceAsIndex;
|
2014-09-17 16:36:01 -07:00
|
|
|
} else if (mSourceAsCursor) {
|
|
|
|
aSource.SetValue().SetAsIDBCursor() = mSourceAsCursor;
|
2013-08-22 22:17:10 -07:00
|
|
|
} else {
|
|
|
|
aSource.SetNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:21:36 -08:00
|
|
|
void
|
|
|
|
IDBRequest::Reset()
|
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
mResultVal = JSVAL_VOID;
|
2011-01-06 22:21:36 -08:00
|
|
|
mHaveResultOrErrorCode = false;
|
2012-07-30 07:20:58 -07:00
|
|
|
mError = nullptr;
|
2011-01-06 22:21:36 -08:00
|
|
|
}
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
nsresult
|
|
|
|
IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
|
|
|
|
NS_ASSERTION(mResultVal.isUndefined(), "Should be undefined!");
|
|
|
|
|
|
|
|
mHaveResultOrErrorCode = true;
|
|
|
|
|
|
|
|
nsresult rv = aHelper->GetResultCode();
|
|
|
|
|
|
|
|
// If the request failed then set the error code and return.
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
SetError(rv);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise we need to get the result from the helper.
|
|
|
|
AutoJSAPI jsapi;
|
|
|
|
Maybe<JSAutoCompartment> ac;
|
|
|
|
if (GetScriptOwner()) {
|
|
|
|
// If we have a script owner we want the SafeJSContext and then to enter
|
|
|
|
// the script owner's compartment.
|
|
|
|
jsapi.Init();
|
|
|
|
ac.emplace(jsapi.cx(), GetScriptOwner());
|
|
|
|
} else {
|
|
|
|
// Otherwise our owner is a window and we use that to initialize.
|
|
|
|
if (!jsapi.InitWithLegacyErrorReporting(GetOwner())) {
|
|
|
|
IDB_WARNING("Failed to initialise AutoJSAPI!");
|
|
|
|
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
|
|
SetError(rv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSContext* cx = jsapi.cx();
|
|
|
|
|
|
|
|
AssertIsRooted();
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> value(cx);
|
|
|
|
rv = aHelper->GetSuccessResult(cx, &value);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("GetSuccessResult failed!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mError = nullptr;
|
|
|
|
mResultVal = value;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetError(rv);
|
|
|
|
mResultVal = JSVAL_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-04-11 14:55:21 -07:00
|
|
|
void
|
2014-09-17 16:36:01 -07:00
|
|
|
IDBRequest::NotifyHelperSentResultsToChildProcess(nsresult aRv)
|
2012-04-11 14:55:21 -07:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
|
|
|
|
NS_ASSERTION(mResultVal.isUndefined(), "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())) {
|
2012-06-01 10:21:12 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
mHaveResultOrErrorCode = true;
|
|
|
|
|
|
|
|
if (NS_FAILED(aRv)) {
|
|
|
|
SetError(aRv);
|
|
|
|
}
|
2012-06-01 10:21:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::SetError(nsresult aRv)
|
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_FAILED(aRv), "Er, what?");
|
|
|
|
NS_ASSERTION(!mError, "Already have an error?");
|
2012-04-11 14:55:21 -07:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
mHaveResultOrErrorCode = true;
|
2014-09-17 16:36:01 -07:00
|
|
|
mError = new mozilla::dom::DOMError(GetOwner(), aRv);
|
2012-06-01 10:21:12 -07:00
|
|
|
mErrorCode = aRv;
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
mResultVal = JSVAL_VOID;
|
2012-06-01 10:21:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsresult
|
|
|
|
IDBRequest::GetErrorCode() const
|
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(mHaveResultOrErrorCode, "Don't call me yet!");
|
2012-06-01 10:21:12 -07:00
|
|
|
return mErrorCode;
|
|
|
|
}
|
2014-09-17 16:36:01 -07:00
|
|
|
#endif
|
2012-06-01 10:21:12 -07:00
|
|
|
|
2012-06-29 09:48:34 -07:00
|
|
|
void
|
2013-06-20 11:05:33 -07:00
|
|
|
IDBRequest::CaptureCaller()
|
2012-06-29 09:48:34 -07:00
|
|
|
{
|
2013-06-20 11:05:33 -07:00
|
|
|
AutoJSContext cx;
|
2012-06-29 09:48:34 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
const char* filename = nullptr;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t lineNo = 0;
|
2013-06-20 11:05:33 -07:00
|
|
|
if (!nsJSUtils::GetCallingLocation(cx, &filename, &lineNo)) {
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_WARNING("Failed to get caller.");
|
2012-06-29 09:48:34 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFilename.Assign(NS_ConvertUTF8toUTF16(filename));
|
|
|
|
mLineNo = lineNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-22 21:01:12 -08:00
|
|
|
IDBRequest::FillScriptErrorEvent(ErrorEventInit& aEventInit) const
|
2012-06-29 09:48:34 -07:00
|
|
|
{
|
2014-02-22 21:01:12 -08:00
|
|
|
aEventInit.mLineno = mLineNo;
|
|
|
|
aEventInit.mFilename = mFilename;
|
2012-06-29 09:48:34 -07:00
|
|
|
}
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
mozilla::dom::IDBRequestReadyState
|
2013-07-31 15:28:15 -07:00
|
|
|
IDBRequest::ReadyState() const
|
2010-06-23 12:46:08 -07:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2011-10-20 09:10:56 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
if (IsPending()) {
|
|
|
|
return IDBRequestReadyState::Pending;
|
|
|
|
}
|
2014-09-13 09:12:19 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
return IDBRequestReadyState::Done;
|
2010-06-23 12:46:08 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 15:28:15 -07:00
|
|
|
JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
IDBRequest::WrapObject(JSContext* aCx)
|
2010-12-09 18:14:09 -08: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-08 15:27:17 -07:00
|
|
|
return IDBRequestBinding::Wrap(aCx, this);
|
2010-12-09 18:14:09 -08:00
|
|
|
}
|
|
|
|
|
2014-06-11 13:26:52 -07:00
|
|
|
void
|
|
|
|
IDBRequest::GetResult(JS::MutableHandle<JS::Value> aResult,
|
|
|
|
ErrorResult& aRv) const
|
2011-01-06 22:21:36 -08:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2011-01-06 22:21:36 -08:00
|
|
|
|
|
|
|
if (!mHaveResultOrErrorCode) {
|
2014-09-17 16:36:01 -07:00
|
|
|
// XXX Need a real error code here.
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
2011-01-06 22:21:36 -08:00
|
|
|
}
|
|
|
|
|
2014-06-11 13:26:52 -07:00
|
|
|
JS::ExposeValueToActiveJS(mResultVal);
|
|
|
|
aResult.set(mResultVal);
|
2011-01-06 22:21:36 -08:00
|
|
|
}
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
mozilla::dom::DOMError*
|
|
|
|
IDBRequest::GetError(mozilla::ErrorResult& aRv)
|
2011-01-06 22:21:36 -08:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2011-01-06 22:21:36 -08:00
|
|
|
|
2011-01-26 17:53:02 -08:00
|
|
|
if (!mHaveResultOrErrorCode) {
|
2013-05-18 10:52:06 -07:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return nullptr;
|
2011-01-06 22:21:36 -08:00
|
|
|
}
|
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
return mError;
|
|
|
|
}
|
|
|
|
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBRequest)
|
|
|
|
|
2012-01-24 02:03:37 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because
|
2014-03-31 23:13:50 -07:00
|
|
|
// DOMEventTargetHelper does it for us.
|
2013-08-22 22:17:10 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsObjectStore)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsIndex)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsCursor)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransaction)
|
2013-05-27 13:43:09 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
2010-06-23 12:46:08 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2012-01-24 02:03:37 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
2014-09-17 16:36:01 -07:00
|
|
|
tmp->mResultVal = JSVAL_VOID;
|
2013-08-22 22:17:10 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsObjectStore)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsIndex)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsCursor)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTransaction)
|
2013-05-27 13:43:09 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
2010-06-23 12:46:08 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2012-01-24 02:03:37 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
2014-03-31 23:13:50 -07:00
|
|
|
// DOMEventTargetHelper does it for us.
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mResultVal)
|
2011-01-06 22:21:36 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBRequest)
|
2012-01-24 02:03:37 -08:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2012-01-24 02:03:37 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2010-11-10 15:26:03 -08:00
|
|
|
nsresult
|
2014-03-17 21:48:19 -07:00
|
|
|
IDBRequest::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
2010-11-10 15:26:03 -08:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2011-01-06 22:21:36 -08:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
aVisitor.mCanHandle = true;
|
2010-11-10 15:26:03 -08:00
|
|
|
aVisitor.mParentTarget = mTransaction;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
IDBOpenDBRequest::IDBOpenDBRequest(nsPIDOMWindow* aOwner)
|
2014-01-06 21:32:20 -08:00
|
|
|
: IDBRequest(aOwner)
|
2013-07-31 15:28:15 -07:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2013-07-31 15:28:15 -07:00
|
|
|
}
|
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
IDBOpenDBRequest::~IDBOpenDBRequest()
|
2011-01-06 22:21:36 -08:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2011-01-06 22:21:36 -08:00
|
|
|
}
|
|
|
|
|
2010-10-19 10:58:52 -07:00
|
|
|
// static
|
2011-10-20 09:10:56 -07:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
2014-09-17 16:36:01 -07:00
|
|
|
IDBOpenDBRequest::Create(IDBFactory* aFactory,
|
|
|
|
nsPIDOMWindow* aOwner,
|
|
|
|
JS::Handle<JSObject*> aScriptOwner)
|
2010-10-19 10:58:52 -07:00
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(aFactory, "Null pointer!");
|
2012-08-29 17:50:28 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aOwner);
|
2010-10-19 10:58:52 -07:00
|
|
|
|
2012-11-29 14:54:14 -08:00
|
|
|
request->SetScriptOwner(aScriptOwner);
|
2014-09-17 16:36:01 -07:00
|
|
|
request->mFactory = aFactory;
|
2012-06-29 09:48:34 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
if (!aFactory->FromIPC()) {
|
|
|
|
request->CaptureCaller();
|
|
|
|
}
|
2013-11-04 04:57:53 -08:00
|
|
|
|
2010-10-19 10:58:52 -07:00
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:21:36 -08:00
|
|
|
void
|
2011-10-20 09:10:56 -07:00
|
|
|
IDBOpenDBRequest::SetTransaction(IDBTransaction* aTransaction)
|
|
|
|
{
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2012-06-01 10:21:12 -07:00
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
NS_ASSERTION(!aTransaction || !mTransaction,
|
|
|
|
"Shouldn't have a transaction here!");
|
2012-06-01 10:21:12 -07:00
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
mTransaction = aTransaction;
|
|
|
|
}
|
|
|
|
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBOpenDBRequest)
|
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBOpenDBRequest,
|
2010-10-19 10:58:52 -07:00
|
|
|
IDBRequest)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFactory)
|
2010-10-19 10:58:52 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBOpenDBRequest,
|
2010-10-19 10:58:52 -07:00
|
|
|
IDBRequest)
|
2012-08-29 17:50:28 -07:00
|
|
|
// Don't unlink mFactory!
|
2010-10-19 10:58:52 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBOpenDBRequest)
|
2010-10-19 10:58:52 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(IDBRequest)
|
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBOpenDBRequest, IDBRequest)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBOpenDBRequest, IDBRequest)
|
2010-10-19 10:58:52 -07:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
nsresult
|
2014-03-17 21:48:20 -07:00
|
|
|
IDBOpenDBRequest::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
2012-06-01 10:21:12 -07:00
|
|
|
{
|
2012-06-29 09:48:34 -07:00
|
|
|
return IndexedDatabaseManager::FireWindowOnError(GetOwner(), aVisitor);
|
2012-06-01 10:21:12 -07:00
|
|
|
}
|
2013-07-31 15:28:15 -07:00
|
|
|
|
|
|
|
JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
IDBOpenDBRequest::WrapObject(JSContext* aCx)
|
2013-07-31 15:28:15 -07: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-08 15:27:17 -07:00
|
|
|
return IDBOpenDBRequestBinding::Wrap(aCx, this);
|
2013-07-31 15:28:15 -07:00
|
|
|
}
|