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
|
|
|
|
|
|
|
#include "IDBRequest.h"
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "BackgroundChildImpl.h"
|
|
|
|
#include "IDBCursor.h"
|
|
|
|
#include "IDBDatabase.h"
|
|
|
|
#include "IDBEvents.h"
|
|
|
|
#include "IDBFactory.h"
|
|
|
|
#include "IDBIndex.h"
|
|
|
|
#include "IDBObjectStore.h"
|
|
|
|
#include "IDBTransaction.h"
|
2013-09-25 15:21:20 +04:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2014-02-23 09:01:12 +04:00
|
|
|
#include "mozilla/dom/ErrorEventBinding.h"
|
2013-08-01 02:28:15 +04:00
|
|
|
#include "mozilla/dom/IDBOpenDBRequestBinding.h"
|
2014-07-01 13:09:46 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2013-08-23 09:17:10 +04:00
|
|
|
#include "mozilla/dom/UnionTypes.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2011-10-03 23:11:31 +04:00
|
|
|
#include "nsContentUtils.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "nsIScriptContext.h"
|
2012-06-29 20:48:34 +04:00
|
|
|
#include "nsJSUtils.h"
|
2010-08-27 00:57:25 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2013-09-23 21:25:00 +04:00
|
|
|
#include "nsString.h"
|
2014-01-28 04:37:05 +04:00
|
|
|
#include "ReportInternalError.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
using namespace mozilla::ipc;
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-01-07 09:32:20 +04:00
|
|
|
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
2014-09-27 03:21:57 +04:00
|
|
|
: IDBWrapperCache(aDatabase)
|
2010-11-11 02:26:03 +03:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aDatabase);
|
|
|
|
aDatabase->AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
InitMembers();
|
2014-01-07 09:32:20 +04:00
|
|
|
}
|
2013-08-01 02:28:15 +04:00
|
|
|
|
2014-01-07 09:32:20 +04:00
|
|
|
IDBRequest::IDBRequest(nsPIDOMWindow* aOwner)
|
2014-09-27 03:21:57 +04:00
|
|
|
: IDBWrapperCache(aOwner)
|
2014-01-07 09:32:20 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
InitMembers();
|
2010-11-11 02:26:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
IDBRequest::~IDBRequest()
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::AssertIsOnOwningThread() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mOwningThread);
|
|
|
|
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::InitMembers()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
mOwningThread = PR_GetCurrentThread();
|
|
|
|
#endif
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
mResultVal.setUndefined();
|
|
|
|
mErrorCode = NS_OK;
|
|
|
|
mLineNo = 0;
|
|
|
|
mHaveResultOrErrorCode = false;
|
|
|
|
|
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
{
|
|
|
|
BackgroundChildImpl::ThreadLocal* threadLocal =
|
|
|
|
BackgroundChildImpl::GetThreadLocalForCurrentThread();
|
|
|
|
MOZ_ASSERT(threadLocal);
|
|
|
|
|
|
|
|
mSerialNumber = threadLocal->mNextRequestSerialNumber++;
|
|
|
|
}
|
|
|
|
#endif
|
2010-11-11 02:26:03 +03:00
|
|
|
}
|
|
|
|
|
2010-09-10 02:15:38 +04:00
|
|
|
// static
|
2010-08-27 00:57:25 +04:00
|
|
|
already_AddRefed<IDBRequest>
|
2013-11-04 16:57:53 +04:00
|
|
|
IDBRequest::Create(IDBDatabase* aDatabase,
|
2013-06-20 22:05:33 +04:00
|
|
|
IDBTransaction* aTransaction)
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aDatabase);
|
|
|
|
aDatabase->AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
nsRefPtr<IDBRequest> request = new IDBRequest(aDatabase);
|
2010-08-27 00:57:25 +04:00
|
|
|
|
2010-11-11 02:26:03 +03:00
|
|
|
request->mTransaction = aTransaction;
|
2013-11-04 16:57:53 +04:00
|
|
|
request->SetScriptOwner(aDatabase->GetScriptOwner());
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
request->CaptureCaller();
|
2012-06-29 20:48:34 +04:00
|
|
|
|
2010-08-27 00:57:25 +04:00
|
|
|
return request.forget();
|
2010-06-23 23:46:08 +04:00
|
|
|
}
|
|
|
|
|
2013-08-23 09:17:10 +04:00
|
|
|
// static
|
|
|
|
already_AddRefed<IDBRequest>
|
|
|
|
IDBRequest::Create(IDBObjectStore* aSourceAsObjectStore,
|
2013-11-04 16:57:53 +04:00
|
|
|
IDBDatabase* aDatabase,
|
2013-08-23 09:17:10 +04:00
|
|
|
IDBTransaction* aTransaction)
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aSourceAsObjectStore);
|
|
|
|
aSourceAsObjectStore->AssertIsOnOwningThread();
|
|
|
|
|
2013-11-04 16:57:53 +04:00
|
|
|
nsRefPtr<IDBRequest> request = Create(aDatabase, aTransaction);
|
2013-08-23 09:17:10 +04:00
|
|
|
|
|
|
|
request->mSourceAsObjectStore = aSourceAsObjectStore;
|
|
|
|
|
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
already_AddRefed<IDBRequest>
|
|
|
|
IDBRequest::Create(IDBIndex* aSourceAsIndex,
|
2013-11-04 16:57:53 +04:00
|
|
|
IDBDatabase* aDatabase,
|
2013-08-23 09:17:10 +04:00
|
|
|
IDBTransaction* aTransaction)
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aSourceAsIndex);
|
|
|
|
aSourceAsIndex->AssertIsOnOwningThread();
|
|
|
|
|
2013-11-04 16:57:53 +04:00
|
|
|
nsRefPtr<IDBRequest> request = Create(aDatabase, aTransaction);
|
2013-08-23 09:17:10 +04:00
|
|
|
|
|
|
|
request->mSourceAsIndex = aSourceAsIndex;
|
|
|
|
|
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
2014-09-18 03:36:01 +04:00
|
|
|
void
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBRequest::GetSource(
|
|
|
|
Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const
|
2014-09-18 03:36:01 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT_IF(mSourceAsObjectStore, !mSourceAsIndex);
|
|
|
|
MOZ_ASSERT_IF(mSourceAsIndex, !mSourceAsObjectStore);
|
|
|
|
MOZ_ASSERT_IF(mSourceAsCursor, mSourceAsObjectStore || mSourceAsIndex);
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// Always check cursor first since cursor requests hold both the cursor and
|
|
|
|
// the objectStore or index the cursor came from.
|
|
|
|
if (mSourceAsCursor) {
|
|
|
|
aSource.SetValue().SetAsIDBCursor() = mSourceAsCursor;
|
|
|
|
} else if (mSourceAsObjectStore) {
|
2013-08-23 09:17:10 +04:00
|
|
|
aSource.SetValue().SetAsIDBObjectStore() = mSourceAsObjectStore;
|
|
|
|
} else if (mSourceAsIndex) {
|
|
|
|
aSource.SetValue().SetAsIDBIndex() = mSourceAsIndex;
|
|
|
|
} else {
|
|
|
|
aSource.SetNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-07 09:21:36 +03:00
|
|
|
void
|
|
|
|
IDBRequest::Reset()
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
mResultVal.setUndefined();
|
2011-01-07 09:21:36 +03:00
|
|
|
mHaveResultOrErrorCode = false;
|
2012-07-30 18:20:58 +04:00
|
|
|
mError = nullptr;
|
2011-01-07 09:21:36 +03:00
|
|
|
}
|
|
|
|
|
2012-04-12 01:55:21 +04:00
|
|
|
void
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBRequest::DispatchNonTransactionError(nsresult aErrorCode)
|
2012-04-12 01:55:21 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(NS_FAILED(aErrorCode));
|
|
|
|
MOZ_ASSERT(NS_ERROR_GET_MODULE(aErrorCode) == NS_ERROR_MODULE_DOM_INDEXEDDB);
|
|
|
|
|
|
|
|
SetError(aErrorCode);
|
|
|
|
|
|
|
|
// Make an error event and fire it at the target.
|
|
|
|
nsCOMPtr<nsIDOMEvent> event =
|
|
|
|
CreateGenericEvent(this,
|
|
|
|
nsDependentString(kErrorEventType),
|
|
|
|
eDoesBubble,
|
|
|
|
eCancelable);
|
|
|
|
if (NS_WARN_IF(!event)) {
|
2012-06-01 21:21:12 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
bool ignored;
|
|
|
|
if (NS_FAILED(DispatchEvent(event, &ignored))) {
|
|
|
|
NS_WARNING("Failed to dispatch event!");
|
2014-09-18 03:36:01 +04:00
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::SetError(nsresult aRv)
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(NS_FAILED(aRv));
|
|
|
|
MOZ_ASSERT(NS_ERROR_GET_MODULE(aRv) == NS_ERROR_MODULE_DOM_INDEXEDDB);
|
|
|
|
MOZ_ASSERT(!mError);
|
2012-04-12 01:55:21 +04:00
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
mHaveResultOrErrorCode = true;
|
2014-09-27 03:21:57 +04:00
|
|
|
mError = new DOMError(GetOwner(), aRv);
|
2012-06-01 21:21:12 +04:00
|
|
|
mErrorCode = aRv;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
mResultVal.setUndefined();
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
nsresult
|
|
|
|
IDBRequest::GetErrorCode() const
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mHaveResultOrErrorCode);
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
return mErrorCode;
|
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
#endif // DEBUG
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2012-06-29 20:48:34 +04:00
|
|
|
void
|
2013-06-20 22:05:33 +04:00
|
|
|
IDBRequest::CaptureCaller()
|
2012-06-29 20:48:34 +04:00
|
|
|
{
|
2013-06-20 22:05:33 +04:00
|
|
|
AutoJSContext cx;
|
2012-06-29 20:48:34 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
const char* filename = nullptr;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t lineNo = 0;
|
2013-06-20 22:05:33 +04:00
|
|
|
if (!nsJSUtils::GetCallingLocation(cx, &filename, &lineNo)) {
|
2012-06-29 20:48:34 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFilename.Assign(NS_ConvertUTF8toUTF16(filename));
|
|
|
|
mLineNo = lineNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-23 09:01:12 +04:00
|
|
|
IDBRequest::FillScriptErrorEvent(ErrorEventInit& aEventInit) const
|
2012-06-29 20:48:34 +04:00
|
|
|
{
|
2014-02-23 09:01:12 +04:00
|
|
|
aEventInit.mLineno = mLineNo;
|
|
|
|
aEventInit.mFilename = mFilename;
|
2012-06-29 20:48:34 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBRequestReadyState
|
2013-08-01 02:28:15 +04:00
|
|
|
IDBRequest::ReadyState() const
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2011-10-20 20:10:56 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return IsPending() ?
|
|
|
|
IDBRequestReadyState::Pending :
|
|
|
|
IDBRequestReadyState::Done;
|
|
|
|
}
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
IDBRequest::SetSource(IDBCursor* aSource)
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aSource);
|
|
|
|
MOZ_ASSERT(mSourceAsObjectStore || mSourceAsIndex);
|
|
|
|
MOZ_ASSERT(!mSourceAsCursor);
|
|
|
|
|
|
|
|
mSourceAsCursor = aSource;
|
2010-06-23 23:46:08 +04:00
|
|
|
}
|
|
|
|
|
2013-08-01 02:28:15 +04:00
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
IDBRequest::WrapObject(JSContext* aCx)
|
2010-12-10 05:14:09 +03: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 IDBRequestBinding::Wrap(aCx, this);
|
2010-12-10 05:14:09 +03:00
|
|
|
}
|
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void
|
|
|
|
IDBRequest::GetResult(JS::MutableHandle<JS::Value> aResult,
|
|
|
|
ErrorResult& aRv) const
|
2011-01-07 09:21:36 +03:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2011-01-07 09:21:36 +03:00
|
|
|
|
|
|
|
if (!mHaveResultOrErrorCode) {
|
2014-09-27 03:21:57 +04:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return;
|
2011-01-07 09:21:36 +03:00
|
|
|
}
|
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
JS::ExposeValueToActiveJS(mResultVal);
|
|
|
|
aResult.set(mResultVal);
|
2011-01-07 09:21:36 +03:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void
|
|
|
|
IDBRequest::SetResultCallback(ResultCallback* aCallback)
|
2011-01-07 09:21:36 +03:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aCallback);
|
|
|
|
MOZ_ASSERT(!mHaveResultOrErrorCode);
|
|
|
|
MOZ_ASSERT(mResultVal.isUndefined());
|
|
|
|
MOZ_ASSERT(!mError);
|
|
|
|
|
|
|
|
// See if our window is still valid.
|
|
|
|
if (NS_WARN_IF(NS_FAILED(CheckInnerWindowCorrectness()))) {
|
|
|
|
IDB_REPORT_INTERNAL_ERR();
|
|
|
|
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoJSAPI autoJS;
|
|
|
|
Maybe<JSAutoCompartment> ac;
|
|
|
|
|
|
|
|
if (GetScriptOwner()) {
|
|
|
|
// If we have a script owner we want the SafeJSContext and then to enter the
|
|
|
|
// script owner's compartment.
|
|
|
|
autoJS.Init();
|
|
|
|
ac.emplace(autoJS.cx(), GetScriptOwner());
|
|
|
|
} else {
|
|
|
|
// Otherwise our owner is a window and we use that to initialize.
|
|
|
|
MOZ_ASSERT(GetOwner());
|
|
|
|
if (!autoJS.InitWithLegacyErrorReporting(GetOwner())) {
|
|
|
|
IDB_WARNING("Failed to initialize AutoJSAPI!");
|
|
|
|
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JSContext* cx = autoJS.cx();
|
|
|
|
|
|
|
|
AssertIsRooted();
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> result(cx);
|
|
|
|
nsresult rv = aCallback->GetResult(cx, &result);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
SetError(rv);
|
|
|
|
mResultVal.setUndefined();
|
|
|
|
} else {
|
|
|
|
mError = nullptr;
|
|
|
|
mResultVal = result;
|
|
|
|
}
|
|
|
|
|
|
|
|
mHaveResultOrErrorCode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMError*
|
|
|
|
IDBRequest::GetError(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
2011-01-07 09:21:36 +03:00
|
|
|
|
2011-01-27 04:53:02 +03:00
|
|
|
if (!mHaveResultOrErrorCode) {
|
2013-05-18 21:52:06 +04:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return nullptr;
|
2011-01-07 09:21:36 +03:00
|
|
|
}
|
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
return mError;
|
|
|
|
}
|
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBRequest)
|
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because
|
2014-04-01 10:13:50 +04:00
|
|
|
// DOMEventTargetHelper does it for us.
|
2013-08-23 09:17:10 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsObjectStore)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsIndex)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsCursor)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransaction)
|
2013-05-28 00:43:09 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
2010-06-23 23:46:08 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
2014-09-27 03:21:57 +04:00
|
|
|
tmp->mResultVal.setUndefined();
|
2013-08-23 09:17:10 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsObjectStore)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsIndex)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsCursor)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTransaction)
|
2013-05-28 00:43:09 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
2010-06-23 23:46:08 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
2014-04-01 10:13:50 +04:00
|
|
|
// DOMEventTargetHelper does it for us.
|
2012-06-11 03:44:50 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mResultVal)
|
2011-01-07 09:21:36 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBRequest)
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-11-11 02:26:03 +03:00
|
|
|
nsresult
|
2014-03-18 08:48:19 +04:00
|
|
|
IDBRequest::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
2010-11-11 02:26:03 +03:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2011-01-07 09:21:36 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aVisitor.mCanHandle = true;
|
2010-11-11 02:26:03 +03:00
|
|
|
aVisitor.mParentTarget = mTransaction;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBOpenDBRequest::IDBOpenDBRequest(IDBFactory* aFactory, nsPIDOMWindow* aOwner)
|
2014-01-07 09:32:20 +04:00
|
|
|
: IDBRequest(aOwner)
|
2014-09-27 03:21:57 +04:00
|
|
|
, mFactory(aFactory)
|
2013-08-01 02:28:15 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aFactory);
|
|
|
|
|
|
|
|
// aOwner may be null.
|
2013-08-01 02:28:15 +04:00
|
|
|
}
|
|
|
|
|
2011-10-20 20:10:56 +04:00
|
|
|
IDBOpenDBRequest::~IDBOpenDBRequest()
|
2011-01-07 09:21:36 +03:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2011-01-07 09:21:36 +03:00
|
|
|
}
|
|
|
|
|
2010-10-19 21:58:52 +04:00
|
|
|
// static
|
2011-10-20 20:10:56 +04:00
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBOpenDBRequest::CreateForWindow(IDBFactory* aFactory,
|
|
|
|
nsPIDOMWindow* aOwner,
|
|
|
|
JS::Handle<JSObject*> aScriptOwner)
|
2010-10-19 21:58:52 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aFactory);
|
|
|
|
aFactory->AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aOwner);
|
|
|
|
MOZ_ASSERT(aScriptOwner);
|
2012-08-30 04:50:28 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, aOwner);
|
|
|
|
request->CaptureCaller();
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2012-11-30 02:54:14 +04:00
|
|
|
request->SetScriptOwner(aScriptOwner);
|
2012-06-29 20:48:34 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
|
|
|
IDBOpenDBRequest::CreateForJS(IDBFactory* aFactory,
|
|
|
|
JS::Handle<JSObject*> aScriptOwner)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFactory);
|
|
|
|
aFactory->AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aScriptOwner);
|
|
|
|
|
|
|
|
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, nullptr);
|
|
|
|
request->CaptureCaller();
|
|
|
|
|
|
|
|
request->SetScriptOwner(aScriptOwner);
|
2013-11-04 16:57:53 +04:00
|
|
|
|
2010-10-19 21:58:52 +04:00
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
2011-01-07 09:21:36 +03:00
|
|
|
void
|
2011-10-20 20:10:56 +04:00
|
|
|
IDBOpenDBRequest::SetTransaction(IDBTransaction* aTransaction)
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(!aTransaction || !mTransaction);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2011-10-20 20:10:56 +04:00
|
|
|
mTransaction = aTransaction;
|
|
|
|
}
|
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBOpenDBRequest)
|
|
|
|
|
2011-10-20 20:10:56 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBOpenDBRequest,
|
2010-10-19 21:58:52 +04:00
|
|
|
IDBRequest)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFactory)
|
2010-10-19 21:58:52 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2011-10-20 20:10:56 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBOpenDBRequest,
|
2010-10-19 21:58:52 +04:00
|
|
|
IDBRequest)
|
2012-08-30 04:50:28 +04:00
|
|
|
// Don't unlink mFactory!
|
2010-10-19 21:58:52 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2011-10-20 20:10:56 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBOpenDBRequest)
|
2010-10-19 21:58:52 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(IDBRequest)
|
|
|
|
|
2011-10-20 20:10:56 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBOpenDBRequest, IDBRequest)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBOpenDBRequest, IDBRequest)
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
nsresult
|
2014-03-18 08:48:20 +04:00
|
|
|
IDBOpenDBRequest::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
2012-06-01 21:21:12 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
// XXX Fix me!
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2012-06-29 20:48:34 +04:00
|
|
|
return IndexedDatabaseManager::FireWindowOnError(GetOwner(), aVisitor);
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
2013-08-01 02:28:15 +04:00
|
|
|
|
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
IDBOpenDBRequest::WrapObject(JSContext* aCx)
|
2013-08-01 02:28:15 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
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 IDBOpenDBRequestBinding::Wrap(aCx, this);
|
2013-08-01 02:28:15 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|