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

Side by Side Diff: components/mus/ws/ids.h

Issue 1459973005: Reland of Use std::tie() for operator< in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 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 COMPONENTS_MUS_WS_IDS_H_ 5 #ifndef COMPONENTS_MUS_WS_IDS_H_
6 #define COMPONENTS_MUS_WS_IDS_H_ 6 #define COMPONENTS_MUS_WS_IDS_H_
7 7
8 #include <tuple>
9
8 #include "components/mus/common/types.h" 10 #include "components/mus/common/types.h"
9 #include "components/mus/common/util.h" 11 #include "components/mus/common/util.h"
10 12
11 namespace mus { 13 namespace mus {
12 14
13 namespace ws { 15 namespace ws {
14 16
15 // Connection id is used to indicate no connection. That is, no WindowTreeImpl 17 // Connection id is used to indicate no connection. That is, no WindowTreeImpl
16 // ever gets this id. 18 // ever gets this id.
17 const ConnectionSpecificId kInvalidConnectionId = 0; 19 const ConnectionSpecificId kInvalidConnectionId = 0;
18 20
19 // Adds a bit of type safety to window ids. 21 // Adds a bit of type safety to window ids.
20 struct WindowId { 22 struct WindowId {
21 WindowId(ConnectionSpecificId connection_id, ConnectionSpecificId window_id) 23 WindowId(ConnectionSpecificId connection_id, ConnectionSpecificId window_id)
22 : connection_id(connection_id), window_id(window_id) {} 24 : connection_id(connection_id), window_id(window_id) {}
23 WindowId() : connection_id(0), window_id(0) {} 25 WindowId() : connection_id(0), window_id(0) {}
24 26
25 bool operator==(const WindowId& other) const { 27 bool operator==(const WindowId& other) const {
26 return other.connection_id == connection_id && other.window_id == window_id; 28 return other.connection_id == connection_id && other.window_id == window_id;
27 } 29 }
28 30
29 bool operator!=(const WindowId& other) const { return !(*this == other); } 31 bool operator!=(const WindowId& other) const { return !(*this == other); }
30 32
31 bool operator<(const WindowId& other) const { 33 bool operator<(const WindowId& other) const {
32 if (connection_id == other.connection_id) 34 return std::tie(connection_id, window_id) <
33 return window_id < other.window_id; 35 std::tie(other.connection_id, other.window_id);
34
35 return connection_id < other.connection_id;
36 } 36 }
37 37
38 ConnectionSpecificId connection_id; 38 ConnectionSpecificId connection_id;
39 ConnectionSpecificId window_id; 39 ConnectionSpecificId window_id;
40 }; 40 };
41 41
42 inline WindowId WindowIdFromTransportId(Id id) { 42 inline WindowId WindowIdFromTransportId(Id id) {
43 return WindowId(HiWord(id), LoWord(id)); 43 return WindowId(HiWord(id), LoWord(id));
44 } 44 }
45 45
(...skipping 10 matching lines...) Expand all
56 // Returns a root window id with a given index offset. 56 // Returns a root window id with a given index offset.
57 inline WindowId RootWindowId(uint16_t index) { 57 inline WindowId RootWindowId(uint16_t index) {
58 return WindowId(kInvalidConnectionId, 2 + index); 58 return WindowId(kInvalidConnectionId, 2 + index);
59 } 59 }
60 60
61 } // namespace ws 61 } // namespace ws
62 62
63 } // namespace mus 63 } // namespace mus
64 64
65 #endif // COMPONENTS_MUS_WS_IDS_H_ 65 #endif // COMPONENTS_MUS_WS_IDS_H_
OLDNEW
« no previous file with comments | « components/guest_view/browser/guest_view_manager.cc ('k') | components/policy/core/common/policy_namespace.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698