mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 911258: Part 1 - Remove nsIExceptionService/Manager usage. r=bholley
This commit is contained in:
parent
cf498d852b
commit
61aeeecde4
@ -2898,8 +2898,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
|||||||
mObjectHolderRoots(nullptr),
|
mObjectHolderRoots(nullptr),
|
||||||
mWatchdogManager(new WatchdogManager(this)),
|
mWatchdogManager(new WatchdogManager(this)),
|
||||||
mJunkScope(nullptr),
|
mJunkScope(nullptr),
|
||||||
mAsyncSnowWhiteFreer(new AsyncFreeSnowWhite()),
|
mAsyncSnowWhiteFreer(new AsyncFreeSnowWhite())
|
||||||
mExceptionManagerNotAvailable(false)
|
|
||||||
{
|
{
|
||||||
#ifdef XPC_CHECK_WRAPPERS_AT_SHUTDOWN
|
#ifdef XPC_CHECK_WRAPPERS_AT_SHUTDOWN
|
||||||
DEBUG_WrappedNativeHashtable =
|
DEBUG_WrappedNativeHashtable =
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "xpcpublic.h"
|
#include "xpcpublic.h"
|
||||||
#include "XPCWrapper.h"
|
#include "XPCWrapper.h"
|
||||||
#include "jsprf.h"
|
#include "jsprf.h"
|
||||||
|
#include "nsDOMException.h"
|
||||||
|
|
||||||
bool XPCThrower::sVerbose = true;
|
bool XPCThrower::sVerbose = true;
|
||||||
|
|
||||||
@ -45,8 +46,7 @@ Throw(JSContext *cx, nsresult rv)
|
|||||||
bool
|
bool
|
||||||
XPCThrower::CheckForPendingException(nsresult result, JSContext *cx)
|
XPCThrower::CheckForPendingException(nsresult result, JSContext *cx)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIException> e;
|
nsCOMPtr<nsIException> e = XPCJSRuntime::Get()->GetPendingException();
|
||||||
XPCJSRuntime::Get()->GetPendingException(getter_AddRefs(e));
|
|
||||||
if (!e)
|
if (!e)
|
||||||
return false;
|
return false;
|
||||||
XPCJSRuntime::Get()->SetPendingException(nullptr);
|
XPCJSRuntime::Get()->SetPendingException(nullptr);
|
||||||
@ -178,32 +178,52 @@ XPCThrower::BuildAndThrowException(JSContext* cx, nsresult rv, const char* sz)
|
|||||||
/* no need to set an expection if the security manager already has */
|
/* no need to set an expection if the security manager already has */
|
||||||
if (rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO && JS_IsExceptionPending(cx))
|
if (rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO && JS_IsExceptionPending(cx))
|
||||||
return;
|
return;
|
||||||
nsCOMPtr<nsIException> finalException;
|
|
||||||
nsCOMPtr<nsIException> defaultException;
|
|
||||||
nsXPCException::NewException(sz, rv, nullptr, nullptr, getter_AddRefs(defaultException));
|
|
||||||
|
|
||||||
nsIExceptionManager * exceptionManager = XPCJSRuntime::Get()->GetExceptionManager();
|
XPCJSRuntime* runtime = XPCJSRuntime::Get();
|
||||||
if (exceptionManager) {
|
nsCOMPtr<nsIException> existingException = runtime->GetPendingException();
|
||||||
// Ask the provider for the exception, if there is no provider
|
if (existingException) {
|
||||||
// we expect it to set e to null
|
nsresult nr;
|
||||||
exceptionManager->GetExceptionFromProvider(rv,
|
if (NS_SUCCEEDED(existingException->GetResult(&nr)) &&
|
||||||
defaultException,
|
rv == nr) {
|
||||||
getter_AddRefs(finalException));
|
// Just reuse the existing exception.
|
||||||
// We should get at least the defaultException back,
|
return;
|
||||||
// but just in case
|
|
||||||
if (finalException == nullptr) {
|
|
||||||
finalException = defaultException;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Should we put the following test and call to JS_ReportOutOfMemory
|
nsCOMPtr<nsIException> finalException;
|
||||||
// inside this test?
|
nsCOMPtr<nsIException> defaultException;
|
||||||
if (finalException)
|
nsXPCException::NewException(sz, rv, nullptr, nullptr,
|
||||||
success = ThrowExceptionObject(cx, finalException);
|
getter_AddRefs(defaultException));
|
||||||
// If we weren't able to build or throw an exception we're
|
|
||||||
|
// Do we use DOM exceptions for this error code?
|
||||||
|
switch (NS_ERROR_GET_MODULE(rv)) {
|
||||||
|
case NS_ERROR_MODULE_DOM:
|
||||||
|
case NS_ERROR_MODULE_SVG:
|
||||||
|
case NS_ERROR_MODULE_DOM_XPATH:
|
||||||
|
case NS_ERROR_MODULE_DOM_INDEXEDDB:
|
||||||
|
case NS_ERROR_MODULE_DOM_FILEHANDLE:
|
||||||
|
if (NS_IsMainThread()) {
|
||||||
|
NS_NewDOMException(rv, defaultException,
|
||||||
|
getter_AddRefs(finalException));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not, use the default.
|
||||||
|
if (finalException == nullptr) {
|
||||||
|
finalException = defaultException;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(finalException);
|
||||||
|
success = ThrowExceptionObject(cx, finalException);
|
||||||
|
// If we weren't able to throw an exception we're
|
||||||
// most likely out of memory
|
// most likely out of memory
|
||||||
if (!success)
|
if (!success) {
|
||||||
JS_ReportOutOfMemory(cx);
|
JS_ReportOutOfMemory(cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
#include "nsIConsoleService.h"
|
#include "nsIConsoleService.h"
|
||||||
#include "nsIScriptError.h"
|
#include "nsIScriptError.h"
|
||||||
#include "nsIExceptionService.h"
|
#include "nsIException.h"
|
||||||
|
|
||||||
#include "nsVariant.h"
|
#include "nsVariant.h"
|
||||||
#include "nsIPropertyBag.h"
|
#include "nsIPropertyBag.h"
|
||||||
@ -739,48 +739,15 @@ public:
|
|||||||
|
|
||||||
~XPCJSRuntime();
|
~XPCJSRuntime();
|
||||||
|
|
||||||
nsresult GetPendingException(nsIException** aException)
|
already_AddRefed<nsIException> GetPendingException()
|
||||||
{
|
{
|
||||||
if (EnsureExceptionManager())
|
|
||||||
return mExceptionManager->GetCurrentException(aException);
|
|
||||||
nsCOMPtr<nsIException> out = mPendingException;
|
nsCOMPtr<nsIException> out = mPendingException;
|
||||||
out.forget(aException);
|
return out.forget();
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult SetPendingException(nsIException* aException)
|
void SetPendingException(nsIException* aException)
|
||||||
{
|
{
|
||||||
if (EnsureExceptionManager())
|
|
||||||
return mExceptionManager->SetCurrentException(aException);
|
|
||||||
|
|
||||||
mPendingException = aException;
|
mPendingException = aException;
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIExceptionManager* GetExceptionManager()
|
|
||||||
{
|
|
||||||
if (EnsureExceptionManager())
|
|
||||||
return mExceptionManager;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EnsureExceptionManager()
|
|
||||||
{
|
|
||||||
if (mExceptionManager)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (mExceptionManagerNotAvailable)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIExceptionService> xs =
|
|
||||||
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
|
|
||||||
if (xs)
|
|
||||||
xs->GetCurrentExceptionManager(getter_AddRefs(mExceptionManager));
|
|
||||||
if (mExceptionManager)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
mExceptionManagerNotAvailable = true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XPCReadableJSStringWrapper *NewStringWrapper(const PRUnichar *str, uint32_t len);
|
XPCReadableJSStringWrapper *NewStringWrapper(const PRUnichar *str, uint32_t len);
|
||||||
@ -865,8 +832,6 @@ private:
|
|||||||
mozilla::TimeStamp mSlowScriptCheckpoint;
|
mozilla::TimeStamp mSlowScriptCheckpoint;
|
||||||
|
|
||||||
nsCOMPtr<nsIException> mPendingException;
|
nsCOMPtr<nsIException> mPendingException;
|
||||||
nsCOMPtr<nsIExceptionManager> mExceptionManager;
|
|
||||||
bool mExceptionManagerNotAvailable;
|
|
||||||
|
|
||||||
#define XPCCCX_STRING_CACHE_SIZE 2
|
#define XPCCCX_STRING_CACHE_SIZE 2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user