Index: cc/surfaces/surface_id.h |
diff --git a/cc/surfaces/surface_id.h b/cc/surfaces/surface_id.h |
index 48a434affe1309ba155534537d63b381d938bff8..8b8d13134c5b2c77b58f33fc411c264775336a9d 100644 |
--- a/cc/surfaces/surface_id.h |
+++ b/cc/surfaces/surface_id.h |
@@ -13,62 +13,70 @@ |
#include "base/format_macros.h" |
#include "base/hash.h" |
#include "base/strings/stringprintf.h" |
+#include "cc/surfaces/frame_sink_id.h" |
namespace cc { |
class SurfaceId { |
public: |
- SurfaceId() : client_id_(0), local_id_(0), nonce_(0) {} |
+ SurfaceId() : local_id_(0), nonce_(0) {} |
SurfaceId(const SurfaceId& other) |
- : client_id_(other.client_id_), |
+ : frame_sink_id_(other.frame_sink_id_), |
local_id_(other.local_id_), |
nonce_(other.nonce_) {} |
- // A SurfaceId consists of three components: client Id, local Id, and nonce. |
- // A |client_id| is a display compositor service allocated ID that |
- // uniquely identifies a client. |
- // A |local_id| is a sequentially allocated ID generated by the display |
- // compositor client that uniquely identifies a surface. |
- // A |nonce| is a cryptographically secure random int that makes a SurfaceId |
- // unguessable by other clients. |
- SurfaceId(uint32_t client_id, uint32_t local_id, uint64_t nonce) |
- : client_id_(client_id), local_id_(local_id), nonce_(nonce) {} |
+ // A SurfaceId consists of three components: FrameSinkId, local Id, and nonce. |
+ // A |frame_sink_id| consists of two components; one is allocated by the |
+ // display compositor service and one is allocated by the client. The |
+ // |frame_sink_id| uniquely identifies a FrameSink (and frame source). |
+ // A |local_id| is a sequentially allocated ID generated by the frame source |
+ // that uniquely identifies a sequential set of frames of the same size and |
+ // device scale factor. |
+ // A |nonce| is a cryptographically secure unguessable token that makes it |
+ // impossible for an unprivileged frame source to embed another frame source |
+ // without being explicitly given the surface ID of that frame source from a |
+ // privileged process. |
+ SurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id, uint64_t nonce) |
+ : frame_sink_id_(frame_sink_id), local_id_(local_id), nonce_(nonce) {} |
bool is_null() const { |
- return client_id_ == 0 && nonce_ == 0 && local_id_ == 0; |
+ return frame_sink_id_.is_null() && nonce_ == 0 && local_id_ == 0; |
} |
size_t hash() const { |
- size_t interim = base::HashInts(client_id_, local_id_); |
- return base::HashInts(static_cast<uint64_t>(interim), nonce_); |
+ size_t interim = base::HashInts(local_id_, nonce_); |
+ return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), |
+ static_cast<uint64_t>(interim)); |
} |
- uint32_t client_id() const { return client_id_; } |
+ const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
uint32_t local_id() const { return local_id_; } |
uint64_t nonce() const { return nonce_; } |
std::string ToString() const { |
- return base::StringPrintf("%d:%d:%" PRIu64, client_id_, local_id_, nonce_); |
+ return base::StringPrintf("%s:LocalId(%d, %" PRIu64 ")", |
+ frame_sink_id_.ToString().c_str(), local_id_, |
+ nonce_); |
} |
bool operator==(const SurfaceId& other) const { |
- return client_id_ == other.client_id_ && local_id_ == other.local_id_ && |
- nonce_ == other.nonce_; |
+ return frame_sink_id_ == other.frame_sink_id_ && |
+ local_id_ == other.local_id_ && nonce_ == other.nonce_; |
} |
bool operator!=(const SurfaceId& other) const { return !(*this == other); } |
bool operator<(const SurfaceId& other) const { |
- return std::tie(client_id_, local_id_, nonce_) < |
- std::tie(other.client_id_, other.local_id_, other.nonce_); |
+ return std::tie(frame_sink_id_, local_id_, nonce_) < |
+ std::tie(frame_sink_id_, other.local_id_, other.nonce_); |
} |
private: |
// See SurfaceIdAllocator::GenerateId. |
- uint32_t client_id_; |
+ FrameSinkId frame_sink_id_; |
uint32_t local_id_; |
uint64_t nonce_; |
}; |