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

Side by Side Diff: cc/surfaces/local_frame_id.h

Issue 2661543002: Rename LocalFrameId to LocalSurfaceId (Closed)
Patch Set: c Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « cc/surfaces/display_unittest.cc ('k') | cc/surfaces/local_frame_id.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_SURFACES_LOCAL_FRAME_ID_H_
6 #define CC_SURFACES_LOCAL_FRAME_ID_H_
7
8 #include <inttypes.h>
9
10 #include <iosfwd>
11 #include <string>
12 #include <tuple>
13
14 #include "base/hash.h"
15 #include "base/unguessable_token.h"
16 #include "mojo/public/cpp/bindings/struct_traits.h"
17
18 namespace cc {
19 namespace mojom {
20 class LocalFrameIdDataView;
21 }
22
23 class LocalFrameId {
24 public:
25 constexpr LocalFrameId() : local_id_(0) {}
26
27 constexpr LocalFrameId(const LocalFrameId& other)
28 : local_id_(other.local_id_), nonce_(other.nonce_) {}
29
30 constexpr LocalFrameId(uint32_t local_id, const base::UnguessableToken& nonce)
31 : local_id_(local_id), nonce_(nonce) {}
32
33 constexpr bool is_valid() const {
34 return local_id_ != 0 && !nonce_.is_empty();
35 }
36
37 constexpr uint32_t local_id() const { return local_id_; }
38
39 constexpr const base::UnguessableToken& nonce() const { return nonce_; }
40
41 bool operator==(const LocalFrameId& other) const {
42 return local_id_ == other.local_id_ && nonce_ == other.nonce_;
43 }
44
45 bool operator!=(const LocalFrameId& other) const { return !(*this == other); }
46
47 bool operator<(const LocalFrameId& other) const {
48 return std::tie(local_id_, nonce_) <
49 std::tie(other.local_id_, other.nonce_);
50 }
51
52 size_t hash() const {
53 return base::HashInts(
54 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_)));
55 }
56
57 std::string ToString() const;
58
59 private:
60 friend struct mojo::StructTraits<mojom::LocalFrameIdDataView, LocalFrameId>;
61
62 uint32_t local_id_;
63 base::UnguessableToken nonce_;
64 };
65
66 std::ostream& operator<<(std::ostream& out, const LocalFrameId& local_frame_id);
67
68 struct LocalFrameIdHash {
69 size_t operator()(const LocalFrameId& key) const { return key.hash(); }
70 };
71
72 } // namespace cc
73
74 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_
OLDNEW
« no previous file with comments | « cc/surfaces/display_unittest.cc ('k') | cc/surfaces/local_frame_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698