Bug 1364622 - Add a utility function AsyncPanZoomController::CallWithLastContentPaintMetrics(). r=kats
authorBotond Ballo <botond@mozilla.com>
Mon, 15 May 2017 19:38:51 -0400
changeset 579735 cb603b519a5db41cd74ebdf2a9245480e9549fac
parent 579734 9da6da9c2a6580b7b028356d2a04265ebd18d9ec
child 579736 c4f86883f3254617d6834b53f42050ee687d6b2e
push id59357
push userbballo@mozilla.com
push dateWed, 17 May 2017 19:07:47 +0000
reviewerskats
bugs1364622
milestone55.0a1
Bug 1364622 - Add a utility function AsyncPanZoomController::CallWithLastContentPaintMetrics(). r=kats MozReview-Commit-ID: Juh622Qoh2I
gfx/layers/apz/src/AsyncPanZoomController.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -743,16 +743,30 @@ private:
   UniquePtr<OverscrollEffectBase> mOverscrollEffect;
 
   // Groups state variables that are specific to a platform.
   // Initialized on first use.
   UniquePtr<PlatformSpecificStateBase> mPlatformSpecificState;
 
   friend class Axis;
 
+public:
+  /**
+   * Invoke |callable|, passing |mLastContentPaintMetrics| as argument,
+   * while holding the APZC lock required to access |mLastContentPaintMetrics|.
+   * This allows code outside of an AsyncPanZoomController method implementation
+   * to access |mLastContentPaintMetrics| without having to make a copy of it.
+   * Passes through the return value of |callable|.
+   */
+  template <typename Callable>
+  auto CallWithLastContentPaintMetrics(const Callable& callable) const
+    -> decltype(callable(mLastContentPaintMetrics)) {
+    ReentrantMonitorAutoEnter lock(mMonitor);
+    return callable(mLastContentPaintMetrics);
+  }
 
   /* ===================================================================
    * The functions and members in this section are used to expose
    * the current async transform state to callers.
    */
 public:
   /**
    * Allows callers to specify which type of async transform they want: