mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Backed out 9 changesets (bug 965920, bug 966765, bug 966766)
CLOSED TREE Backed out changeset 6c2bba06ed58 (bug 965920) Backed out changeset e01c94498760 (bug 966766) Backed out changeset e2585386f84e (bug 966766) Backed out changeset d1db5d2a417f (bug 966766) Backed out changeset f114c97660c6 (bug 966766) Backed out changeset 2dd7d47a1e8c (bug 966765) Backed out changeset 0f26c4b3eab7 (bug 965920) Backed out changeset ca0b05e7155f (bug 965920) Backed out changeset 55dcd2a5362e (bug 965920)
This commit is contained in:
parent
22e6b16ac5
commit
381d88b901
@ -246,8 +246,9 @@ XPCCallContext::~XPCCallContext()
|
||||
NS_IMETHODIMP
|
||||
XPCCallContext::GetCallee(nsISupports * *aCallee)
|
||||
{
|
||||
nsCOMPtr<nsISupports> rval = mWrapper ? mWrapper->GetIdentityObject() : nullptr;
|
||||
rval.forget(aCallee);
|
||||
nsISupports* temp = mWrapper ? mWrapper->GetIdentityObject() : nullptr;
|
||||
NS_IF_ADDREF(temp);
|
||||
*aCallee = temp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -263,8 +264,9 @@ XPCCallContext::GetCalleeMethodIndex(uint16_t *aCalleeMethodIndex)
|
||||
NS_IMETHODIMP
|
||||
XPCCallContext::GetCalleeWrapper(nsIXPConnectWrappedNative * *aCalleeWrapper)
|
||||
{
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> rval = mWrapper;
|
||||
rval.forget(aCalleeWrapper);
|
||||
nsIXPConnectWrappedNative* temp = mWrapper;
|
||||
NS_IF_ADDREF(temp);
|
||||
*aCalleeWrapper = temp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -272,8 +274,9 @@ XPCCallContext::GetCalleeWrapper(nsIXPConnectWrappedNative * *aCalleeWrapper)
|
||||
NS_IMETHODIMP
|
||||
XPCCallContext::GetCalleeInterface(nsIInterfaceInfo * *aCalleeInterface)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfo> rval = mInterface->GetInterfaceInfo();
|
||||
rval.forget(aCalleeInterface);
|
||||
nsIInterfaceInfo* temp = mInterface->GetInterfaceInfo();
|
||||
NS_IF_ADDREF(temp);
|
||||
*aCalleeInterface = temp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -281,8 +284,9 @@ XPCCallContext::GetCalleeInterface(nsIInterfaceInfo * *aCalleeInterface)
|
||||
NS_IMETHODIMP
|
||||
XPCCallContext::GetCalleeClassInfo(nsIClassInfo * *aCalleeClassInfo)
|
||||
{
|
||||
nsCOMPtr<nsIClassInfo> rval = mWrapper ? mWrapper->GetClassInfo() : nullptr;
|
||||
rval.forget(aCalleeClassInfo);
|
||||
nsIClassInfo* temp = mWrapper ? mWrapper->GetClassInfo() : nullptr;
|
||||
NS_IF_ADDREF(temp);
|
||||
*aCalleeClassInfo = temp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2550,8 +2550,7 @@ nsXPCComponents_Utils::GetSandbox(nsIXPCComponents_utils_Sandbox **aSandbox)
|
||||
if (!mSandbox)
|
||||
mSandbox = NewSandboxConstructor();
|
||||
|
||||
nsCOMPtr<nsIXPCComponents_utils_Sandbox> rval = mSandbox;
|
||||
rval.forget(aSandbox);
|
||||
NS_ADDREF(*aSandbox = mSandbox);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -721,11 +721,10 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
MOZ_ASSERT(iid,"can't do interface conversions without iid");
|
||||
|
||||
if (iid->Equals(NS_GET_IID(nsIVariant))) {
|
||||
nsCOMPtr<nsIVariant> variant = XPCVariant::newVariant(cx, s);
|
||||
XPCVariant* variant = XPCVariant::newVariant(cx, s);
|
||||
if (!variant)
|
||||
return false;
|
||||
|
||||
variant.forget(static_cast<nsISupports**>(d));
|
||||
*((nsISupports**)d) = static_cast<nsIVariant*>(variant);
|
||||
return true;
|
||||
} else if (iid->Equals(NS_GET_IID(nsIAtom)) &&
|
||||
JSVAL_IS_STRING(s)) {
|
||||
@ -772,11 +771,11 @@ CreateHolderIfNeeded(HandleObject obj, MutableHandleValue d,
|
||||
nsIXPConnectJSObjectHolder** dest)
|
||||
{
|
||||
if (dest) {
|
||||
nsRefPtr<XPCJSObjectHolder> objHolder = XPCJSObjectHolder::newHolder(obj);
|
||||
XPCJSObjectHolder* objHolder = XPCJSObjectHolder::newHolder(obj);
|
||||
if (!objHolder)
|
||||
return false;
|
||||
|
||||
objHolder.forget(dest);
|
||||
NS_ADDREF(*dest = objHolder);
|
||||
}
|
||||
|
||||
d.setObjectOrNull(obj);
|
||||
@ -1150,8 +1149,9 @@ XPCConvert::JSValToXPCException(MutableHandleValue s,
|
||||
nsCOMPtr<nsIException> iface = do_QueryInterface(supports);
|
||||
if (iface) {
|
||||
// just pass through the exception (with extra ref and all)
|
||||
nsCOMPtr<nsIException> temp = iface;
|
||||
temp.forget(exceptn);
|
||||
nsIException* temp = iface;
|
||||
NS_ADDREF(temp);
|
||||
*exceptn = temp;
|
||||
return NS_OK;
|
||||
} else {
|
||||
// it is a wrapped native, but not an exception!
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "JavaScriptParent.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace JS;
|
||||
@ -224,13 +223,14 @@ NS_IMPL_RELEASE(SharedScriptableHelperForJSIID)
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
#include "xpc_map_end.h" /* This will #undef the above */
|
||||
|
||||
static mozilla::StaticRefPtr<nsIXPCScriptable> gSharedScriptableHelperForJSIID;
|
||||
static nsIXPCScriptable* gSharedScriptableHelperForJSIID;
|
||||
static bool gClassObjectsWereInited = false;
|
||||
|
||||
static void EnsureClassObjectsInitialized()
|
||||
{
|
||||
if (!gClassObjectsWereInited) {
|
||||
gSharedScriptableHelperForJSIID = new SharedScriptableHelperForJSIID();
|
||||
NS_ADDREF(gSharedScriptableHelperForJSIID);
|
||||
|
||||
gClassObjectsWereInited = true;
|
||||
}
|
||||
@ -241,8 +241,8 @@ NS_METHOD GetSharedScriptableHelperForJSIID(uint32_t language,
|
||||
{
|
||||
EnsureClassObjectsInitialized();
|
||||
if (language == nsIProgrammingLanguage::JAVASCRIPT) {
|
||||
nsCOMPtr<nsIXPCScriptable> temp = gSharedScriptableHelperForJSIID.get();
|
||||
temp.forget(helper);
|
||||
NS_IF_ADDREF(gSharedScriptableHelperForJSIID);
|
||||
*helper = gSharedScriptableHelperForJSIID;
|
||||
} else
|
||||
*helper = nullptr;
|
||||
return NS_OK;
|
||||
@ -268,7 +268,7 @@ void xpc_DestroyJSxIDClassObjects()
|
||||
if (gClassObjectsWereInited) {
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSIID));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSCID));
|
||||
gSharedScriptableHelperForJSIID = nullptr;
|
||||
NS_IF_RELEASE(gSharedScriptableHelperForJSIID);
|
||||
|
||||
gClassObjectsWereInited = false;
|
||||
}
|
||||
|
@ -1266,8 +1266,8 @@ NS_IMETHODIMP
|
||||
nsXPCFunctionThisTranslator::TranslateThis(nsISupports *aInitialThis,
|
||||
nsISupports **_retval)
|
||||
{
|
||||
nsCOMPtr<nsISupports> temp = aInitialThis;
|
||||
temp.forget(_retval);
|
||||
NS_IF_ADDREF(aInitialThis);
|
||||
*_retval = aInitialThis;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1687,7 +1687,7 @@ XPCShellDirProvider::GetFile(const char *prop, bool *persistent,
|
||||
NS_FAILED(file->AppendNative(NS_LITERAL_CSTRING("defaults"))) ||
|
||||
NS_FAILED(file->AppendNative(NS_LITERAL_CSTRING("pref"))))
|
||||
return NS_ERROR_FAILURE;
|
||||
file.forget(result);
|
||||
NS_ADDREF(*result = file);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -110,20 +110,23 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XPCVariant)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
// static
|
||||
already_AddRefed<XPCVariant>
|
||||
XPCVariant::newVariant(JSContext* cx, jsval aJSVal)
|
||||
XPCVariant* XPCVariant::newVariant(JSContext* cx, jsval aJSVal)
|
||||
{
|
||||
nsRefPtr<XPCVariant> variant;
|
||||
XPCVariant* variant;
|
||||
|
||||
if (!JSVAL_IS_TRACEABLE(aJSVal))
|
||||
variant = new XPCVariant(cx, aJSVal);
|
||||
else
|
||||
variant = new XPCTraceableVariant(cx, aJSVal);
|
||||
|
||||
if (!variant->InitializeData(cx))
|
||||
if (!variant)
|
||||
return nullptr;
|
||||
NS_ADDREF(variant);
|
||||
|
||||
return variant.forget();
|
||||
if (!variant->InitializeData(cx))
|
||||
NS_RELEASE(variant); // Also sets variant to nullptr.
|
||||
|
||||
return variant;
|
||||
}
|
||||
|
||||
// Helper class to give us a namespace for the table based code below.
|
||||
|
@ -491,7 +491,7 @@ nsXPCWrappedJS::FindInherited(REFNSIID aIID)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** infoResult)
|
||||
nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** info)
|
||||
{
|
||||
MOZ_ASSERT(GetClass(), "wrapper without class");
|
||||
MOZ_ASSERT(GetClass()->GetInterfaceInfo(), "wrapper class without interface");
|
||||
@ -499,10 +499,9 @@ nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** infoResult)
|
||||
// Since failing to get this info will crash some platforms(!), we keep
|
||||
// mClass valid at shutdown time.
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> info = GetClass()->GetInterfaceInfo();
|
||||
if (!info)
|
||||
if (!(*info = GetClass()->GetInterfaceInfo()))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
info.forget(infoResult);
|
||||
NS_ADDREF(*info);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -101,28 +101,30 @@ bool xpc_IsReportableErrorCode(nsresult code)
|
||||
// static
|
||||
nsresult
|
||||
nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID,
|
||||
nsXPCWrappedJSClass** resultClasp)
|
||||
nsXPCWrappedJSClass** resultClazz)
|
||||
{
|
||||
nsXPCWrappedJSClass* clazz = nullptr;
|
||||
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
|
||||
IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
|
||||
nsRefPtr<nsXPCWrappedJSClass> clasp = map->Find(aIID);
|
||||
|
||||
if (!clasp) {
|
||||
IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
|
||||
clazz = map->Find(aIID);
|
||||
NS_IF_ADDREF(clazz);
|
||||
|
||||
if (!clazz) {
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (info) {
|
||||
bool canScript, isBuiltin;
|
||||
if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript &&
|
||||
NS_SUCCEEDED(info->IsBuiltinClass(&isBuiltin)) && !isBuiltin &&
|
||||
nsXPConnect::IsISupportsDescendant(info))
|
||||
{
|
||||
clasp = new nsXPCWrappedJSClass(cx, aIID, info);
|
||||
if (!clasp->mDescriptors)
|
||||
clasp = nullptr;
|
||||
nsXPConnect::IsISupportsDescendant(info)) {
|
||||
clazz = new nsXPCWrappedJSClass(cx, aIID, info);
|
||||
if (clazz && !clazz->mDescriptors)
|
||||
NS_RELEASE(clazz); // sets clazz to nullptr
|
||||
}
|
||||
}
|
||||
}
|
||||
clasp.forget(resultClasp);
|
||||
*resultClazz = clazz;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -134,6 +136,8 @@ nsXPCWrappedJSClass::nsXPCWrappedJSClass(JSContext* cx, REFNSIID aIID,
|
||||
mIID(aIID),
|
||||
mDescriptors(nullptr)
|
||||
{
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
mRuntime->GetWrappedJSClassMap()->Add(this);
|
||||
|
||||
uint16_t methodCount;
|
||||
@ -416,8 +420,7 @@ NS_IMETHODIMP xpcProperty::GetName(nsAString & aName)
|
||||
/* readonly attribute nsIVariant value; */
|
||||
NS_IMETHODIMP xpcProperty::GetValue(nsIVariant * *aValue)
|
||||
{
|
||||
nsCOMPtr<nsIVariant> rval = mValue;
|
||||
rval.forget(aValue);
|
||||
NS_ADDREF(*aValue = mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2404,8 +2404,8 @@ NS_IMETHODIMP XPCWrappedNative::GetNative(nsISupports * *aNative)
|
||||
{
|
||||
// No need to QI here, we already have the correct nsISupports
|
||||
// vtable.
|
||||
nsCOMPtr<nsISupports> rval = mIdentity;
|
||||
rval.forget(aNative);
|
||||
*aNative = mIdentity;
|
||||
NS_ADDREF(*aNative);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2446,8 +2446,9 @@ NS_IMETHODIMP XPCWrappedNative::FindInterfaceWithMember(HandleId name,
|
||||
XPCNativeMember* member;
|
||||
|
||||
if (GetSet()->FindMember(name, &member, &iface) && iface) {
|
||||
nsCOMPtr<nsIInterfaceInfo> temp = iface->GetInterfaceInfo();
|
||||
temp.forget(_retval);
|
||||
nsIInterfaceInfo* temp = iface->GetInterfaceInfo();
|
||||
NS_IF_ADDREF(temp);
|
||||
*_retval = temp;
|
||||
} else
|
||||
*_retval = nullptr;
|
||||
return NS_OK;
|
||||
@ -2459,8 +2460,9 @@ NS_IMETHODIMP XPCWrappedNative::FindInterfaceWithName(HandleId name,
|
||||
{
|
||||
XPCNativeInterface* iface = GetSet()->FindNamedInterface(name);
|
||||
if (iface) {
|
||||
nsCOMPtr<nsIInterfaceInfo> temp = iface->GetInterfaceInfo();
|
||||
temp.forget(_retval);
|
||||
nsIInterfaceInfo* temp = iface->GetInterfaceInfo();
|
||||
NS_IF_ADDREF(temp);
|
||||
*_retval = temp;
|
||||
} else
|
||||
*_retval = nullptr;
|
||||
return NS_OK;
|
||||
|
@ -159,6 +159,25 @@ nsXPConnect::ReleaseXPConnectSingleton()
|
||||
if (xpc) {
|
||||
nsThread::SetMainThreadObserver(nullptr);
|
||||
|
||||
#ifdef DEBUG
|
||||
// force a dump of the JavaScript gc heap if JS is still alive
|
||||
// if requested through XPC_SHUTDOWN_HEAP_DUMP environment variable
|
||||
{
|
||||
const char* dumpName = getenv("XPC_SHUTDOWN_HEAP_DUMP");
|
||||
if (dumpName) {
|
||||
FILE* dumpFile = (*dumpName == '\0' ||
|
||||
strcmp(dumpName, "stdout") == 0)
|
||||
? stdout
|
||||
: fopen(dumpName, "w");
|
||||
if (dumpFile) {
|
||||
JS_DumpHeap(xpc->GetRuntime()->Runtime(), dumpFile, nullptr,
|
||||
JSTRACE_OBJECT, nullptr, static_cast<size_t>(-1), nullptr);
|
||||
if (dumpFile != stdout)
|
||||
fclose(dumpFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
nsrefcnt cnt;
|
||||
NS_RELEASE2(xpc, cnt);
|
||||
}
|
||||
@ -599,8 +618,7 @@ nsXPConnect::JSValToVariant(JSContext *cx,
|
||||
{
|
||||
NS_PRECONDITION(aResult, "bad param");
|
||||
|
||||
nsRefPtr<XPCVariant> variant = XPCVariant::newVariant(cx, aJSVal);
|
||||
variant.forget(aResult);
|
||||
*aResult = XPCVariant::newVariant(cx, aJSVal);
|
||||
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
@ -641,14 +659,14 @@ nsXPConnect::GetWrappedNativeOfJSObject(JSContext * aJSContext,
|
||||
|
||||
RootedObject aJSObj(aJSContext, aJSObjArg);
|
||||
aJSObj = js::CheckedUnwrap(aJSObj, /* stopAtOuter = */ false);
|
||||
if (!aJSObj || !IS_WN_REFLECTOR(aJSObj)) {
|
||||
*_retval = nullptr;
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aJSObj && IS_WN_REFLECTOR(aJSObj)) {
|
||||
NS_IF_ADDREF(*_retval = XPCWrappedNative::Get(aJSObj));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<XPCWrappedNative> temp = XPCWrappedNative::Get(aJSObj);
|
||||
temp.forget(_retval);
|
||||
return NS_OK;
|
||||
// else...
|
||||
*_retval = nullptr;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* nsISupports getNativeOfWrapper(in JSContextPtr aJSContext, in JSObjectPtr aJSObj); */
|
||||
@ -1055,8 +1073,7 @@ nsXPConnect::JSToVariant(JSContext* ctx, HandleValue value, nsIVariant** _retval
|
||||
NS_PRECONDITION(ctx, "bad param");
|
||||
NS_PRECONDITION(_retval, "bad param");
|
||||
|
||||
nsRefPtr<XPCVariant> variant = XPCVariant::newVariant(ctx, value);
|
||||
variant.forget(_retval);
|
||||
*_retval = XPCVariant::newVariant(ctx, value);
|
||||
if (!(*_retval))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -3215,7 +3215,7 @@ public:
|
||||
// if a given nsIVariant is in fact an XPCVariant.
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(XPCVARIANT_IID)
|
||||
|
||||
static already_AddRefed<XPCVariant> newVariant(JSContext* cx, jsval aJSVal);
|
||||
static XPCVariant* newVariant(JSContext* cx, jsval aJSVal);
|
||||
|
||||
/**
|
||||
* This getter clears the gray bit before handing out the jsval if the jsval
|
||||
@ -3558,8 +3558,7 @@ public:
|
||||
}
|
||||
bool GetLocationURI(LocationHint aLocationHint, nsIURI **aURI) {
|
||||
if (locationURI) {
|
||||
nsCOMPtr<nsIURI> rval = locationURI;
|
||||
rval.forget(aURI);
|
||||
NS_IF_ADDREF(*aURI = locationURI);
|
||||
return true;
|
||||
}
|
||||
return TryParseLocationURI(aLocationHint, aURI);
|
||||
|
Loading…
Reference in New Issue
Block a user