| 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 <string> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // | 31 // |
| 32 // This model works when the client initiates creation of windows, which is | 32 // This model works when the client initiates creation of windows, which is |
| 33 // the typical use case. Embed roots and the WindowManager are special, they | 33 // the typical use case. Embed roots and the WindowManager are special, they |
| 34 // get access to windows created by other clients. These clients see the | 34 // get access to windows created by other clients. These clients see the |
| 35 // id assigned on the server. Such clients have to take care that they only | 35 // id assigned on the server. Such clients have to take care that they only |
| 36 // create windows using their client id. To do otherwise could result in | 36 // create windows using their client id. To do otherwise could result in |
| 37 // multiple windows having the same ClientWindowId. WindowTree enforces | 37 // multiple windows having the same ClientWindowId. WindowTree enforces |
| 38 // that embed roots use the client id in creating the window id to avoid | 38 // that embed roots use the client id in creating the window id to avoid |
| 39 // possible conflicts. | 39 // possible conflicts. |
| 40 struct WindowId { | 40 struct WindowId { |
| 41 WindowId(ClientSpecificId client_id, ClientSpecificId window_id) | 41 constexpr WindowId(ClientSpecificId client_id, ClientSpecificId window_id) |
| 42 : client_id(client_id), window_id(window_id) {} | 42 : client_id(client_id), window_id(window_id) {} |
| 43 WindowId() : client_id(0), window_id(0) {} | 43 constexpr WindowId() : client_id(0), window_id(0) {} |
| 44 | 44 |
| 45 bool operator==(const WindowId& other) const { | 45 bool operator==(const WindowId& other) const { |
| 46 return other.client_id == client_id && other.window_id == window_id; | 46 return other.client_id == client_id && other.window_id == window_id; |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool operator!=(const WindowId& other) const { return !(*this == other); } | 49 bool operator!=(const WindowId& other) const { return !(*this == other); } |
| 50 | 50 |
| 51 bool operator<(const WindowId& other) const { | 51 bool operator<(const WindowId& other) const { |
| 52 return std::tie(client_id, window_id) < | 52 return std::tie(client_id, window_id) < |
| 53 std::tie(other.client_id, other.window_id); | 53 std::tie(other.client_id, other.window_id); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 template <> | 110 template <> |
| 111 struct hash<ui::ws::WindowId> { | 111 struct hash<ui::ws::WindowId> { |
| 112 size_t operator()(const ui::ws::WindowId& id) const { | 112 size_t operator()(const ui::ws::WindowId& id) const { |
| 113 return hash<ui::Id>()(WindowIdToTransportId(id)); | 113 return hash<ui::Id>()(WindowIdToTransportId(id)); |
| 114 } | 114 } |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 } // namespace BASE_HASH_NAMESPACE | 117 } // namespace BASE_HASH_NAMESPACE |
| 118 | 118 |
| 119 #endif // SERVICES_UI_WS_IDS_H_ | 119 #endif // SERVICES_UI_WS_IDS_H_ |
| OLD | NEW |