OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
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 SERVICES_UI_WS_IDS_H_ | 5 #ifndef SERVICES_UI_WS_IDS_H_ |
6 #define SERVICES_UI_WS_IDS_H_ | 6 #define SERVICES_UI_WS_IDS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <string> |
10 #include <tuple> | 11 #include <tuple> |
11 | 12 |
12 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
13 #include "base/hash.h" | 14 #include "base/hash.h" |
| 15 #include "base/strings/stringprintf.h" |
14 #include "services/ui/common/types.h" | 16 #include "services/ui/common/types.h" |
15 #include "services/ui/common/util.h" | 17 #include "services/ui/common/util.h" |
16 | 18 |
17 namespace ui { | 19 namespace ui { |
18 namespace ws { | 20 namespace ws { |
19 | 21 |
20 // A client id used to indicate no client. That is, no WindowTree ever gets this | 22 // A client id used to indicate no client. That is, no WindowTree ever gets this |
21 // id. | 23 // id. |
22 const ClientSpecificId kInvalidClientId = 0; | 24 const ClientSpecificId kInvalidClientId = 0; |
23 | 25 |
(...skipping 20 matching lines...) Expand all Loading... |
44 return other.client_id == client_id && other.window_id == window_id; | 46 return other.client_id == client_id && other.window_id == window_id; |
45 } | 47 } |
46 | 48 |
47 bool operator!=(const WindowId& other) const { return !(*this == other); } | 49 bool operator!=(const WindowId& other) const { return !(*this == other); } |
48 | 50 |
49 bool operator<(const WindowId& other) const { | 51 bool operator<(const WindowId& other) const { |
50 return std::tie(client_id, window_id) < | 52 return std::tie(client_id, window_id) < |
51 std::tie(other.client_id, other.window_id); | 53 std::tie(other.client_id, other.window_id); |
52 } | 54 } |
53 | 55 |
| 56 std::string ToString() const { |
| 57 return base::StringPrintf("%u:%u", client_id, window_id); |
| 58 } |
| 59 |
54 ClientSpecificId client_id; | 60 ClientSpecificId client_id; |
55 ClientSpecificId window_id; | 61 ClientSpecificId window_id; |
56 }; | 62 }; |
57 | 63 |
58 // Used for ids assigned by the client. | 64 // Used for ids assigned by the client. |
59 struct ClientWindowId { | 65 struct ClientWindowId { |
60 explicit ClientWindowId(Id id) : id(id) {} | 66 explicit ClientWindowId(Id id) : id(id) {} |
61 ClientWindowId() : id(0u) {} | 67 ClientWindowId() : id(0u) {} |
62 | 68 |
63 bool operator==(const ClientWindowId& other) const { return other.id == id; } | 69 bool operator==(const ClientWindowId& other) const { return other.id == id; } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 template <> | 110 template <> |
105 struct hash<ui::ws::WindowId> { | 111 struct hash<ui::ws::WindowId> { |
106 size_t operator()(const ui::ws::WindowId& id) const { | 112 size_t operator()(const ui::ws::WindowId& id) const { |
107 return hash<ui::Id>()(WindowIdToTransportId(id)); | 113 return hash<ui::Id>()(WindowIdToTransportId(id)); |
108 } | 114 } |
109 }; | 115 }; |
110 | 116 |
111 } // namespace BASE_HASH_NAMESPACE | 117 } // namespace BASE_HASH_NAMESPACE |
112 | 118 |
113 #endif // SERVICES_UI_WS_IDS_H_ | 119 #endif // SERVICES_UI_WS_IDS_H_ |
OLD | NEW |