Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3307)

Unified Diff: cc/surfaces/surface_id.h

Issue 1996783002: Make cc::SurfaceId unguessable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed more build targets Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/surfaces/surface_hittest_unittest.cc ('k') | cc/surfaces/surface_id_allocator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_id.h
diff --git a/cc/surfaces/surface_id.h b/cc/surfaces/surface_id.h
index bbc485f9009f90eaf577205f31dd7d2533310b6e..0ba30a102b6912970a9fef3b4df95f53b23cdff6 100644
--- a/cc/surfaces/surface_id.h
+++ b/cc/surfaces/surface_id.h
@@ -10,22 +10,26 @@
#include <functional>
+#include "base/hash.h"
+
namespace cc {
struct SurfaceId {
- SurfaceId() : id(0) {}
- explicit SurfaceId(uint64_t id) : id(id) {}
+ SurfaceId() : id_namespace(0), local_id(0) {}
+ SurfaceId(const SurfaceId& other)
+ : id_namespace(other.id_namespace), local_id(other.local_id) {}
+ SurfaceId(uint32_t id_namespace, uint64_t local_id)
+ : id_namespace(id_namespace), local_id(local_id) {}
- bool is_null() const { return id == 0; }
+ bool is_null() const { return id_namespace == 0 && local_id == 0; }
// See SurfaceIdAllocator::GenerateId.
- uint32_t id_namespace() const { return id >> 32; }
-
- uint64_t id;
+ uint32_t id_namespace;
+ uint64_t local_id;
};
inline bool operator==(const SurfaceId& a, const SurfaceId& b) {
- return a.id == b.id;
+ return (a.id_namespace == b.id_namespace) && (a.local_id == b.local_id);
Tom Sepez 2016/05/20 20:22:02 nit: overparenthesized, also line 40
Fady Samuel 2016/05/24 20:33:07 Done. I've switched to if statements for readabili
}
inline bool operator!=(const SurfaceId& a, const SurfaceId& b) {
@@ -33,12 +37,13 @@ inline bool operator!=(const SurfaceId& a, const SurfaceId& b) {
}
inline bool operator<(const SurfaceId& a, const SurfaceId& b) {
- return a.id < b.id;
+ return (a.id_namespace < b.id_namespace) ||
+ ((a.id_namespace == b.id_namespace) && (a.local_id < b.local_id));
}
struct SurfaceIdHash {
size_t operator()(const SurfaceId& key) const {
- return std::hash<uint64_t>()(key.id);
+ return base::HashInts64(key.id_namespace, key.local_id);
danakj 2016/05/20 21:01:36 Just use HashInts() it picks the right function.
Fady Samuel 2016/05/24 20:33:07 Done.
}
};
« no previous file with comments | « cc/surfaces/surface_hittest_unittest.cc ('k') | cc/surfaces/surface_id_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698