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

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: 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/display.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..5482464e452cdbf82a1dec6df55f832d9f28230d 100644
--- a/cc/surfaces/surface_id.h
+++ b/cc/surfaces/surface_id.h
@@ -13,19 +13,19 @@
namespace cc {
struct SurfaceId {
- SurfaceId() : id(0) {}
- explicit SurfaceId(uint64_t id) : id(id) {}
+ SurfaceId() : id_namespace(0), id(0) {}
+ SurfaceId(uint32_t id_namespace, uint64_t id)
+ : id_namespace(id_namespace), id(id) {}
- bool is_null() const { return id == 0; }
+ bool is_null() const { return id_namespace == 0 && id == 0; }
// See SurfaceIdAllocator::GenerateId.
- uint32_t id_namespace() const { return id >> 32; }
-
+ uint32_t id_namespace;
uint64_t id;
};
inline bool operator==(const SurfaceId& a, const SurfaceId& b) {
- return a.id == b.id;
+ return (a.id_namespace == a.id_namespace) && (a.id == b.id);
}
inline bool operator!=(const SurfaceId& a, const SurfaceId& b) {
@@ -33,12 +33,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.id < b.id);
}
struct SurfaceIdHash {
size_t operator()(const SurfaceId& key) const {
- return std::hash<uint64_t>()(key.id);
+ return std::hash<uint64_t>()((key.id_namespace) | (key.id << 32));
jbauman 2016/05/20 00:29:00 Probably better to use base::HashInts64.
Fady Samuel 2016/05/20 00:40:31 Done.
}
};
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/surface_id_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698