зеркало из https://github.com/mozilla/gecko-dev.git
Bug 887524 - Move IDBRequest to WebIDL, r=janv
This commit is contained in:
Родитель
3c66a55593
Коммит
8f98621998
|
@ -53,5 +53,3 @@ exports.indexedDB = Object.freeze({
|
|||
|
||||
exports.IDBKeyRange = IDBKeyRange;
|
||||
exports.DOMException = Ci.nsIDOMDOMException;
|
||||
exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
|
||||
exports.IDBRequest = Ci.nsIIDBRequest;
|
||||
|
|
|
@ -9,7 +9,6 @@ if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) {
|
|||
new function tests() {
|
||||
|
||||
const { indexedDB, IDBKeyRange, DOMException
|
||||
IDBOpenDBRequest, IDBRequest
|
||||
} = require("sdk/indexed-db");
|
||||
|
||||
exports["test indexedDB is frozen"] = function(assert){
|
||||
|
@ -23,7 +22,6 @@ exports["test indexedDB is frozen"] = function(assert){
|
|||
|
||||
exports["test db variables"] = function(assert) {
|
||||
[ indexedDB, IDBKeyRange, DOMException
|
||||
IDBOpenDBRequest, IDBOpenDBRequest, IDBRequest
|
||||
].forEach(function(value) {
|
||||
assert.notEqual(typeof(value), "undefined", "variable is defined");
|
||||
});
|
||||
|
|
|
@ -202,7 +202,6 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
|
||||
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
||||
#include "mozilla/dom/indexedDB/IDBRequest.h"
|
||||
#include "mozilla/dom/indexedDB/IDBKeyRange.h"
|
||||
|
||||
using mozilla::dom::indexedDB::IDBWrapperCache;
|
||||
|
@ -630,12 +629,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
|
||||
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
|
||||
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframeRule, nsDOMGenericSH,
|
||||
|
@ -1522,21 +1517,10 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(IDBKeyRange, nsIIDBKeyRange)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframeRule, nsIDOMMozCSSKeyframeRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframeRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -2794,133 +2778,6 @@ DefineInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// This code is temporary until we remove support for the constants defined
|
||||
// on IDBRequest
|
||||
|
||||
struct IDBConstant
|
||||
{
|
||||
const char* interface;
|
||||
const char* name;
|
||||
const char* value;
|
||||
|
||||
static const char* IDBRequest;
|
||||
};
|
||||
|
||||
const char* IDBConstant::IDBRequest = "IDBRequest";
|
||||
|
||||
static const IDBConstant sIDBConstants[] = {
|
||||
{ IDBConstant::IDBRequest, "LOADING", "pending" },
|
||||
{ IDBConstant::IDBRequest, "DONE", "done" },
|
||||
};
|
||||
|
||||
static JSBool
|
||||
IDBConstantGetter(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
||||
JS::MutableHandle<JS::Value> vp)
|
||||
{
|
||||
JSString *idstr = JSID_TO_STRING(id);
|
||||
unsigned index;
|
||||
for (index = 0; index < mozilla::ArrayLength(sIDBConstants); index++) {
|
||||
JSBool match;
|
||||
if (!JS_StringEqualsAscii(cx, idstr, sIDBConstants[index].name, &match)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (match) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(index < mozilla::ArrayLength(sIDBConstants));
|
||||
|
||||
const IDBConstant& c = sIDBConstants[index];
|
||||
|
||||
// Put a warning on the console
|
||||
nsString warnText =
|
||||
NS_LITERAL_STRING("The constant ") +
|
||||
NS_ConvertASCIItoUTF16(c.interface) +
|
||||
NS_LITERAL_STRING(".") +
|
||||
NS_ConvertASCIItoUTF16(c.name) +
|
||||
NS_LITERAL_STRING(" has been deprecated. Use the string value \"") +
|
||||
NS_ConvertASCIItoUTF16(c.value) +
|
||||
NS_LITERAL_STRING("\" instead.");
|
||||
|
||||
uint64_t windowID = 0;
|
||||
nsIScriptContext* context = GetScriptContextFromJSContext(cx);
|
||||
if (context) {
|
||||
nsCOMPtr<nsPIDOMWindow> window =
|
||||
do_QueryInterface(context->GetGlobalObject());
|
||||
if (window) {
|
||||
window = window->GetCurrentInnerWindow();
|
||||
}
|
||||
NS_WARN_IF_FALSE(window, "Missing a window, got a door?");
|
||||
if (window) {
|
||||
windowID = window->WindowID();
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||
NS_WARN_IF_FALSE(errorObject, "Failed to create error object");
|
||||
if (errorObject) {
|
||||
nsresult rv = errorObject->InitWithWindowID(warnText,
|
||||
EmptyString(), // file name
|
||||
EmptyString(), // source line
|
||||
0, 0, // Line/col number
|
||||
nsIScriptError::warningFlag,
|
||||
"DOM Core", windowID);
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to init error object");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIConsoleService> consoleServ =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
if (consoleServ) {
|
||||
consoleServ->LogMessage(errorObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Redefine property to remove getter
|
||||
NS_ConvertASCIItoUTF16 valStr(c.value);
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
if (!xpc::StringToJsval(cx, valStr, value.address())) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!::JS_DefineProperty(cx, obj, c.name, value,
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// Return value
|
||||
vp.set(value);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
DefineIDBInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *aIID)
|
||||
{
|
||||
const char* interface;
|
||||
if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
|
||||
interface = IDBConstant::IDBRequest;
|
||||
}
|
||||
else {
|
||||
MOZ_CRASH("unexpected IID");
|
||||
}
|
||||
|
||||
for (int8_t i = 0; i < (int8_t)mozilla::ArrayLength(sIDBConstants); ++i) {
|
||||
const IDBConstant& c = sIDBConstants[i];
|
||||
if (c.interface != interface) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!JS_DefineProperty(cx, obj, c.name, JSVAL_VOID,
|
||||
IDBConstantGetter, JS_StrictPropertyStub,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class nsDOMConstructor MOZ_FINAL : public nsIDOMDOMConstructor
|
||||
{
|
||||
protected:
|
||||
|
@ -3320,13 +3177,6 @@ nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JS::Handle<JSObject*>
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Special case a few IDB interfaces which for now are getting transitional
|
||||
// constants.
|
||||
if (class_iid->Equals(NS_GET_IID(nsIIDBRequest))) {
|
||||
rv = DefineIDBInterfaceConstants(cx, obj, class_iid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3457,13 +3307,6 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Special case a few IDB interfaces which for now are getting transitional
|
||||
// constants.
|
||||
if (primary_iid->Equals(NS_GET_IID(nsIIDBRequest))) {
|
||||
rv = DefineIDBInterfaceConstants(cx, class_obj, primary_iid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager>
|
||||
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
||||
|
|
|
@ -119,10 +119,7 @@ DOMCI_CLASS(ContentFrameMessageManager)
|
|||
DOMCI_CLASS(ChromeMessageBroadcaster)
|
||||
DOMCI_CLASS(ChromeMessageSender)
|
||||
|
||||
DOMCI_CLASS(IDBRequest)
|
||||
DOMCI_CLASS(IDBKeyRange)
|
||||
DOMCI_CLASS(IDBOpenDBRequest)
|
||||
|
||||
|
||||
DOMCI_CLASS(MozCSSKeyframeRule)
|
||||
DOMCI_CLASS(MozCSSKeyframesRule)
|
||||
|
|
|
@ -578,6 +578,15 @@ DOMInterfaces = {
|
|||
}
|
||||
},
|
||||
|
||||
'IDBOpenDBRequest': {
|
||||
'nativeType': 'mozilla::dom::indexedDB::IDBOpenDBRequest',
|
||||
'headerFile': 'IDBRequest.h'
|
||||
},
|
||||
|
||||
'IDBRequest': {
|
||||
'nativeType': 'mozilla::dom::indexedDB::IDBRequest',
|
||||
},
|
||||
|
||||
'IDBTransaction': {
|
||||
'nativeType': 'mozilla::dom::indexedDB::IDBTransaction',
|
||||
},
|
||||
|
@ -1691,8 +1700,6 @@ addExternalIface('File')
|
|||
addExternalIface('FileCallback', nativeType='nsIFileCallback',
|
||||
headerFile='nsIDOMHTMLCanvasElement.h')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
|
||||
addExternalIface('IDBRequest', nativeType='nsIIDBRequest')
|
||||
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
|
||||
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
|
||||
addExternalIface('LockedFile')
|
||||
|
|
|
@ -119,7 +119,8 @@ HelperBase::WrapNative(JSContext* aCx,
|
|||
NS_ASSERTION(aResult.address(), "Null pointer!");
|
||||
NS_ASSERTION(mRequest, "Null request!");
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, mRequest->GetParentObject());
|
||||
nsRefPtr<IDBWrapperCache> wrapper = static_cast<IDBWrapperCache*>(mRequest);
|
||||
JS::Rooted<JSObject*> global(aCx, wrapper->GetParentObject());
|
||||
NS_ASSERTION(global, "This should never be null!");
|
||||
|
||||
nsresult rv =
|
||||
|
|
|
@ -412,13 +412,8 @@ IDBCursor::ContinueInternal(const Key& aKey, int32_t aCount, ErrorResult& aRv)
|
|||
mContinueToKey = aKey;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsAutoString readyState;
|
||||
if (NS_FAILED(mRequest->GetReadyState(readyState))) {
|
||||
NS_ERROR("This should never fail!");
|
||||
}
|
||||
NS_ASSERTION(readyState.EqualsLiteral("done"), "Should be DONE!");
|
||||
}
|
||||
NS_ASSERTION(mRequest->ReadyState() == IDBRequestReadyState::Done,
|
||||
"Should be DONE!");
|
||||
#endif
|
||||
|
||||
mRequest->Reset();
|
||||
|
|
|
@ -645,7 +645,7 @@ IDBFactory::Cmp(JSContext* aCx, JS::Handle<JS::Value> aFirst,
|
|||
return Key::CompareKeys(first, second);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
IDBFactory::OpenForPrincipal(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aName,
|
||||
const Optional<uint64_t>& aVersion,
|
||||
|
@ -659,7 +659,7 @@ IDBFactory::OpenForPrincipal(nsIPrincipal* aPrincipal,
|
|||
return Open(aPrincipal, aName, aVersion, false, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
IDBFactory::DeleteForPrincipal(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aName,
|
||||
ErrorResult& aRv)
|
||||
|
@ -672,7 +672,7 @@ IDBFactory::DeleteForPrincipal(nsIPrincipal* aPrincipal,
|
|||
return Open(aPrincipal, aName, Optional<uint64_t>(), true, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
IDBFactory::Open(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aName, const Optional<uint64_t>& aVersion,
|
||||
bool aDelete, ErrorResult& aRv)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
class nsIAtom;
|
||||
class nsIFile;
|
||||
class nsIFileURL;
|
||||
class nsIIDBOpenDBRequest;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -140,14 +139,14 @@ public:
|
|||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
Open(const nsAString& aName, const Optional<uint64_t>& aVersion,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return Open(nullptr, aName, aVersion, false, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
DeleteDatabase(const nsAString& aName, ErrorResult& aRv)
|
||||
{
|
||||
return Open(nullptr, aName, Optional<uint64_t>(), true, aRv);
|
||||
|
@ -157,11 +156,11 @@ public:
|
|||
Cmp(JSContext* aCx, JS::Handle<JS::Value> aFirst,
|
||||
JS::Handle<JS::Value> aSecond, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
OpenForPrincipal(nsIPrincipal* aPrincipal, const nsAString& aName,
|
||||
const Optional<uint64_t>& aVersion, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
DeleteForPrincipal(nsIPrincipal* aPrincipal, const nsAString& aName,
|
||||
ErrorResult& aRv);
|
||||
|
||||
|
@ -169,7 +168,7 @@ private:
|
|||
IDBFactory();
|
||||
~IDBFactory();
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
Open(nsIPrincipal* aPrincipal, const nsAString& aName,
|
||||
const Optional<uint64_t>& aVersion, bool aDelete, ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
#include "mozilla/dom/IDBOpenDBRequestBinding.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
|
@ -46,6 +47,8 @@ IDBRequest::IDBRequest()
|
|||
mHaveResultOrErrorCode(false)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
IDBRequest::~IDBRequest()
|
||||
|
@ -113,7 +116,7 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
|||
return rv;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> global(cx, GetParentObject());
|
||||
JS::Rooted<JSObject*> global(cx, IDBWrapperCache::GetParentObject());
|
||||
NS_ASSERTION(global, "This should never be null!");
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
@ -229,53 +232,35 @@ IDBRequest::FillScriptErrorEvent(nsScriptErrorEvent* aEvent) const
|
|||
aEvent->fileName = mFilename.get();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetReadyState(nsAString& aReadyState)
|
||||
mozilla::dom::IDBRequestReadyState
|
||||
IDBRequest::ReadyState() const
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (IsPending()) {
|
||||
aReadyState.AssignLiteral("pending");
|
||||
}
|
||||
else {
|
||||
aReadyState.AssignLiteral("done");
|
||||
return IDBRequestReadyState::Pending;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return IDBRequestReadyState::Done;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetSource(nsISupports** aSource)
|
||||
JSObject*
|
||||
IDBRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsCOMPtr<nsISupports> source(mSource);
|
||||
source.forget(aSource);
|
||||
return NS_OK;
|
||||
return IDBRequestBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetTransaction(nsISupports** aTransaction)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsRefPtr<IDBWrapperCache> transaction(mTransaction);
|
||||
transaction.forget(aTransaction);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetResult(jsval* aResult)
|
||||
JS::Value
|
||||
IDBRequest::GetResult(JSContext* aCx, mozilla::ErrorResult& aRv) const
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (!mHaveResultOrErrorCode) {
|
||||
// XXX Need a real error code here.
|
||||
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
}
|
||||
|
||||
*aResult = mResultVal;
|
||||
return NS_OK;
|
||||
return mResultVal;
|
||||
}
|
||||
|
||||
mozilla::dom::DOMError*
|
||||
|
@ -291,15 +276,6 @@ IDBRequest::GetError(mozilla::ErrorResult& aRv)
|
|||
return mError;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetError(nsISupports** aError)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aError = GetError(rv);
|
||||
NS_IF_ADDREF(*aError);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -322,18 +298,11 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
|||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIDBRequest)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBRequest)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
|
||||
DOMCI_DATA(IDBRequest, IDBRequest)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(IDBRequest, success)
|
||||
NS_IMPL_EVENT_HANDLER(IDBRequest, error)
|
||||
|
||||
nsresult
|
||||
IDBRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
{
|
||||
|
@ -344,6 +313,13 @@ IDBRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
IDBOpenDBRequest::IDBOpenDBRequest()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
IDBOpenDBRequest::~IDBOpenDBRequest()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
@ -390,20 +366,19 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBOpenDBRequest,
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBOpenDBRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIDBOpenDBRequest)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBOpenDBRequest)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBRequest)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBOpenDBRequest, IDBRequest)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBOpenDBRequest, IDBRequest)
|
||||
|
||||
DOMCI_DATA(IDBOpenDBRequest, IDBOpenDBRequest)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, blocked)
|
||||
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, upgradeneeded)
|
||||
|
||||
nsresult
|
||||
IDBOpenDBRequest::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
{
|
||||
return IndexedDatabaseManager::FireWindowOnError(GetOwner(), aVisitor);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
IDBOpenDBRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return IDBOpenDBRequestBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
|
|
@ -7,14 +7,16 @@
|
|||
#ifndef mozilla_dom_indexeddb_idbrequest_h__
|
||||
#define mozilla_dom_indexeddb_idbrequest_h__
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
||||
|
||||
#include "nsIIDBRequest.h"
|
||||
#include "nsIIDBOpenDBRequest.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/DOMError.h"
|
||||
#include "mozilla/dom/IDBRequestBinding.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
class nsPIDOMWindow;
|
||||
|
@ -26,12 +28,10 @@ class IDBFactory;
|
|||
class IDBTransaction;
|
||||
class IndexedDBRequestParentBase;
|
||||
|
||||
class IDBRequest : public IDBWrapperCache,
|
||||
public nsIIDBRequest
|
||||
class IDBRequest : public IDBWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIIDBREQUEST
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBRequest,
|
||||
IDBWrapperCache)
|
||||
|
||||
|
@ -101,6 +101,40 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
// nsWrapperCache
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
nsPIDOMWindow*
|
||||
GetParentObject() const
|
||||
{
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
JS::Value
|
||||
GetResult(JSContext* aCx, ErrorResult& aRv) const;
|
||||
|
||||
nsISupports*
|
||||
GetSource() const
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
return mSource;
|
||||
}
|
||||
|
||||
IDBTransaction*
|
||||
GetTransaction() const
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
return mTransaction;
|
||||
}
|
||||
|
||||
IDBRequestReadyState
|
||||
ReadyState() const;
|
||||
|
||||
IMPL_EVENT_HANDLER(success);
|
||||
IMPL_EVENT_HANDLER(error);
|
||||
|
||||
protected:
|
||||
IDBRequest();
|
||||
~IDBRequest();
|
||||
|
@ -120,13 +154,10 @@ protected:
|
|||
bool mHaveResultOrErrorCode;
|
||||
};
|
||||
|
||||
class IDBOpenDBRequest : public IDBRequest,
|
||||
public nsIIDBOpenDBRequest
|
||||
class IDBOpenDBRequest : public IDBRequest
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_FORWARD_NSIIDBREQUEST(IDBRequest::)
|
||||
NS_DECL_NSIIDBOPENDBREQUEST
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBOpenDBRequest, IDBRequest)
|
||||
|
||||
static
|
||||
|
@ -151,7 +182,16 @@ public:
|
|||
return mFactory;
|
||||
}
|
||||
|
||||
// nsWrapperCache
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
IMPL_EVENT_HANDLER(blocked);
|
||||
IMPL_EVENT_HANDLER(upgradeneeded);
|
||||
|
||||
protected:
|
||||
IDBOpenDBRequest();
|
||||
~IDBOpenDBRequest();
|
||||
|
||||
// Only touched on the main thread.
|
||||
|
|
|
@ -276,8 +276,7 @@ IndexedDatabaseManager::FireWindowOnError(nsPIDOMWindow* aOwner,
|
|||
nsCOMPtr<EventTarget> eventTarget =
|
||||
aVisitor.mDOMEvent->InternalDOMEvent()->GetTarget();
|
||||
|
||||
nsCOMPtr<nsIIDBRequest> strongRequest = do_QueryInterface(eventTarget);
|
||||
IDBRequest* request = static_cast<IDBRequest*>(strongRequest.get());
|
||||
IDBRequest* request = static_cast<IDBRequest*>(eventTarget.get());
|
||||
NS_ENSURE_TRUE(request, NS_ERROR_UNEXPECTED);
|
||||
|
||||
ErrorResult ret;
|
||||
|
|
|
@ -383,9 +383,9 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
|
|||
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
rv = mOpenRequest->GetResult(result.address());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult error;
|
||||
JS::Rooted<JS::Value> result(cx, mOpenRequest->GetResult(cx, error));
|
||||
ENSURE_SUCCESS(error, error.ErrorCode());
|
||||
|
||||
MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(result));
|
||||
|
||||
|
|
|
@ -9,8 +9,6 @@ TEST_DIRS += ['test']
|
|||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIIDBKeyRange.idl',
|
||||
'nsIIDBOpenDBRequest.idl',
|
||||
'nsIIDBRequest.idl',
|
||||
'nsIIndexedDatabaseManager.idl',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
|
||||
/**
|
||||
* IDBOpenDBRequest interface. See
|
||||
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBOpenDBRequest
|
||||
* for more information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(2d6c5ef4-b84a-45ae-9030-eb6cfc65bb26)]
|
||||
interface nsIIDBOpenDBRequest : nsISupports
|
||||
{
|
||||
[implicit_jscontext] attribute jsval onblocked;
|
||||
[implicit_jscontext] attribute jsval onupgradeneeded;
|
||||
};
|
|
@ -1,34 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
|
||||
/**
|
||||
* IDBRequest interface. See
|
||||
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBRequest for more
|
||||
* information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(4d1e9ee3-4bd0-4c99-9e6a-19cb536ab6d4)]
|
||||
interface nsIIDBRequest : nsISupports
|
||||
{
|
||||
readonly attribute jsval result;
|
||||
|
||||
// This is a DOMError
|
||||
readonly attribute nsISupports error;
|
||||
|
||||
readonly attribute nsISupports source;
|
||||
|
||||
// This is a nsIIDBTransaction
|
||||
readonly attribute nsISupports transaction;
|
||||
|
||||
// "pending" or "done"
|
||||
readonly attribute DOMString readyState;
|
||||
|
||||
[implicit_jscontext] attribute jsval onsuccess;
|
||||
[implicit_jscontext] attribute jsval onerror;
|
||||
};
|
|
@ -6,8 +6,6 @@
|
|||
const { 'classes': Cc, 'interfaces': Ci } = Components;
|
||||
|
||||
const DOMException = Ci.nsIDOMDOMException;
|
||||
const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
|
||||
const IDBRequest = Ci.nsIIDBRequest
|
||||
|
||||
function is(a, b, msg) {
|
||||
dump("is(" + a + ", " + b + ", \"" + msg + "\")");
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface IDBOpenDBRequest;
|
||||
interface Principal;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBObjectStore
|
||||
*/
|
||||
|
||||
interface IDBRequest;
|
||||
|
||||
dictionary IDBObjectStoreParameters {
|
||||
// TODO (DOMString or sequence<DOMString>)? keyPath = null;
|
||||
any keyPath = null;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBOpenDBRequest
|
||||
*/
|
||||
|
||||
interface IDBOpenDBRequest : IDBRequest {
|
||||
[SetterThrows]
|
||||
attribute EventHandler onblocked;
|
||||
|
||||
[SetterThrows]
|
||||
attribute EventHandler onupgradeneeded;
|
||||
};
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBRequest
|
||||
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBRequestReadyState
|
||||
*/
|
||||
|
||||
enum IDBRequestReadyState {
|
||||
"pending",
|
||||
"done"
|
||||
};
|
||||
|
||||
interface IDBRequest : EventTarget {
|
||||
[Throws]
|
||||
readonly attribute any result;
|
||||
|
||||
[Throws]
|
||||
readonly attribute DOMError? error;
|
||||
|
||||
readonly attribute nsISupports? source;
|
||||
readonly attribute IDBTransaction? transaction;
|
||||
readonly attribute IDBRequestReadyState readyState;
|
||||
|
||||
[SetterThrows]
|
||||
attribute EventHandler onsuccess;
|
||||
|
||||
[SetterThrows]
|
||||
attribute EventHandler onerror;
|
||||
};
|
|
@ -170,6 +170,8 @@ webidl_files = \
|
|||
IDBFileHandle.webidl \
|
||||
IDBIndex.webidl \
|
||||
IDBObjectStore.webidl \
|
||||
IDBOpenDBRequest.webidl \
|
||||
IDBRequest.webidl \
|
||||
IDBTransaction.webidl \
|
||||
IDBVersionChangeEvent.webidl \
|
||||
ImageData.webidl \
|
||||
|
|
|
@ -85,8 +85,6 @@ members = [
|
|||
|
||||
# dom/indexedDB
|
||||
'nsIIDBKeyRange.*',
|
||||
'nsIIDBRequest.*',
|
||||
'nsIIDBOpenDBRequest.*',
|
||||
'nsIIndexedDatabaseManager.*',
|
||||
|
||||
# dom/file
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/IDBIndexBinding.h"
|
||||
#include "mozilla/dom/IDBObjectStoreBinding.h"
|
||||
#include "mozilla/dom/IDBOpenDBRequestBinding.h"
|
||||
#include "mozilla/dom/IDBRequestBinding.h"
|
||||
#include "mozilla/dom/IDBTransactionBinding.h"
|
||||
#include "mozilla/dom/IDBVersionChangeEventBinding.h"
|
||||
#include "mozilla/dom/TextDecoderBinding.h"
|
||||
|
@ -548,6 +550,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
|
|||
// Init WebIDL binding constructors wanted on all XPConnect globals.
|
||||
if (!IDBIndexBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBObjectStoreBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBOpenDBRequestBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBRequestBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBTransactionBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!TextDecoderBinding::GetConstructorObject(aJSContext, global) ||
|
||||
|
|
Загрузка…
Ссылка в новой задаче