Bug 752578 - Use mfbt's guard object implementation in js/ipc. r=Ms2ger
authorJeff Walden <jwalden@mit.edu>
Thu, 27 Dec 2012 11:20:22 -0600
changeset 123039 7f628cbf1073dda524db9c1d71ceb04e4d9616cc
parent 123038 0d6c5f87f08bb687cf3e0148f8d8b48940becc3e
child 123040 01efd933f60b4376289c1174bd3d45aef096ad0f
push idunknown
push userunknown
push dateunknown
reviewersMs2ger
bugs752578
milestone20.0a1
Bug 752578 - Use mfbt's guard object implementation in js/ipc. r=Ms2ger
js/ipc/ObjectWrapperChild.cpp
js/ipc/ObjectWrapperParent.cpp
--- a/js/ipc/ObjectWrapperChild.cpp
+++ b/js/ipc/ObjectWrapperChild.cpp
@@ -1,15 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sw=4 et tw=80:
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/GuardObjects.h"
+
 #include "base/basictypes.h"
 
 #include "mozilla/jsipc/ContextWrapperChild.h"
 #include "mozilla/jsipc/ObjectWrapperChild.h"
 #include "mozilla/jsipc/CPOWTypes.h"
 
 #include "jsapi.h"
 #include "nsAutoPtr.h"
@@ -23,28 +25,28 @@ using namespace js;
 namespace {
 
     class AutoContextPusher {
 
         nsCxPusher mStack;
         JSAutoRequest mRequest;
         JSContext* const mContext;
         const uint32_t mSavedOptions;
-        JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+        MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     public:
 
         AutoContextPusher(JSContext* cx
-                          JS_GUARD_OBJECT_NOTIFIER_PARAM)
+                          MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
             : mRequest(cx)
             , mContext(cx)
             , mSavedOptions(JS_SetOptions(cx, (JS_GetOptions(cx) |
                                                JSOPTION_DONT_REPORT_UNCAUGHT)))
         {
-            JS_GUARD_OBJECT_NOTIFIER_INIT;
+            MOZ_GUARD_OBJECT_NOTIFIER_INIT;
             mStack.Push(cx, false);
         }
 
         ~AutoContextPusher() {
             mStack.Pop();
             JS_SetOptions(mContext, mSavedOptions);
         }
 
@@ -71,24 +73,24 @@ namespace {
             return mStatusPtr;
         }
     };
 
     typedef AutoCheckOperationBase<StatusPtrOwner> ACOBase;
 
     class AutoCheckOperation : public ACOBase
     {
-        JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+        MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
     public:
         AutoCheckOperation(ObjectWrapperChild* owc,
                            OperationStatus* statusPtr
-                           JS_GUARD_OBJECT_NOTIFIER_PARAM)
+                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
             : ACOBase(NULL, owc)
         {
-            JS_GUARD_OBJECT_NOTIFIER_INIT;
+            MOZ_GUARD_OBJECT_NOTIFIER_INIT;
             SetStatusPtr(statusPtr);
         }
     };
 }
 
 void
 ObjectWrapperChild::CheckOperation(JSContext*,
                                    OperationStatus* status)
--- a/js/ipc/ObjectWrapperParent.cpp
+++ b/js/ipc/ObjectWrapperParent.cpp
@@ -1,15 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sw=4 et tw=80:
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/GuardObjects.h"
+
 #include "mozilla/jsipc/ObjectWrapperParent.h"
 #include "mozilla/jsipc/ContextWrapperParent.h"
 #include "mozilla/jsipc/CPOWTypes.h"
 #include "mozilla/unused.h"
 #include "nsJSUtils.h"
 
 #include "jsutil.h"
 #include "jsfriendapi.h"
@@ -23,38 +25,38 @@ namespace {
     static const unsigned sFlagsSlot = 0;
     static const unsigned sNumSlots = 1;
     static const unsigned CPOW_FLAG_RESOLVING = 1 << 0;
 
     class AutoResolveFlag
     {
         JSObject* mObj;
         unsigned mOldFlags;
-        JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+        MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
         static unsigned GetFlags(JSObject* obj) {
             jsval v = JS_GetReservedSlot(obj, sFlagsSlot);
             return JSVAL_TO_INT(v);
         }
 
         static unsigned SetFlags(JSObject* obj, unsigned flags) {
             unsigned oldFlags = GetFlags(obj);
             if (oldFlags != flags)
                 JS_SetReservedSlot(obj, sFlagsSlot, INT_TO_JSVAL(flags));
             return oldFlags;
         }
 
     public:
 
         AutoResolveFlag(JSObject* obj
-                        JS_GUARD_OBJECT_NOTIFIER_PARAM)
+                        MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
             : mObj(obj)
             , mOldFlags(SetFlags(obj, GetFlags(obj) | CPOW_FLAG_RESOLVING))
         {
-            JS_GUARD_OBJECT_NOTIFIER_INIT;
+            MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         }
 
         ~AutoResolveFlag() {
             SetFlags(mObj, mOldFlags);
         }
 
         static JSBool IsSet(JSObject* obj) {
             return GetFlags(obj) & CPOW_FLAG_RESOLVING;
@@ -71,24 +73,24 @@ namespace {
             return &mStatus;
         }
     };
 
     typedef AutoCheckOperationBase<StatusMemberOwner> ACOBase;
 
     class AutoCheckOperation : public ACOBase
     {
-        JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+        MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
     public:
         AutoCheckOperation(JSContext* cx,
                            ObjectWrapperParent* owp
-                           JS_GUARD_OBJECT_NOTIFIER_PARAM)
+                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
             : ACOBase(cx, owp)
         {
-            JS_GUARD_OBJECT_NOTIFIER_INIT;
+            MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         }
     };
 
 }
 
 void
 ObjectWrapperParent::CheckOperation(JSContext* cx,
                                     OperationStatus* status)