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

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

Issue 1456263005: Revert 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
10 #include "components/mus/common/types.h" 8 #include "components/mus/common/types.h"
11 #include "components/mus/common/util.h" 9 #include "components/mus/common/util.h"
12 10
13 namespace mus { 11 namespace mus {
14 12
15 namespace ws { 13 namespace ws {
16 14
17 // Connection id is used to indicate no connection. That is, no WindowTreeImpl 15 // Connection id is used to indicate no connection. That is, no WindowTreeImpl
18 // ever gets this id. 16 // ever gets this id.
19 const ConnectionSpecificId kInvalidConnectionId = 0; 17 const ConnectionSpecificId kInvalidConnectionId = 0;
20 18
21 // Adds a bit of type safety to window ids. 19 // Adds a bit of type safety to window ids.
22 struct WindowId { 20 struct WindowId {
23 WindowId(ConnectionSpecificId connection_id, ConnectionSpecificId window_id) 21 WindowId(ConnectionSpecificId connection_id, ConnectionSpecificId window_id)
24 : connection_id(connection_id), window_id(window_id) {} 22 : connection_id(connection_id), window_id(window_id) {}
25 WindowId() : connection_id(0), window_id(0) {} 23 WindowId() : connection_id(0), window_id(0) {}
26 24
27 bool operator==(const WindowId& other) const { 25 bool operator==(const WindowId& other) const {
28 return other.connection_id == connection_id && other.window_id == window_id; 26 return other.connection_id == connection_id && other.window_id == window_id;
29 } 27 }
30 28
31 bool operator!=(const WindowId& other) const { return !(*this == other); } 29 bool operator!=(const WindowId& other) const { return !(*this == other); }
32 30
33 bool operator<(const WindowId& other) const { 31 bool operator<(const WindowId& other) const {
34 return std::tie(connection_id, window_id) < 32 if (connection_id == other.connection_id)
35 std::tie(other.connection_id, other.window_id); 33 return window_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