Bug 1364622 - Add a utility function AsyncPanZoomController::CallWithLastContentPaintMetrics(). r=kats
MozReview-Commit-ID: Juh622Qoh2I
--- 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: