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

Side by Side Diff: cc/surfaces/local_surface_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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
danakj 2017/01/27 16:25:17 2017 in new files
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_SURFACES_LOCAL_FRAME_ID_H_ 5 #ifndef CC_SURFACES_LOCAL_SURFACE_ID_H_
6 #define CC_SURFACES_LOCAL_FRAME_ID_H_ 6 #define CC_SURFACES_LOCAL_SURFACE_ID_H_
7 7
8 #include <inttypes.h> 8 #include <inttypes.h>
9 9
10 #include <iosfwd> 10 #include <iosfwd>
11 #include <string> 11 #include <string>
12 #include <tuple> 12 #include <tuple>
13 13
14 #include "base/hash.h" 14 #include "base/hash.h"
15 #include "base/unguessable_token.h" 15 #include "base/unguessable_token.h"
16 #include "mojo/public/cpp/bindings/struct_traits.h" 16 #include "mojo/public/cpp/bindings/struct_traits.h"
17 17
18 namespace cc { 18 namespace cc {
19 namespace mojom { 19 namespace mojom {
20 class LocalFrameIdDataView; 20 class LocalSurfaceIdDataView;
21 } 21 }
22 22
23 class LocalFrameId { 23 class LocalSurfaceId {
24 public: 24 public:
25 constexpr LocalFrameId() : local_id_(0) {} 25 constexpr LocalSurfaceId() : local_id_(0) {}
26 26
27 constexpr LocalFrameId(const LocalFrameId& other) 27 constexpr LocalSurfaceId(const LocalSurfaceId& other)
28 : local_id_(other.local_id_), nonce_(other.nonce_) {} 28 : local_id_(other.local_id_), nonce_(other.nonce_) {}
29 29
30 constexpr LocalFrameId(uint32_t local_id, const base::UnguessableToken& nonce) 30 constexpr LocalSurfaceId(uint32_t local_id,
31 const base::UnguessableToken& nonce)
31 : local_id_(local_id), nonce_(nonce) {} 32 : local_id_(local_id), nonce_(nonce) {}
32 33
33 constexpr bool is_valid() const { 34 constexpr bool is_valid() const {
34 return local_id_ != 0 && !nonce_.is_empty(); 35 return local_id_ != 0 && !nonce_.is_empty();
35 } 36 }
36 37
37 constexpr uint32_t local_id() const { return local_id_; } 38 constexpr uint32_t local_id() const { return local_id_; }
38 39
39 constexpr const base::UnguessableToken& nonce() const { return nonce_; } 40 constexpr const base::UnguessableToken& nonce() const { return nonce_; }
40 41
41 bool operator==(const LocalFrameId& other) const { 42 bool operator==(const LocalSurfaceId& other) const {
42 return local_id_ == other.local_id_ && nonce_ == other.nonce_; 43 return local_id_ == other.local_id_ && nonce_ == other.nonce_;
43 } 44 }
44 45
45 bool operator!=(const LocalFrameId& other) const { return !(*this == other); } 46 bool operator!=(const LocalSurfaceId& other) const {
47 return !(*this == other);
48 }
46 49
47 bool operator<(const LocalFrameId& other) const { 50 bool operator<(const LocalSurfaceId& other) const {
48 return std::tie(local_id_, nonce_) < 51 return std::tie(local_id_, nonce_) <
49 std::tie(other.local_id_, other.nonce_); 52 std::tie(other.local_id_, other.nonce_);
50 } 53 }
51 54
52 size_t hash() const { 55 size_t hash() const {
53 return base::HashInts( 56 return base::HashInts(
54 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); 57 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_)));
55 } 58 }
56 59
57 std::string ToString() const; 60 std::string ToString() const;
58 61
59 private: 62 private:
60 friend struct mojo::StructTraits<mojom::LocalFrameIdDataView, LocalFrameId>; 63 friend struct mojo::StructTraits<mojom::LocalSurfaceIdDataView,
64 LocalSurfaceId>;
61 65
62 uint32_t local_id_; 66 uint32_t local_id_;
63 base::UnguessableToken nonce_; 67 base::UnguessableToken nonce_;
64 }; 68 };
65 69
66 std::ostream& operator<<(std::ostream& out, const LocalFrameId& local_frame_id); 70 std::ostream& operator<<(std::ostream& out,
71 const LocalSurfaceId& local_surface_id);
67 72
68 struct LocalFrameIdHash { 73 struct LocalSurfaceIdHash {
69 size_t operator()(const LocalFrameId& key) const { return key.hash(); } 74 size_t operator()(const LocalSurfaceId& key) const { return key.hash(); }
70 }; 75 };
71 76
72 } // namespace cc 77 } // namespace cc
73 78
74 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ 79 #endif // CC_SURFACES_LOCAL_SURFACE_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698