Bug 708326 - Use IDL for Components.utils.forceGC; r=bholley
authorMs2ger <ms2ger@gmail.com>
Sun, 18 Dec 2011 11:11:23 +0100
changeset 84521 72a269d3e823cf386e7afcd47f06169e4567740f
parent 84520 b456317ba3e46675e53e44a19f7a59dea73110a1
child 84522 515da54158b2018193c797b93859a2f74b7c35ad
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs708326
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 708326 - Use IDL for Components.utils.forceGC; r=bholley
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -147,17 +147,17 @@ interface nsIXPCComponents_utils_Sandbox
 interface ScheduledGCCallback : nsISupports
 {
     void callback();
 };
 
 /**
 * interface of Components.utils
 */
-[scriptable, uuid(90894460-26a2-44c2-a3fc-c96a5286614e)]
+[scriptable, uuid(9e0b065d-a755-482d-ab1f-cc0f26a6fdcd)]
 interface nsIXPCComponents_Utils : nsISupports
 {
 
     /* reportError is designed to be called from JavaScript only.
      *
      * It will report a JS Error object to the JS console, and return. It
      * is meant for use in exception handler blocks which want to "eat"
      * an exception, but still want to report it to the console.
@@ -255,16 +255,17 @@ interface nsIXPCComponents_Utils : nsISu
      */
     xpcIJSWeakReference getWeakReference(/* in JSObject obj */);
 
     /*
      * To be called from JS only.
      *
      * Force an immediate garbage collection cycle.
      */
+    [implicit_jscontext]
     void forceGC();
 
     /*
      * Schedule a garbage collection cycle for a point in the future when no JS
      * is running. Call the provided function once this has occurred.
      */
     [implicit_jscontext]
     void schedulePreciseGC(in ScheduledGCCallback callback);
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3589,36 +3589,19 @@ nsXPCComponents_Utils::GetWeakReference(
     ref->Init();
     *_retval = ref;
     NS_ADDREF(*_retval);
     return NS_OK;
 }
 
 /* void forceGC (); */
 NS_IMETHODIMP
-nsXPCComponents_Utils::ForceGC()
+nsXPCComponents_Utils::ForceGC(JSContext *cx)
 {
-    nsXPConnect* xpc = nsXPConnect::GetXPConnect();
-    if (!xpc)
-        return NS_ERROR_FAILURE;
-
-    // get the xpconnect native call context
-    nsAXPCNativeCallContext *cc = nsnull;
-    nsresult rv = xpc->GetCurrentNativeCallContext(&cc);
-    if (!cc)
-        return rv;
-
-    // Get JSContext of current call
-    JSContext* cx;
-    cc->GetJSContext(&cx);
-    if (!cx)
-        return NS_ERROR_FAILURE;
-
     JS_GC(cx);
-
     return NS_OK;
 }
 
 class PreciseGCRunnable : public nsRunnable
 {
   public:
     PreciseGCRunnable(JSContext *aCx, ScheduledGCCallback* aCallback)
     : mCallback(aCallback), mCx(aCx) {}