Bug 1326105 part 1. dom::RootedCallback should hold on to a JSContext that it can then use in its destructor. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 29 Dec 2016 13:19:25 -0800
changeset 327615 946d799f43afea40cd0386dbf7a546dfc5762552
parent 327614 01c4f310d039f0f3b4b08a0e6ce2afb1892f31de
child 327616 dd5b7e039015662e7084a6ccfe84d309eef60687
push id31139
push userryanvm@gmail.com
push dateFri, 30 Dec 2016 15:04:57 +0000
treeherdermozilla-central@9104708cc3ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1326105
milestone53.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 1326105 part 1. dom::RootedCallback should hold on to a JSContext that it can then use in its destructor. r=smaug
dom/bindings/CallbackObject.h
--- a/dom/bindings/CallbackObject.h
+++ b/dom/bindings/CallbackObject.h
@@ -540,21 +540,22 @@ ImplCycleCollectionUnlink(CallbackObject
   aField.UnlinkSelf();
 }
 
 // T is expected to be a RefPtr or OwningNonNull around a CallbackObject
 // subclass.  This class is used in bindings to safely handle Fast* callbacks;
 // it ensures that the callback is traced, and that if something is holding onto
 // the callback when we're done with it HoldJSObjects is called.
 template<typename T>
-class RootedCallback : public JS::Rooted<T>
+class MOZ_RAII RootedCallback : public JS::Rooted<T>
 {
 public:
   explicit RootedCallback(JSContext* cx)
     : JS::Rooted<T>(cx)
+    , mCx(cx)
   {}
 
   // We need a way to make assignment from pointers (how we're normally used)
   // work.
   template<typename S>
   void operator=(S* arg)
   {
     this->get().operator=(arg);
@@ -594,14 +595,16 @@ private:
     return aRefPtr;
   }
 
   template<typename U>
   static bool IsInitialized(OwningNonNull<U>& aOwningNonNull)
   {
     return aOwningNonNull.isInitialized();
   }
+
+  JSContext* mCx;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CallbackObject_h