Bug 1510853 - Make TransactionId usable for other 64bit identifiers. r=jrmuizel
☠☠ backed out by 9b7e80071dec ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 07 Dec 2018 17:06:07 +0000
changeset 508832 0ade0aa77b2f2e04e15b4618c9ef1a74b8739777
parent 508831 7b9332b0c24d8f40310d9020693bb2321f32c935
child 508833 ae190948ad730114399ac7074dbbf1cda2ebe359
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<