Bug 888104 - Reimplement Auto*JSContext in terms of AutoCxPusher. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Fri, 19 Jul 2013 18:21:45 -0700
changeset 147952 a8d411f033422cc4a641af09b268b76b57269103
parent 147951 3704ae20d90ef496332c470ae65cbdcff9a1d8cc
child 147953 d7c8ed78618ddeac9794845dee149cd5e8673915
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
bugs888104
milestone24.0a2
Bug 888104 - Reimplement Auto*JSContext in terms of AutoCxPusher. r=gabor
js/xpconnect/src/nsCxPusher.cpp
js/xpconnect/src/nsCxPusher.h
--- a/js/xpconnect/src/nsCxPusher.cpp
+++ b/js/xpconnect/src/nsCxPusher.cpp
@@ -188,30 +188,30 @@ AutoJSContext::Init(bool aSafe MOZ_GUARD
 
   nsXPConnect *xpc = nsXPConnect::XPConnect();
   if (!aSafe) {
     mCx = xpc->GetCurrentJSContext();
   }
 
   if (!mCx) {
     mCx = xpc->GetSafeJSContext();
-    mPusher.Push(mCx);
+    mPusher.construct(mCx);
   }
 }
 
 AutoJSContext::operator JSContext*() const
 {
   return mCx;
 }
 
 AutoSafeJSContext::AutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
   : AutoJSContext(true MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
 {
 }
 
 AutoPushJSContext::AutoPushJSContext(JSContext *aCx) : mCx(aCx)
 {
   if (mCx && mCx != nsXPConnect::XPConnect()->GetCurrentJSContext()) {
-    mPusher.Push(mCx);
+    mPusher.construct(mCx);
   }
 }
 
 } // namespace mozilla
--- a/js/xpconnect/src/nsCxPusher.h
+++ b/js/xpconnect/src/nsCxPusher.h
@@ -105,17 +105,17 @@ protected:
 
 private:
   // We need this Init() method because we can't use delegating constructor for
   // the moment. It is a C++11 feature and we do not require C++11 to be
   // supported to be able to compile Gecko.
   void Init(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
   JSContext* mCx;
-  nsCxPusher mPusher;
+  Maybe<AutoCxPusher> mPusher;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /**
  * AutoSafeJSContext is similar to AutoJSContext but will only return the safe
  * JS context. That means it will never call ::GetCurrentJSContext().
  */
 class MOZ_STACK_CLASS AutoSafeJSContext : public AutoJSContext {
@@ -133,17 +133,17 @@ public:
  * here is to preserve the existing behavior while ensure proper cx-stack
  * semantics in edge cases where the context being used doesn't match the active
  * context.
  *
  * NB: This will not push a null cx even if aCx is null. Make sure you know what
  * you're doing.
  */
 class MOZ_STACK_CLASS AutoPushJSContext {
-  nsCxPusher mPusher;
+  Maybe<AutoCxPusher> mPusher;
   JSContext* mCx;
 
 public:
   AutoPushJSContext(JSContext* aCx);
   operator JSContext*() { return mCx; }
 };
 
 } // namespace mozilla