Bug 860085 - Make XPCJSContextStack manipulators private to enforce that we go through the RAII classes. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Fri, 19 Jul 2013 18:21:53 -0700
changeset 147984 b831de023e6f4cd1eade30ac04f2f5a7b414c69a
parent 147983 0dbbd5e84d465000d4e302245fa09b239f31a047
child 147985 394dd09c63fd2fb26822bae4d0ae26985fd21ac1
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs860085
milestone24.0a2
Bug 860085 - Make XPCJSContextStack manipulators private to enforce that we go through the RAII classes. r=gabor With this change, we can be very, very sure that we never push an nsJSContext without instantiating an AutoCxPusher on the stack.
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -3256,25 +3256,32 @@ public:
         return mStack.Length();
     }
 
     JSContext *Peek()
     {
         return mStack.IsEmpty() ? NULL : mStack[mStack.Length() - 1].cx;
     }
 
-    JSContext *Pop();
-    bool Push(JSContext *cx);
     JSContext *GetSafeJSContext();
     bool HasJSContext(JSContext *cx);
 
     const InfallibleTArray<XPCJSContextInfo>* GetStack()
     { return &mStack; }
 
 private:
+    friend class mozilla::AutoCxPusher;
+    friend bool xpc::PushJSContextNoScriptContext(JSContext *aCx);;
+    friend void xpc::PopJSContextNoScriptContext();
+
+    // We make these private so that stack manipulation can only happen
+    // through one of the above friends.
+    JSContext *Pop();
+    bool Push(JSContext *cx);
+
     AutoInfallibleTArray<XPCJSContextInfo, 16> mStack;
     JSContext*  mSafeJSContext;
     JSContext*  mOwnSafeJSContext;
 };
 
 /***************************************************************************/
 // 'Components' object