Bug 1510853 - Make TransactionId usable for other 64bit identifiers. r=jrmuizel
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 07 Dec 2018 23:26:53 +0000
changeset 508868 2dd3277b650808e2afb458792ec2efee68362be2
parent 508867 21f77dc6811d390c937f927e5ce9b0320ea8c091
child 508869 be8b9297085042370ded2cd12b210b7ebeb895a8
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1510853
milestone65.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 1510853 - Make TransactionId usable for other 64bit identifiers. r=jrmuizel MozReview-Commit-ID: 9qX9A7ZGWS8 Differential Revision: https://phabricator.services.mozilla.com/D13349
gfx/layers/LayersTypes.h
gfx/layers/ipc/LayersMessageUtils.h
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -74,49 +74,61 @@ struct LayersId {
   //   std::unordered_map<LayersId, ValueType, LayersId::HashFn> myMap;
   struct HashFn {
     std::size_t operator()(const LayersId& aKey) const {
       return std::hash<uint64_t>{}(aKey.mId);
     }
   };
 };
 
-struct TransactionId {
-  uint64_t mId;
+template <typename T>
+struct BaseTransactionId {
+  uint64_t mId = 0;
 
   bool IsValid() const { return mId != 0; }
 
-  MOZ_MUST_USE TransactionId Next() const { return TransactionId{mId + 1}; }
+  MOZ_MUST_USE BaseTransactionId<T> Next() const {
+    return BaseTransactionId<T>{mId + 1};
+  }
 
-  MOZ_MUST_USE TransactionId Prev() const { return TransactionId{mId - 1}; }
+  MOZ_MUST_USE BaseTransactionId<T> Prev() const {
+    return BaseTransactionId<T>{mId - 1};
+  }
 
-  int64_t operator-(const TransactionId& aOther) const {
+  int64_t operator-(const BaseTransactionId<T>& aOther) const {
     return mId - aOther.mId;
   }
 
   // Allow explicit cast to a uint64_t for now
   explicit operator uint64_t() const { return mId; }
 
-  bool operator<(const TransactionId& aOther) const { return mId < aOther.mId; }
+  bool operator<(const BaseTransactionId<T>& aOther) const {
+    return mId < aOther.mId;
+  }
 
-  bool operator<=(const TransactionId& aOther) const {
+  bool operator<=(const BaseTransactionId<T>& aOther) const {
     return mId <= aOther.mId;
   }
 
-  bool operator>(const TransactionId& aOther) const { return mId > aOther.mId; }
+  bool operator>(const BaseTransactionId<T>& aOther) const {
+    return mId > aOther.mId;
+  }
 
-  bool operator>=(const TransactionId& aOther) const {
+  bool operator>=(const BaseTransactionId<T>& aOther) const {
     return mId >= aOther.mId;
   }
 
-  bool operator==(const TransactionId& aOther) const {
+  bool operator==(const BaseTransactionId<T>& aOther) const {
     return mId == aOther.mId;
   }
 };
 
+class TransactionIdType {};
+typedef BaseTransactionId<TransactionIdType> TransactionId;
+
 struct LayersObserverEpoch {
   uint64_t mId;
 
   MOZ_MUST_USE LayersObserverEpoch Next() const {
     return LayersObserverEpoch{mId + 1};
   }
 
   bool operator<=(const LayersObserverEpoch& aOther) const {
--- a/gfx/layers/ipc/LayersMessageUtils.h
+++ b/gfx/layers/ipc/LayersMessageUtils.h
@@ -33,19 +33,19 @@
 #endif
 
 namespace IPC {
 
 template <>
 struct ParamTraits<mozilla::layers::LayersId>
     : public PlainOldDataSerializer<mozilla::layers::LayersId> {};
 
-template <>
-struct ParamTraits<mozilla::layers::TransactionId>
-    : public PlainOldDataSerializer<mozilla::layers::TransactionId> {};
+template <typename T>
+struct ParamTraits<mozilla::layers::BaseTransactionId<T>>
+    : public PlainOldDataSerializer<mozilla::layers::BaseTransactionId<T>> {};
 
 template <>
 struct ParamTraits<mozilla::layers::LayersObserverEpoch>
     : public PlainOldDataSerializer<mozilla::layers::LayersObserverEpoch> {};
 
 template <>
 struct ParamTraits<mozilla::layers::LayersBackend>
     : public ContiguousEnumSerializer<