Bug 1298676 - Part 2: Add an AutoIOInterposerDisable RAII class. r=aklotz, a=jcristau
authorNathan Froyd <froydnj@mozilla.com>
Tue, 10 Jan 2017 16:31:25 -0500
changeset 353672 74b93a29d034530c5de1dd6336a30e151f7949f9
parent 353671 742559e3393fb7dd29e2a1072a583fbaace1c2c7
child 353673 e6d6e457c4f7aaae803a880b26bd0949fbc9fee2
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz, jcristau
bugs1298676
milestone52.0a2
Bug 1298676 - Part 2: Add an AutoIOInterposerDisable RAII class. r=aklotz, a=jcristau This will ensure the I/O Interposer is re-enabled after temporarily disabling it.
xpcom/build/IOInterposer.h
--- a/xpcom/build/IOInterposer.h
+++ b/xpcom/build/IOInterposer.h
@@ -3,16 +3,17 @@
 /* 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/. */
 
 #ifndef mozilla_IOInterposer_h
 #define mozilla_IOInterposer_h
 
 #include "mozilla/Attributes.h"
+#include "mozilla/GuardObjects.h"
 #include "mozilla/TimeStamp.h"
 
 namespace mozilla {
 
 /**
  * Interface for I/O interposer observers. This is separate from the
  * IOInterposer because we have multiple uses for these observations.
  */
@@ -267,11 +268,28 @@ public:
   ~IOInterposerInit()
   {
 #if !defined(RELEASE_OR_BETA)
     IOInterposer::Clear();
 #endif
   }
 };
 
+class MOZ_RAII AutoIOInterposerDisable final
+{
+public:
+  explicit AutoIOInterposerDisable(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
+  {
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+    IOInterposer::Disable();
+  }
+  ~AutoIOInterposerDisable()
+  {
+    IOInterposer::Enable();
+  }
+
+private:
+  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+};
+
 } // namespace mozilla
 
 #endif // mozilla_IOInterposer_h