зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1282150 part 3. Add a way to get the JSRuntime for the thread, and use it in various places for rooting. r=bholley
This commit is contained in:
Родитель
e990418707
Коммит
d208b0de7a
|
@ -23,6 +23,7 @@ using mozilla::dom::DOMRequestService;
|
|||
using mozilla::dom::DOMCursor;
|
||||
using mozilla::dom::Promise;
|
||||
using mozilla::dom::AutoJSAPI;
|
||||
using mozilla::dom::GetJSRuntime;
|
||||
|
||||
DOMRequest::DOMRequest(nsPIDOMWindowInner* aWindow)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
|
@ -301,7 +302,7 @@ class FireSuccessAsyncTask : public mozilla::Runnable
|
|||
FireSuccessAsyncTask(DOMRequest* aRequest,
|
||||
const JS::Value& aResult) :
|
||||
mReq(aRequest),
|
||||
mResult(nsContentUtils::RootingCxForThread(), aResult)
|
||||
mResult(GetJSRuntime(), aResult)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -293,6 +293,12 @@ GetJSContext()
|
|||
}
|
||||
} // namespace danger
|
||||
|
||||
JSRuntime*
|
||||
GetJSRuntime()
|
||||
{
|
||||
return CycleCollectedJSRuntime::Get()->Runtime();
|
||||
}
|
||||
|
||||
AutoJSAPI::AutoJSAPI()
|
||||
: ScriptSettingsStackEntry(nullptr, eJSAPI)
|
||||
, mCx(nullptr)
|
||||
|
|
|
@ -136,6 +136,8 @@ JSContext* GetJSContext();
|
|||
|
||||
} // namespace danger
|
||||
|
||||
JSRuntime* GetJSRuntime();
|
||||
|
||||
class ScriptSettingsStack;
|
||||
class ScriptSettingsStackEntry {
|
||||
friend class ScriptSettingsStack;
|
||||
|
|
|
@ -247,8 +247,8 @@ FindExceptionStackForConsoleReport(nsPIDOMWindowInner* win,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
JSContext* cx = nsContentUtils::RootingCxForThread();
|
||||
JS::RootedObject exceptionObject(cx, &exceptionValue.toObject());
|
||||
JSRuntime* rt = GetJSRuntime();
|
||||
JS::RootedObject exceptionObject(rt, &exceptionValue.toObject());
|
||||
JSObject* stackObject = ExceptionStackOrNull(exceptionObject);
|
||||
if (stackObject) {
|
||||
return stackObject;
|
||||
|
@ -269,7 +269,7 @@ FindExceptionStackForConsoleReport(nsPIDOMWindowInner* win,
|
|||
if (!stack) {
|
||||
return nullptr;
|
||||
}
|
||||
JS::RootedValue value(cx);
|
||||
JS::RootedValue value(rt);
|
||||
stack->GetNativeSavedFrame(&value);
|
||||
if (value.isObject()) {
|
||||
return &value.toObject();
|
||||
|
|
|
@ -2350,7 +2350,7 @@ ConstructJSImplementation(const char* aContractId,
|
|||
do_QueryInterface(implISupports);
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||
if (gpi) {
|
||||
JS::Rooted<JS::Value> initReturn(nsContentUtils::RootingCxForThread());
|
||||
JS::Rooted<JS::Value> initReturn(GetJSRuntime());
|
||||
rv = gpi->Init(window, &initReturn);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
|
|
|
@ -751,7 +751,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
|||
mService = service;
|
||||
|
||||
// Signal
|
||||
JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
|
||||
JS::Rooted<JS::Value> value(dom::GetJSRuntime());
|
||||
voiceInfo->GetRelSignalStrength(&value);
|
||||
if (value.isNumber()) {
|
||||
mSignal = (int)ceil(value.toNumber() / 20.0);
|
||||
|
|
|
@ -641,7 +641,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
|||
}
|
||||
UpdateCIND(CINDType::SERVICE, service);
|
||||
|
||||
JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
|
||||
JS::Rooted<JS::Value> value(dom::GetJSRuntime());
|
||||
voiceInfo->GetRelSignalStrength(&value);
|
||||
if (value.isNumber()) {
|
||||
uint8_t signal = ceil(value.toNumber() / 20.0);
|
||||
|
|
|
@ -3975,8 +3975,7 @@ DeviceStorageRequestManager::Resolve(uint32_t aId, uint64_t aValue,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::RootedValue value(nsContentUtils::RootingCxForThread(),
|
||||
JS_NumberValue((double)aValue));
|
||||
JS::RootedValue value(GetJSRuntime(), JS_NumberValue((double)aValue));
|
||||
return ResolveInternal(i, value);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent)
|
|||
columnNumber.Construct();
|
||||
columnNumber.Value() = scriptEvent->Colno();
|
||||
|
||||
error.Construct(nsContentUtils::RootingCxForThread());
|
||||
error.Construct(GetJSRuntime());
|
||||
scriptEvent->GetError(&error.Value());
|
||||
} else {
|
||||
msgOrEvent.SetAsEvent() = aEvent->InternalDOMEvent();
|
||||
|
|
|
@ -507,7 +507,7 @@ public:
|
|||
mReadyState(0), mUploadEvent(aUploadEvent), mProgressEvent(true),
|
||||
mLengthComputable(aLengthComputable), mUseCachedArrayBufferResponse(false),
|
||||
mResponseTextResult(NS_OK), mStatusResult(NS_OK), mResponseResult(NS_OK),
|
||||
mScopeObj(nsContentUtils::RootingCxForThread(), aScopeObj)
|
||||
mScopeObj(GetJSRuntime(), aScopeObj)
|
||||
{ }
|
||||
|
||||
EventRunnable(Proxy* aProxy, bool aUploadEvent, const nsString& aType,
|
||||
|
@ -520,7 +520,7 @@ public:
|
|||
mUploadEvent(aUploadEvent), mProgressEvent(false), mLengthComputable(0),
|
||||
mUseCachedArrayBufferResponse(false), mResponseTextResult(NS_OK),
|
||||
mStatusResult(NS_OK), mResponseResult(NS_OK),
|
||||
mScopeObj(nsContentUtils::RootingCxForThread(), aScopeObj)
|
||||
mScopeObj(GetJSRuntime(), aScopeObj)
|
||||
{ }
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "txXPathObjectAdaptor.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "nsIClassInfo.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "js/RootingAPI.h"
|
||||
|
@ -384,7 +384,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
|||
uint8_t paramCount = methodInfo->GetParamCount();
|
||||
uint8_t inArgs = paramCount - 1;
|
||||
|
||||
JS::Rooted<txParamArrayHolder> invokeParams(nsContentUtils::RootingCxForThread());
|
||||
JS::Rooted<txParamArrayHolder> invokeParams(mozilla::dom::GetJSRuntime());
|
||||
if (!invokeParams.get().Init(paramCount)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче