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

Unified Diff: cc/surfaces/surface_id_allocator.cc

Issue 2425923003: Replaced is_null() with is_valid in SurfaceId and related classes. (Closed)
Patch Set: Removed added printf statements; LocalFrameId::is_valid() no longer checks if nonce is 0. Created 4 years, 2 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
Index: cc/surfaces/surface_id_allocator.cc
diff --git a/cc/surfaces/surface_id_allocator.cc b/cc/surfaces/surface_id_allocator.cc
index af4d5932df723a6da76dc79377e0430248785966..e6c4194444275407b3306634111785aa3ce1ce81 100644
--- a/cc/surfaces/surface_id_allocator.cc
+++ b/cc/surfaces/surface_id_allocator.cc
@@ -17,6 +17,10 @@ SurfaceIdAllocator::~SurfaceIdAllocator() {
LocalFrameId SurfaceIdAllocator::GenerateId() {
uint64_t nonce = base::RandUint64();
+ // Since 0 nonce are treated as uninitialized and thus invalid, we need to
+ // keep generating until there is a non-zero nonce
+ while (nonce == 0)
+ nonce = base::RandUint64();
LocalFrameId id(next_id_, nonce);
next_id_++;
return id;

Powered by Google App Engine
This is Rietveld 408576698