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
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
#include "IDBKeyRange.h"
|
|
|
|
|
2010-11-10 15:26:00 -08:00
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
#include "nsDOMClassInfo.h"
|
2010-11-10 15:26:00 -08:00
|
|
|
#include "nsJSUtils.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2010-11-10 15:26:00 -08:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
|
|
|
#include "Key.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBIndex.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBObjectStore.h"
|
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
USING_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-11-10 15:26:00 -08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
inline
|
2011-11-03 08:57:30 -07:00
|
|
|
bool
|
2010-11-10 15:26:00 -08:00
|
|
|
ReturnKeyRange(JSContext* aCx,
|
|
|
|
jsval* aVp,
|
|
|
|
IDBKeyRange* aKeyRange)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(aCx, "Null pointer!");
|
|
|
|
NS_ASSERTION(aVp, "Null pointer!");
|
|
|
|
NS_ASSERTION(aKeyRange, "Null pointer!");
|
|
|
|
|
|
|
|
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
|
|
|
NS_ASSERTION(xpc, "This should never be null!");
|
|
|
|
|
2011-09-28 17:57:27 -07:00
|
|
|
JSObject* global = JS_GetGlobalForScopeChain(aCx);
|
2011-11-03 08:57:30 -07:00
|
|
|
if (!global) {
|
|
|
|
NS_WARNING("Couldn't get global object!");
|
|
|
|
return false;
|
|
|
|
}
|
2010-11-10 15:26:00 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
|
|
|
if (NS_FAILED(xpc->WrapNative(aCx, global, aKeyRange,
|
|
|
|
NS_GET_IID(nsIIDBKeyRange),
|
|
|
|
getter_AddRefs(holder)))) {
|
|
|
|
JS_ReportError(aCx, "Couldn't wrap IDBKeyRange object.");
|
2011-11-03 08:57:30 -07:00
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* result;
|
|
|
|
if (NS_FAILED(holder->GetJSObject(&result))) {
|
|
|
|
JS_ReportError(aCx, "Couldn't get JSObject from wrapper.");
|
2011-11-03 08:57:30 -07:00
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(result));
|
2011-11-03 08:57:30 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
nsresult
|
|
|
|
GetKeyFromJSVal(JSContext* aCx,
|
|
|
|
jsval aVal,
|
|
|
|
Key& aKey,
|
|
|
|
bool aAllowUnset = false)
|
|
|
|
{
|
|
|
|
nsresult rv = aKey.SetFromJSVal(aCx, aVal);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ASSERTION(NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM_INDEXEDDB,
|
|
|
|
"Bad error code!");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aKey.IsUnset() && !aAllowUnset) {
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
void
|
|
|
|
ThrowException(JSContext* aCx,
|
|
|
|
nsresult aErrorCode)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_FAILED(aErrorCode), "Not an error code!");
|
|
|
|
if (!JS_IsExceptionPending(aCx)) {
|
|
|
|
nsDOMClassInfo::ThrowJSException(aCx, aErrorCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool
|
|
|
|
GetKeyFromJSValOrThrow(JSContext* aCx,
|
|
|
|
jsval aVal,
|
|
|
|
Key& aKey)
|
|
|
|
{
|
|
|
|
nsresult rv = GetKeyFromJSVal(aCx, aVal, aKey);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
ThrowException(aCx, rv);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
MakeOnlyKeyRange(JSContext* aCx,
|
2012-02-28 15:11:11 -08:00
|
|
|
unsigned aArgc,
|
2010-11-10 15:26:00 -08:00
|
|
|
jsval* aVp)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
jsval val;
|
|
|
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v", &val)) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
nsRefPtr<IDBKeyRange> keyRange = new IDBKeyRange(false, false, true);
|
2010-11-10 15:26:00 -08:00
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
if (!GetKeyFromJSValOrThrow(aCx, val, keyRange->Lower())) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
return ReturnKeyRange(aCx, aVp, keyRange);
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
MakeLowerBoundKeyRange(JSContext* aCx,
|
2012-02-28 15:11:11 -08:00
|
|
|
unsigned aArgc,
|
2010-11-10 15:26:00 -08:00
|
|
|
jsval* aVp)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
jsval val;
|
|
|
|
JSBool open = false;
|
|
|
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v/b", &val, &open)) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
nsRefPtr<IDBKeyRange> keyRange = new IDBKeyRange(open, true, false);
|
2010-11-10 15:26:00 -08:00
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
if (!GetKeyFromJSValOrThrow(aCx, val, keyRange->Lower())) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
return ReturnKeyRange(aCx, aVp, keyRange);
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
MakeUpperBoundKeyRange(JSContext* aCx,
|
2012-02-28 15:11:11 -08:00
|
|
|
unsigned aArgc,
|
2010-11-10 15:26:00 -08:00
|
|
|
jsval* aVp)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
jsval val;
|
|
|
|
JSBool open = false;
|
|
|
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v/b", &val, &open)) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
nsRefPtr<IDBKeyRange> keyRange = new IDBKeyRange(true, open, false);
|
2010-11-10 15:26:00 -08:00
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
if (!GetKeyFromJSValOrThrow(aCx, val, keyRange->Upper())) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
return ReturnKeyRange(aCx, aVp, keyRange);
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
MakeBoundKeyRange(JSContext* aCx,
|
2012-02-28 15:11:11 -08:00
|
|
|
unsigned aArgc,
|
2010-11-10 15:26:00 -08:00
|
|
|
jsval* aVp)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
jsval lowerVal, upperVal;
|
|
|
|
JSBool lowerOpen = false, upperOpen = false;
|
|
|
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "vv/bb", &lowerVal,
|
|
|
|
&upperVal, &lowerOpen, &upperOpen)) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
nsRefPtr<IDBKeyRange> keyRange = new IDBKeyRange(lowerOpen, upperOpen, false);
|
2010-11-10 15:26:00 -08:00
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
if (!GetKeyFromJSValOrThrow(aCx, lowerVal, keyRange->Lower()) ||
|
|
|
|
!GetKeyFromJSValOrThrow(aCx, upperVal, keyRange->Upper())) {
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
if (keyRange->Lower() > keyRange->Upper() ||
|
|
|
|
(keyRange->Lower() == keyRange->Upper() && (lowerOpen || upperOpen))) {
|
|
|
|
ThrowException(aCx, NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
|
|
|
|
return false;
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
return ReturnKeyRange(aCx, aVp, keyRange);
|
2010-11-10 15:26:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define KEYRANGE_FUNCTION_FLAGS (JSPROP_ENUMERATE | JSPROP_PERMANENT)
|
|
|
|
|
|
|
|
const JSFunctionSpec gKeyRangeConstructors[] = {
|
|
|
|
JS_FN("only", MakeOnlyKeyRange, 1, KEYRANGE_FUNCTION_FLAGS),
|
|
|
|
JS_FN("lowerBound", MakeLowerBoundKeyRange, 1, KEYRANGE_FUNCTION_FLAGS),
|
|
|
|
JS_FN("upperBound", MakeUpperBoundKeyRange, 1, KEYRANGE_FUNCTION_FLAGS),
|
|
|
|
JS_FN("bound", MakeBoundKeyRange, 2, KEYRANGE_FUNCTION_FLAGS),
|
|
|
|
JS_FS_END
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef KEYRANGE_FUNCTION_FLAGS
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
// static
|
|
|
|
JSBool
|
|
|
|
IDBKeyRange::DefineConstructors(JSContext* aCx,
|
|
|
|
JSObject* aObject)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(aCx, "Null pointer!");
|
|
|
|
NS_ASSERTION(aObject, "Null pointer!");
|
|
|
|
|
|
|
|
// Add the constructor methods for key ranges.
|
|
|
|
return JS_DefineFunctions(aCx, aObject,
|
|
|
|
const_cast<JSFunctionSpec*>(gKeyRangeConstructors));
|
|
|
|
}
|
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
// static
|
2011-11-03 08:57:30 -07:00
|
|
|
nsresult
|
|
|
|
IDBKeyRange::FromJSVal(JSContext* aCx,
|
|
|
|
const jsval& aVal,
|
|
|
|
IDBKeyRange** aKeyRange)
|
2010-06-23 12:46:08 -07:00
|
|
|
{
|
2011-11-03 08:57:30 -07:00
|
|
|
nsresult rv;
|
|
|
|
nsRefPtr<IDBKeyRange> keyRange;
|
|
|
|
|
|
|
|
if (JSVAL_IS_VOID(aVal) || JSVAL_IS_NULL(aVal)) {
|
|
|
|
// undefined and null returns no IDBKeyRange.
|
|
|
|
}
|
2011-12-20 02:58:44 -08:00
|
|
|
else if (JSVAL_IS_PRIMITIVE(aVal) ||
|
|
|
|
JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(aVal)) ||
|
|
|
|
JS_ObjectIsDate(aCx, JSVAL_TO_OBJECT(aVal))) {
|
2011-11-03 08:57:30 -07:00
|
|
|
// A valid key returns an 'only' IDBKeyRange.
|
|
|
|
keyRange = new IDBKeyRange(false, false, true);
|
|
|
|
|
|
|
|
rv = GetKeyFromJSVal(aCx, aVal, keyRange->Lower());
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// An object is not permitted unless it's another IDBKeyRange.
|
|
|
|
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
|
|
|
NS_ASSERTION(xpc, "This should never be null!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
|
|
|
rv = xpc->GetWrappedNativeOfJSObject(aCx, JSVAL_TO_OBJECT(aVal),
|
|
|
|
getter_AddRefs(wrapper));
|
2012-06-01 10:21:12 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
|
|
|
}
|
2011-11-03 08:57:30 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIIDBKeyRange> iface;
|
|
|
|
if (!wrapper || !(iface = do_QueryInterface(wrapper->Native()))) {
|
|
|
|
// Some random JS object?
|
|
|
|
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
|
|
|
}
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
keyRange = static_cast<IDBKeyRange*>(iface.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
keyRange.forget(aKeyRange);
|
|
|
|
return NS_OK;
|
2010-06-23 12:46:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
// static
|
|
|
|
template <class T>
|
|
|
|
already_AddRefed<IDBKeyRange>
|
|
|
|
IDBKeyRange::FromSerializedKeyRange(const T& aKeyRange)
|
|
|
|
{
|
|
|
|
nsRefPtr<IDBKeyRange> keyRange =
|
|
|
|
new IDBKeyRange(aKeyRange.lowerOpen(), aKeyRange.upperOpen(),
|
|
|
|
aKeyRange.isOnly());
|
|
|
|
keyRange->Lower() = aKeyRange.lower();
|
|
|
|
if (!keyRange->IsOnly()) {
|
|
|
|
keyRange->Upper() = aKeyRange.upper();
|
|
|
|
}
|
|
|
|
return keyRange.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void
|
|
|
|
IDBKeyRange::ToSerializedKeyRange(T& aKeyRange)
|
|
|
|
{
|
|
|
|
aKeyRange.lowerOpen() = IsLowerOpen();
|
|
|
|
aKeyRange.upperOpen() = IsUpperOpen();
|
|
|
|
aKeyRange.isOnly() = IsOnly();
|
|
|
|
|
|
|
|
aKeyRange.lower() = Lower();
|
|
|
|
if (!IsOnly()) {
|
|
|
|
aKeyRange.upper() = Upper();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBKeyRange)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBKeyRange)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBKeyRange)
|
2012-06-10 16:37:47 -07:00
|
|
|
if (JSVAL_IS_GCTHING(tmp->mCachedLowerVal)) {
|
|
|
|
void *gcThing = JSVAL_TO_GCTHING(tmp->mCachedLowerVal);
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(gcThing, "mCachedLowerVal")
|
|
|
|
}
|
|
|
|
if (JSVAL_IS_GCTHING(tmp->mCachedUpperVal)) {
|
|
|
|
void *gcThing = JSVAL_TO_GCTHING(tmp->mCachedUpperVal);
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(gcThing, "mCachedUpperVal")
|
|
|
|
}
|
2011-11-03 08:57:30 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBKeyRange)
|
|
|
|
if (tmp->mRooted) {
|
|
|
|
NS_DROP_JS_OBJECTS(tmp, IDBKeyRange);
|
|
|
|
tmp->mCachedLowerVal = JSVAL_VOID;
|
|
|
|
tmp->mCachedUpperVal = JSVAL_VOID;
|
|
|
|
tmp->mHaveCachedLowerVal = false;
|
|
|
|
tmp->mHaveCachedUpperVal = false;
|
|
|
|
tmp->mRooted = false;
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBKeyRange)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2010-06-23 12:46:08 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIIDBKeyRange)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBKeyRange)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBKeyRange)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBKeyRange)
|
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
DOMCI_DATA(IDBKeyRange, IDBKeyRange)
|
|
|
|
|
2012-03-28 07:40:52 -07:00
|
|
|
IDBKeyRange::~IDBKeyRange()
|
|
|
|
{
|
|
|
|
if (mRooted) {
|
|
|
|
NS_DROP_JS_OBJECTS(this, IDBKeyRange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
NS_IMETHODIMP
|
2011-11-03 08:57:30 -07:00
|
|
|
IDBKeyRange::GetLower(JSContext* aCx,
|
|
|
|
jsval* aLower)
|
2010-06-23 12:46:08 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
if (!mHaveCachedLowerVal) {
|
|
|
|
if (!mRooted) {
|
|
|
|
NS_HOLD_JS_OBJECTS(this, IDBKeyRange);
|
|
|
|
mRooted = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = Lower().ToJSVal(aCx, &mCachedLowerVal);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mHaveCachedLowerVal = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aLower = mCachedLowerVal;
|
2010-06-23 12:46:08 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-11-03 08:57:30 -07:00
|
|
|
IDBKeyRange::GetUpper(JSContext* aCx,
|
|
|
|
jsval* aUpper)
|
2010-06-23 12:46:08 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
if (!mHaveCachedUpperVal) {
|
|
|
|
if (!mRooted) {
|
|
|
|
NS_HOLD_JS_OBJECTS(this, IDBKeyRange);
|
|
|
|
mRooted = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = Upper().ToJSVal(aCx, &mCachedUpperVal);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mHaveCachedUpperVal = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aUpper = mCachedUpperVal;
|
2010-06-23 12:46:08 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
IDBKeyRange::GetLowerOpen(bool* aLowerOpen)
|
2010-11-10 15:26:00 -08:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
*aLowerOpen = mLowerOpen;
|
2010-11-10 15:26:00 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
IDBKeyRange::GetUpperOpen(bool* aUpperOpen)
|
2010-06-23 12:46:08 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2011-11-03 08:57:30 -07:00
|
|
|
*aUpperOpen = mUpperOpen;
|
2010-06-23 12:46:08 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
// Explicitly instantiate for all our key range types... Grumble.
|
|
|
|
template already_AddRefed<IDBKeyRange>
|
2012-06-10 16:37:47 -07:00
|
|
|
IDBKeyRange::FromSerializedKeyRange<ipc::FIXME_Bug_521898_objectstore::KeyRange>
|
|
|
|
(const ipc::FIXME_Bug_521898_objectstore::KeyRange& aKeyRange);
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
template already_AddRefed<IDBKeyRange>
|
2012-06-10 16:37:47 -07:00
|
|
|
IDBKeyRange::FromSerializedKeyRange<ipc::FIXME_Bug_521898_index::KeyRange>
|
|
|
|
(const ipc::FIXME_Bug_521898_index::KeyRange& aKeyRange);
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
template void
|
2012-06-10 16:37:47 -07:00
|
|
|
IDBKeyRange::ToSerializedKeyRange<ipc::FIXME_Bug_521898_objectstore::KeyRange>
|
|
|
|
(ipc::FIXME_Bug_521898_objectstore::KeyRange& aKeyRange);
|
2012-06-01 10:21:12 -07:00
|
|
|
|
|
|
|
template void
|
2012-06-10 16:37:47 -07:00
|
|
|
IDBKeyRange::ToSerializedKeyRange<ipc::FIXME_Bug_521898_index::KeyRange>
|
|
|
|
(ipc::FIXME_Bug_521898_index::KeyRange& aKeyRange);
|