Bug 1257725 part 4. Get rid of ThreadsafeAutoJSContext usage in IndexedDB code, except for IDBRequest::CaptureCaller. r=khuey

This commit is contained in:
Boris Zbarsky 2016-03-23 11:02:57 -04:00
Родитель 7d81d282f7
Коммит 5ebb7a4795
2 изменённых файлов: 5 добавлений и 22 удалений

Просмотреть файл

@ -607,32 +607,16 @@ IDBDatabase::Transaction(const StringOrStringSequence& aStoreNames,
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
aRv.MightThrowJSException();
if ((aMode == IDBTransactionMode::Readwriteflush || if ((aMode == IDBTransactionMode::Readwriteflush ||
aMode == IDBTransactionMode::Cleanup) && aMode == IDBTransactionMode::Cleanup) &&
!IndexedDatabaseManager::ExperimentalFeaturesEnabled()) { !IndexedDatabaseManager::ExperimentalFeaturesEnabled()) {
// Pretend that this mode doesn't exist. We don't have a way to annotate // Pretend that this mode doesn't exist. We don't have a way to annotate
// certain enum values as depending on preferences so we just duplicate the // certain enum values as depending on preferences so we just duplicate the
// normal exception generation here. // normal exception generation here.
ThreadsafeAutoJSContext cx; aRv.ThrowTypeError<MSG_INVALID_ENUM_VALUE>(
NS_LITERAL_STRING("Argument 2 of IDBDatabase.transaction"),
// Disable any automatic error reporting that might be set up so that we NS_LITERAL_STRING("readwriteflush"),
// can grab the exception object. NS_LITERAL_STRING("IDBTransactionMode"));
AutoForceSetExceptionOnContext forceExn(cx);
MOZ_ALWAYS_FALSE(
ThrowErrorMessage(cx,
MSG_INVALID_ENUM_VALUE,
"Argument 2 of IDBDatabase.transaction",
"readwriteflush",
"IDBTransactionMode"));
MOZ_ASSERT(JS_IsExceptionPending(cx));
JS::Rooted<JS::Value> exception(cx);
MOZ_ALWAYS_TRUE(JS_GetPendingException(cx, &exception));
aRv.ThrowJSException(cx, exception);
return nullptr; return nullptr;
} }

Просмотреть файл

@ -484,8 +484,7 @@ IndexedDatabaseManager::CommonPostHandleEvent(EventChainPostVisitor& aVisitor,
error->GetName(errorName); error->GetName(errorName);
} }
ThreadsafeAutoJSContext cx; RootedDictionary<ErrorEventInit> init(nsContentUtils::RootingCxForThread());
RootedDictionary<ErrorEventInit> init(cx);
request->GetCallerLocation(init.mFilename, &init.mLineno, &init.mColno); request->GetCallerLocation(init.mFilename, &init.mLineno, &init.mColno);
init.mMessage = errorName; init.mMessage = errorName;