Bug 677079 - Part k: Expose outstandingRequests in jsfriendapi.h; r=cdleary
authorMs2ger <ms2ger@gmail.com>
Sun, 15 Jan 2012 09:13:09 +0100
changeset 86905 46b5d4c3b3d8fd767add83477e36d55139edc33a
parent 86904 be5a53604bc33bfde4d010714c3eb56a96a730b1
child 86906 29a2d146c5ff184df4bb8dee53d4329002a6f792
push idunknown
push userunknown
push dateunknown
reviewerscdleary
bugs677079
milestone12.0a1
Bug 677079 - Part k: Expose outstandingRequests in jsfriendapi.h; r=cdleary
dom/base/nsJSEnvironment.cpp
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/xpconnect/src/nsXPConnect.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -32,17 +32,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "jscntxt.h" // outstandingRequests
 #include "nsJSEnvironment.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsDOMCID.h"
 #include "nsIServiceManager.h"
@@ -1122,17 +1121,17 @@ nsJSContext::DestroyJSContext()
   mContext = nsnull;
 }
 
 // QueryInterface implementation for nsJSContext
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSContext)
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSContext)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSContext)
-  NS_ASSERTION(!tmp->mContext || tmp->mContext->outstandingRequests == 0,
+  NS_ASSERTION(!tmp->mContext || js::GetContextOutstandingRequests(tmp->mContext) == 0,
                "Trying to unlink a context with outstanding requests.");
   tmp->mIsInitialized = false;
   tmp->mGCOnDestruction = false;
   tmp->DestroyJSContext();
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mGlobalObjectRef)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSContext)
   NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSContext, tmp->GetCCRefcnt())
@@ -1152,17 +1151,17 @@ NS_INTERFACE_MAP_END
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsJSContext)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsJSContext)
 
 nsrefcnt
 nsJSContext::GetCCRefcnt()
 {
   nsrefcnt refcnt = mRefCnt.get();
   if (NS_LIKELY(mContext))
-    refcnt += mContext->outstandingRequests;
+    refcnt += js::GetContextOutstandingRequests(mContext);
   return refcnt;
 }
 
 nsresult
 nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
                                      JSObject* aScopeObject,
                                      nsIPrincipal *aPrincipal,
                                      const char *aURL,
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -522,11 +522,17 @@ CallContextDebugHandler(JSContext *cx, J
 }
 
 #ifdef JS_THREADSAFE
 JSThread *
 GetContextThread(const JSContext *cx)
 {
     return cx->thread();
 }
+
+JS_FRIEND_API(unsigned)
+GetContextOutstandingRequests(const JSContext *cx)
+{
+    return cx->outstandingRequests;
+}
 #endif
 
 } // namespace js
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -448,16 +448,19 @@ JS_FRIEND_API(JSString *)
 GetPCCountScriptSummary(JSContext *cx, size_t script);
 
 JS_FRIEND_API(JSString *)
 GetPCCountScriptContents(JSContext *cx, size_t script);
 
 #ifdef JS_THREADSAFE
 JS_FRIEND_API(JSThread *)
 GetContextThread(const JSContext *cx);
+
+JS_FRIEND_API(unsigned)
+GetContextOutstandingRequests(const JSContext *cx);
 #endif
 
 class JS_FRIEND_API(AutoLockGC)
 {
   public:
     explicit AutoLockGC(JSRuntime *rt = NULL
                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : runtime(rt)
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -64,17 +64,17 @@
 #include "XPCQuickStubs.h"
 #include "dombindings.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Base64.h"
 
 #include "nsWrapperCacheInlines.h"
 
-#include "jscntxt.h" // js::ThreadData, JS_TRACER_INIT, context->stackLimit, cx->outstandingRequests,
+#include "jscntxt.h" // js::ThreadData, JS_TRACER_INIT, context->stackLimit,
 // cx->globalObject, sizeof(JSContext), js::CompartmentVector, cx->stack.empty()
 
 NS_IMPL_THREADSAFE_ISUPPORTS7(nsXPConnect,
                               nsIXPConnect,
                               nsISupportsWeakReference,
                               nsIThreadObserver,
                               nsIJSRuntimeService,
                               nsIJSContextStack,
@@ -965,17 +965,17 @@ nsXPConnect::Traverse(void *p, nsCycleCo
     }
 
     return NS_OK;
 }
 
 unsigned
 nsXPConnect::GetOutstandingRequests(JSContext* cx)
 {
-    unsigned n = cx->outstandingRequests;
+    unsigned n = js::GetContextOutstandingRequests(cx);
     XPCCallContext* context = mCycleCollectionContext;
     // Ignore the contribution from the XPCCallContext we created for cycle
     // collection.
     if (context && cx == context->GetJSContext()) {
         JS_ASSERT(n);
         --n;
     }
     return n;