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

Unified Diff: cc/surfaces/local_frame_id.h

Issue 2379653006: Replaced cc::SurfaceId::nonce_ with base::UnguessableToken (Closed)
Patch Set: Changed SurfaceManager::kRootSurfaceId to a private field to avoid static initialization Created 4 years, 1 month 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_scheduler_unittest.cc ('k') | cc/surfaces/surface_aggregator_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/local_frame_id.h
diff --git a/cc/surfaces/local_frame_id.h b/cc/surfaces/local_frame_id.h
index 3c11b0d11072a7a7668789214f6e9ce5c5a707e3..c3ac7822b799beabe209e42bdc1329cff3e045a3 100644
--- a/cc/surfaces/local_frame_id.h
+++ b/cc/surfaces/local_frame_id.h
@@ -10,24 +10,27 @@
#include "base/hash.h"
#include "base/strings/stringprintf.h"
+#include "base/unguessable_token.h"
namespace cc {
class LocalFrameId {
public:
- constexpr LocalFrameId() : local_id_(0), nonce_(0) {}
+ constexpr LocalFrameId() : local_id_(0) {}
constexpr LocalFrameId(const LocalFrameId& other)
: local_id_(other.local_id_), nonce_(other.nonce_) {}
- constexpr LocalFrameId(uint32_t local_id, uint64_t nonce)
+ constexpr LocalFrameId(uint32_t local_id, const base::UnguessableToken& nonce)
: local_id_(local_id), nonce_(nonce) {}
- constexpr bool is_valid() const { return local_id_ != 0 && nonce_ != 0; }
+ constexpr bool is_valid() const {
+ return local_id_ != 0 && !nonce_.is_empty();
+ }
constexpr uint32_t local_id() const { return local_id_; }
- constexpr uint64_t nonce() const { return nonce_; }
+ constexpr const base::UnguessableToken& nonce() const { return nonce_; }
bool operator==(const LocalFrameId& other) const {
return local_id_ == other.local_id_ && nonce_ == other.nonce_;
@@ -40,16 +43,19 @@ class LocalFrameId {
std::tie(other.local_id_, other.nonce_);
}
- size_t hash() const { return base::HashInts(local_id_, nonce_); }
+ size_t hash() const {
+ return base::HashInts(
+ local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_)));
+ }
std::string ToString() const {
- return base::StringPrintf("LocalFrameId(%d, %" PRIu64 ")", local_id_,
- nonce_);
+ return base::StringPrintf("LocalFrameId(%d, %s" PRIu64 ")", local_id_,
+ nonce_.ToString().c_str());
}
private:
uint32_t local_id_;
- uint64_t nonce_;
+ base::UnguessableToken nonce_;
};
struct LocalFrameIdHash {
« no previous file with comments | « cc/surfaces/display_scheduler_unittest.cc ('k') | cc/surfaces/surface_aggregator_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698