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

Side by Side Diff: mojo/services/view_manager/ids.h

Issue 513923004: More viewmanager renaming: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sim30 Created 6 years, 3 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
« no previous file with comments | « mojo/services/view_manager/display_manager.cc ('k') | mojo/services/view_manager/node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 MOJO_SERVICES_VIEW_MANAGER_IDS_H_ 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_IDS_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_IDS_H_ 6 #define MOJO_SERVICES_VIEW_MANAGER_IDS_H_
7 7
8 #include "mojo/services/public/cpp/view_manager/types.h" 8 #include "mojo/services/public/cpp/view_manager/types.h"
9 #include "mojo/services/public/cpp/view_manager/util.h" 9 #include "mojo/services/public/cpp/view_manager/util.h"
10 #include "mojo/services/view_manager/view_manager_export.h" 10 #include "mojo/services/view_manager/view_manager_export.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace service { 13 namespace service {
14 14
15 // Connection id is used to indicate no connection. That is, no 15 // Connection id is used to indicate no connection. That is, no
16 // ViewManagerServiceImpl ever gets this id. 16 // ViewManagerServiceImpl ever gets this id.
17 const ConnectionSpecificId kInvalidConnectionId = 0; 17 const ConnectionSpecificId kInvalidConnectionId = 0;
18 18
19 // TODO(sky): remove this, temporary while window manager API is in existing 19 // TODO(sky): remove this, temporary while window manager API is in existing
20 // api. 20 // api.
21 const ConnectionSpecificId kWindowManagerConnection = 1; 21 const ConnectionSpecificId kWindowManagerConnection = 1;
22 22
23 // Adds a bit of type safety to node ids.
24 struct MOJO_VIEW_MANAGER_EXPORT NodeId {
25 NodeId(ConnectionSpecificId connection_id, ConnectionSpecificId node_id)
26 : connection_id(connection_id),
27 node_id(node_id) {}
28 NodeId() : connection_id(0), node_id(0) {}
29
30 bool operator==(const NodeId& other) const {
31 return other.connection_id == connection_id &&
32 other.node_id == node_id;
33 }
34
35 bool operator!=(const NodeId& other) const {
36 return !(*this == other);
37 }
38
39 ConnectionSpecificId connection_id;
40 ConnectionSpecificId node_id;
41 };
42
43 // Adds a bit of type safety to view ids. 23 // Adds a bit of type safety to view ids.
44 struct MOJO_VIEW_MANAGER_EXPORT ViewId { 24 struct MOJO_VIEW_MANAGER_EXPORT ViewId {
45 ViewId(ConnectionSpecificId connection_id, ConnectionSpecificId view_id) 25 ViewId(ConnectionSpecificId connection_id, ConnectionSpecificId view_id)
46 : connection_id(connection_id), 26 : connection_id(connection_id),
47 view_id(view_id) {} 27 view_id(view_id) {}
48 ViewId() : connection_id(0), view_id(0) {} 28 ViewId() : connection_id(0), view_id(0) {}
49 29
50 bool operator==(const ViewId& other) const { 30 bool operator==(const ViewId& other) const {
51 return other.connection_id == connection_id && 31 return other.connection_id == connection_id &&
52 other.view_id == view_id; 32 other.view_id == view_id;
53 } 33 }
54 34
55 bool operator!=(const ViewId& other) const { 35 bool operator!=(const ViewId& other) const {
56 return !(*this == other); 36 return !(*this == other);
57 } 37 }
58 38
59 ConnectionSpecificId connection_id; 39 ConnectionSpecificId connection_id;
60 ConnectionSpecificId view_id; 40 ConnectionSpecificId view_id;
61 }; 41 };
62 42
63 // Functions for converting to/from structs and transport values.
64 inline NodeId NodeIdFromTransportId(Id id) {
65 return NodeId(HiWord(id), LoWord(id));
66 }
67
68 inline Id NodeIdToTransportId(const NodeId& id) {
69 return (id.connection_id << 16) | id.node_id;
70 }
71
72 inline ViewId ViewIdFromTransportId(Id id) { 43 inline ViewId ViewIdFromTransportId(Id id) {
73 return ViewId(HiWord(id), LoWord(id)); 44 return ViewId(HiWord(id), LoWord(id));
74 } 45 }
75 46
76 inline Id ViewIdToTransportId(const ViewId& id) { 47 inline Id ViewIdToTransportId(const ViewId& id) {
77 return (id.connection_id << 16) | id.view_id; 48 return (id.connection_id << 16) | id.view_id;
78 } 49 }
79 50
80 inline NodeId RootNodeId() { 51 inline ViewId RootViewId() {
81 return NodeId(kInvalidConnectionId, 1); 52 return ViewId(kInvalidConnectionId, 1);
82 } 53 }
83 54
84 // Returns a NodeId that is reserved to indicate no node. That is, no node will 55 // Returns a ViewId that is reserved to indicate no view. That is, no view will
85 // ever be created with this id. 56 // ever be created with this id.
86 inline NodeId InvalidNodeId() { 57 inline ViewId InvalidViewId() {
87 return NodeId(kInvalidConnectionId, 0); 58 return ViewId(kInvalidConnectionId, 0);
88 } 59 }
89 60
90 } // namespace service 61 } // namespace service
91 } // namespace mojo 62 } // namespace mojo
92 63
93 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_ 64 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_
OLDNEW
« no previous file with comments | « mojo/services/view_manager/display_manager.cc ('k') | mojo/services/view_manager/node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698