2010-06-23 23:46:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=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"
|
2014-12-17 09:26:15 +03:00
|
|
|
#include "IndexedDatabaseManager.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-12-17 09:26:15 +03:00
|
|
|
#include "mozilla/Move.h"
|
2017-08-06 20:47:00 +03:00
|
|
|
#include "mozilla/dom/DOMException.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"
|
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"
|
2016-06-23 11:53:14 +03:00
|
|
|
#include "WorkerHolder.h"
|
2014-12-17 09:26:15 +03:00
|
|
|
#include "WorkerPrivate.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
// Include this last to avoid path problems on Windows.
|
|
|
|
#include "ActorsChild.h"
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2016-02-17 00:46:08 +03:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
2014-12-17 09:26:15 +03:00
|
|
|
using namespace mozilla::dom::workers;
|
2014-09-27 03:21:57 +04:00
|
|
|
using namespace mozilla::ipc;
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2015-03-20 07:42:37 +03:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2015-03-20 07:42:37 +03:00
|
|
|
|
2014-01-07 09:32:20 +04:00
|
|
|
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
2014-09-27 03:21:57 +04:00
|
|
|
: IDBWrapperCache(aDatabase)
|
2016-01-12 21:16:59 +03:00
|
|
|
, mLoggingSerialNumber(0)
|
|
|
|
, mLineNo(0)
|
|
|
|
, mColumn(0)
|
|
|
|
, mHaveResultOrErrorCode(false)
|
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
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
IDBRequest::IDBRequest(nsPIDOMWindowInner* aOwner)
|
2014-09-27 03:21:57 +04:00
|
|
|
: IDBWrapperCache(aOwner)
|
2016-01-12 21:16:59 +03:00
|
|
|
, mLoggingSerialNumber(0)
|
|
|
|
, mLineNo(0)
|
|
|
|
, mColumn(0)
|
|
|
|
, mHaveResultOrErrorCode(false)
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::InitMembers()
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
mResultVal.setUndefined();
|
2014-10-16 08:56:52 +04:00
|
|
|
mLoggingSerialNumber = NextSerialNumber();
|
2014-09-27 03:21:57 +04:00
|
|
|
mErrorCode = NS_OK;
|
|
|
|
mLineNo = 0;
|
2015-09-02 04:01:02 +03:00
|
|
|
mColumn = 0;
|
2014-09-27 03:21:57 +04:00
|
|
|
mHaveResultOrErrorCode = false;
|
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>
|
2016-03-23 18:02:57 +03:00
|
|
|
IDBRequest::Create(JSContext* aCx,
|
|
|
|
IDBDatabase* aDatabase,
|
2013-06-20 22:05:33 +04:00
|
|
|
IDBTransaction* aTransaction)
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
2016-03-30 14:03:03 +03:00
|
|
|
MOZ_ASSERT(aCx);
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aDatabase);
|
|
|
|
aDatabase->AssertIsOnOwningThread();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBRequest> request = new IDBRequest(aDatabase);
|
2016-03-23 18:02:57 +03:00
|
|
|
CaptureCaller(aCx, request->mFilename, &request->mLineNo, &request->mColumn);
|
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());
|
|
|
|
|
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>
|
2016-03-23 18:02:57 +03:00
|
|
|
IDBRequest::Create(JSContext* aCx,
|
|
|
|
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();
|
|
|
|
|
2016-03-23 18:02:57 +03:00
|
|
|
RefPtr<IDBRequest> request = Create(aCx, aDatabase, aTransaction);
|
2013-08-23 09:17:10 +04:00
|
|
|
|
|
|
|
request->mSourceAsObjectStore = aSourceAsObjectStore;
|
|
|
|
|
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
already_AddRefed<IDBRequest>
|
2016-03-23 18:02:57 +03:00
|
|
|
IDBRequest::Create(JSContext* aCx,
|
|
|
|
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();
|
|
|
|
|
2016-03-23 18:02:57 +03:00
|
|
|
RefPtr<IDBRequest> request = Create(aCx, aDatabase, aTransaction);
|
2013-08-23 09:17:10 +04:00
|
|
|
|
|
|
|
request->mSourceAsIndex = aSourceAsIndex;
|
|
|
|
|
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
2014-11-14 05:20:38 +03:00
|
|
|
// static
|
2014-10-16 08:56:52 +04:00
|
|
|
uint64_t
|
|
|
|
IDBRequest::NextSerialNumber()
|
|
|
|
{
|
|
|
|
BackgroundChildImpl::ThreadLocal* threadLocal =
|
|
|
|
BackgroundChildImpl::GetThreadLocalForCurrentThread();
|
|
|
|
MOZ_ASSERT(threadLocal);
|
|
|
|
|
|
|
|
ThreadLocal* idbThreadLocal = threadLocal->mIndexedDBThreadLocal;
|
|
|
|
MOZ_ASSERT(idbThreadLocal);
|
|
|
|
|
|
|
|
return idbThreadLocal->NextRequestSN();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBRequest::SetLoggingSerialNumber(uint64_t aLoggingSerialNumber)
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aLoggingSerialNumber > mLoggingSerialNumber);
|
|
|
|
|
|
|
|
mLoggingSerialNumber = aLoggingSerialNumber;
|
|
|
|
}
|
|
|
|
|
2014-11-14 05:20:38 +03:00
|
|
|
void
|
2016-03-23 18:02:57 +03:00
|
|
|
IDBRequest::CaptureCaller(JSContext* aCx, nsAString& aFilename,
|
|
|
|
uint32_t* aLineNo, uint32_t* aColumn)
|
2014-11-14 05:20:38 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFilename.IsEmpty());
|
|
|
|
MOZ_ASSERT(aLineNo);
|
2015-09-02 04:01:02 +03:00
|
|
|
MOZ_ASSERT(aColumn);
|
2014-11-14 05:20:38 +03:00
|
|
|
|
2016-03-23 18:02:57 +03:00
|
|
|
nsJSUtils::GetCallingLocation(aCx, aFilename, aLineNo, aColumn);
|
2014-11-14 05:20:38 +03:00
|
|
|
}
|
|
|
|
|
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-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;
|
2017-08-06 20:47:00 +03:00
|
|
|
mError = DOMException::Create(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
|
|
|
|
2017-08-06 20:47:00 +03:00
|
|
|
DOMException*
|
2014-12-17 09:26:15 +03:00
|
|
|
IDBRequest::GetErrorAfterResult() const
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mHaveResultOrErrorCode);
|
|
|
|
|
|
|
|
return mError;
|
|
|
|
}
|
|
|
|
|
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
|
2015-09-02 04:01:02 +03:00
|
|
|
IDBRequest::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
|
|
|
|
uint32_t* aColumn) const
|
2012-06-29 20:48:34 +04:00
|
|
|
{
|
2014-11-14 05:20:38 +03:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aLineNo);
|
2015-09-02 04:01:02 +03:00
|
|
|
MOZ_ASSERT(aColumn);
|
2012-06-29 20:48:34 +04:00
|
|
|
|
2014-11-14 05:20:38 +03:00
|
|
|
aFilename = mFilename;
|
|
|
|
*aLineNo = mLineNo;
|
2015-09-02 04:01:02 +03:00
|
|
|
*aColumn = mColumn;
|
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*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
IDBRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2010-12-10 05:14:09 +03:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return IDBRequestBinding::Wrap(aCx, this, aGivenProto);
|
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
|
|
|
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()))) {
|
|
|
|
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());
|
2016-03-10 03:02:25 +03:00
|
|
|
if (!autoJS.Init(GetOwner())) {
|
2014-09-27 03:21:57 +04:00
|
|
|
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))) {
|
2015-06-11 23:34:30 +03:00
|
|
|
// This can only fail if the structured clone contains a mutable file
|
|
|
|
// and the child is not in the main thread and main process.
|
|
|
|
// In that case CreateAndWrapMutableFile() returns false which shows up
|
|
|
|
// as NS_ERROR_DOM_DATA_CLONE_ERR here.
|
|
|
|
MOZ_ASSERT(rv == NS_ERROR_DOM_DATA_CLONE_ERR);
|
|
|
|
|
|
|
|
// We are not setting a result or an error object here since we want to
|
|
|
|
// throw an exception when the 'result' property is being touched.
|
|
|
|
return;
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
|
|
|
|
2015-06-11 23:34:30 +03:00
|
|
|
mError = nullptr;
|
|
|
|
mResultVal = result;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
mHaveResultOrErrorCode = true;
|
|
|
|
}
|
|
|
|
|
2017-08-06 20:47:00 +03:00
|
|
|
DOMException*
|
2014-09-27 03:21:57 +04:00
|
|
|
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)
|
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.
|
2016-02-22 21:11:02 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mResultVal)
|
2011-01-07 09:21:36 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBRequest)
|
2015-03-20 07:42:37 +03:00
|
|
|
if (aIID.Equals(kIDBRequestIID)) {
|
|
|
|
foundInterface = this;
|
|
|
|
} else
|
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
|
2016-10-21 05:11:07 +03:00
|
|
|
IDBRequest::GetEventTargetParent(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;
|
2017-12-18 19:07:36 +03:00
|
|
|
aVisitor.SetParentTarget(mTransaction, false);
|
2010-11-11 02:26:03 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
class IDBOpenDBRequest::WorkerHolder final
|
|
|
|
: public mozilla::dom::workers::WorkerHolder
|
2014-12-17 09:26:15 +03:00
|
|
|
{
|
|
|
|
WorkerPrivate* mWorkerPrivate;
|
2015-06-22 22:13:38 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// This is only here so that assertions work in the destructor even if
|
2016-06-23 11:53:14 +03:00
|
|
|
// NoteAddWorkerHolderFailed was called.
|
2015-06-22 22:13:38 +03:00
|
|
|
WorkerPrivate* mWorkerPrivateDEBUG;
|
|
|
|
#endif
|
2014-12-17 09:26:15 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit
|
2016-06-23 11:53:14 +03:00
|
|
|
WorkerHolder(WorkerPrivate* aWorkerPrivate)
|
2017-11-15 09:58:38 +03:00
|
|
|
: mozilla::dom::workers::WorkerHolder("IDBOpenDBRequest::WorkerHolder")
|
|
|
|
, mWorkerPrivate(aWorkerPrivate)
|
2015-06-22 22:13:38 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mWorkerPrivateDEBUG(aWorkerPrivate)
|
|
|
|
#endif
|
2014-12-17 09:26:15 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aWorkerPrivate);
|
|
|
|
aWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
MOZ_COUNT_CTOR(IDBOpenDBRequest::WorkerHolder);
|
2014-12-17 09:26:15 +03:00
|
|
|
}
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
~WorkerHolder()
|
2014-12-17 09:26:15 +03:00
|
|
|
{
|
2015-06-22 22:13:38 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
mWorkerPrivateDEBUG->AssertIsOnWorkerThread();
|
|
|
|
#endif
|
2014-12-17 09:26:15 +03:00
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
MOZ_COUNT_DTOR(IDBOpenDBRequest::WorkerHolder);
|
2015-06-22 22:13:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-23 11:53:14 +03:00
|
|
|
NoteAddWorkerHolderFailed()
|
2015-06-22 22:13:38 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWorkerPrivate);
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
|
|
|
|
mWorkerPrivate = nullptr;
|
2014-12-17 09:26:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool
|
2016-03-28 20:28:14 +03:00
|
|
|
Notify(Status aStatus) override;
|
2014-12-17 09:26:15 +03:00
|
|
|
};
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
IDBOpenDBRequest::IDBOpenDBRequest(IDBFactory* aFactory,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* aOwner,
|
2015-09-09 14:15:05 +03:00
|
|
|
bool aFileHandleDisabled)
|
2014-01-07 09:32:20 +04:00
|
|
|
: IDBRequest(aOwner)
|
2014-09-27 03:21:57 +04:00
|
|
|
, mFactory(aFactory)
|
2015-09-09 14:15:05 +03:00
|
|
|
, mFileHandleDisabled(aFileHandleDisabled)
|
2017-06-16 14:06:36 +03:00
|
|
|
, mIncreasedActiveDatabaseCount(false)
|
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();
|
2017-06-16 14:06:36 +03:00
|
|
|
MOZ_ASSERT(!mIncreasedActiveDatabaseCount);
|
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>
|
2016-03-23 18:02:57 +03:00
|
|
|
IDBOpenDBRequest::CreateForWindow(JSContext* aCx,
|
|
|
|
IDBFactory* aFactory,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* aOwner,
|
2014-09-27 03:21:57 +04:00
|
|
|
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
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
bool fileHandleDisabled = !IndexedDatabaseManager::IsFileHandleEnabled();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBOpenDBRequest> request =
|
2015-09-09 14:15:05 +03:00
|
|
|
new IDBOpenDBRequest(aFactory, aOwner, fileHandleDisabled);
|
2016-03-23 18:02:57 +03:00
|
|
|
CaptureCaller(aCx, request->mFilename, &request->mLineNo, &request->mColumn);
|
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
|
|
|
|
2017-06-16 14:06:36 +03:00
|
|
|
request->IncreaseActiveDatabaseCount();
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
already_AddRefed<IDBOpenDBRequest>
|
2016-03-23 18:02:57 +03:00
|
|
|
IDBOpenDBRequest::CreateForJS(JSContext* aCx,
|
|
|
|
IDBFactory* aFactory,
|
2014-09-27 03:21:57 +04:00
|
|
|
JS::Handle<JSObject*> aScriptOwner)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFactory);
|
|
|
|
aFactory->AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aScriptOwner);
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
bool fileHandleDisabled = !IndexedDatabaseManager::IsFileHandleEnabled();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBOpenDBRequest> request =
|
2015-09-09 14:15:05 +03:00
|
|
|
new IDBOpenDBRequest(aFactory, nullptr, fileHandleDisabled);
|
2016-03-23 18:02:57 +03:00
|
|
|
CaptureCaller(aCx, request->mFilename, &request->mLineNo, &request->mColumn);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
request->SetScriptOwner(aScriptOwner);
|
2013-11-04 16:57:53 +04:00
|
|
|
|
2014-12-17 09:26:15 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
|
|
|
MOZ_ASSERT(workerPrivate);
|
|
|
|
|
|
|
|
workerPrivate->AssertIsOnWorkerThread();
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
nsAutoPtr<WorkerHolder> workerHolder(new WorkerHolder(workerPrivate));
|
2016-08-18 17:11:04 +03:00
|
|
|
if (NS_WARN_IF(!workerHolder->HoldWorker(workerPrivate, Canceling))) {
|
2016-06-23 11:53:14 +03:00
|
|
|
workerHolder->NoteAddWorkerHolderFailed();
|
2014-12-17 09:26:15 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
request->mWorkerHolder = Move(workerHolder);
|
2014-12-17 09:26:15 +03:00
|
|
|
}
|
|
|
|
|
2017-06-16 14:06:36 +03:00
|
|
|
request->IncreaseActiveDatabaseCount();
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-06-16 14:06:36 +03:00
|
|
|
void
|
|
|
|
IDBOpenDBRequest::DispatchNonTransactionError(nsresult aErrorCode)
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(NS_FAILED(aErrorCode));
|
|
|
|
MOZ_ASSERT(NS_ERROR_GET_MODULE(aErrorCode) == NS_ERROR_MODULE_DOM_INDEXEDDB);
|
|
|
|
|
|
|
|
// The actor failed to initiate, decrease the number of active IDBOpenRequests
|
|
|
|
// here since NoteComplete won't be called.
|
|
|
|
MaybeDecreaseActiveDatabaseCount();
|
|
|
|
|
|
|
|
SetError(aErrorCode);
|
|
|
|
|
|
|
|
// Make an error event and fire it at the target.
|
|
|
|
nsCOMPtr<nsIDOMEvent> event =
|
|
|
|
CreateGenericEvent(this,
|
|
|
|
nsDependentString(kErrorEventType),
|
|
|
|
eDoesBubble,
|
|
|
|
eCancelable);
|
|
|
|
MOZ_ASSERT(event);
|
|
|
|
|
|
|
|
bool ignored;
|
|
|
|
if (NS_FAILED(DispatchEvent(event, &ignored))) {
|
|
|
|
NS_WARNING("Failed to dispatch event!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-17 09:26:15 +03:00
|
|
|
void
|
|
|
|
IDBOpenDBRequest::NoteComplete()
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
2016-06-23 11:53:14 +03:00
|
|
|
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
|
2014-12-17 09:26:15 +03:00
|
|
|
|
2017-06-16 14:06:36 +03:00
|
|
|
// Normally, we decrease the number of active IDBOpenRequests here.
|
|
|
|
MaybeDecreaseActiveDatabaseCount();
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
// If we have a WorkerHolder installed on the worker then nulling this out
|
2014-12-17 09:26:15 +03:00
|
|
|
// will uninstall it from the worker.
|
2016-06-23 11:53:14 +03:00
|
|
|
mWorkerHolder = nullptr;
|
2014-12-17 09:26:15 +03:00
|
|
|
}
|
|
|
|
|
2017-06-16 14:06:36 +03:00
|
|
|
void
|
|
|
|
IDBOpenDBRequest::IncreaseActiveDatabaseCount()
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(!mIncreasedActiveDatabaseCount);
|
|
|
|
|
|
|
|
// Increase the number of active IDBOpenRequests.
|
|
|
|
// Note: We count here instead of the actor's ctor because the preemption
|
|
|
|
// could happen at next JS interrupt but its BackgroundFactoryRequestChild
|
|
|
|
// could be created asynchronously from IDBFactory::BackgroundCreateCallback
|
|
|
|
// ::ActorCreated() if its PBackgroundChild is not created yet on this thread.
|
|
|
|
mFactory->UpdateActiveDatabaseCount(1);
|
|
|
|
mIncreasedActiveDatabaseCount = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IDBOpenDBRequest::MaybeDecreaseActiveDatabaseCount()
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
if (mIncreasedActiveDatabaseCount) {
|
|
|
|
// Decrease the number of active IDBOpenRequests.
|
|
|
|
mFactory->UpdateActiveDatabaseCount(-1);
|
|
|
|
mIncreasedActiveDatabaseCount = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(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-12-17 09:26:15 +03:00
|
|
|
nsresult rv =
|
2015-03-20 07:42:37 +03:00
|
|
|
IndexedDatabaseManager::CommonPostHandleEvent(aVisitor, mFactory);
|
2014-12-17 09:26:15 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2014-12-17 09:26:15 +03:00
|
|
|
return NS_OK;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
2013-08-01 02:28:15 +04:00
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
IDBOpenDBRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-08-01 02:28:15 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return IDBOpenDBRequestBinding::Wrap(aCx, this, aGivenProto);
|
2013-08-01 02:28:15 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2014-12-17 09:26:15 +03:00
|
|
|
bool
|
|
|
|
IDBOpenDBRequest::
|
2016-06-23 11:53:14 +03:00
|
|
|
WorkerHolder::Notify(Status aStatus)
|
2014-12-17 09:26:15 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWorkerPrivate);
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
MOZ_ASSERT(aStatus > Running);
|
|
|
|
|
|
|
|
// There's nothing we can really do here at the moment...
|
|
|
|
NS_WARNING("Worker closing but IndexedDB is waiting to open a database!");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|