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

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

Issue 292283002: Finishes up setroots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/services/view_manager/node.cc » ('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/util.h" 8 #include "mojo/services/public/cpp/view_manager/util.h"
9 #include "mojo/services/public/cpp/view_manager/view_manager_types.h" 9 #include "mojo/services/public/cpp/view_manager/view_manager_types.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 view_manager { 13 namespace view_manager {
14 namespace service { 14 namespace service {
15 15
16 // Connection id reserved for the root.
17 const TransportConnectionId kRootConnection = 0;
18
16 // Adds a bit of type safety to node ids. 19 // Adds a bit of type safety to node ids.
17 struct MOJO_VIEW_MANAGER_EXPORT NodeId { 20 struct MOJO_VIEW_MANAGER_EXPORT NodeId {
18 NodeId(TransportConnectionId connection_id, 21 NodeId(TransportConnectionId connection_id,
19 TransportConnectionSpecificNodeId node_id) 22 TransportConnectionSpecificNodeId node_id)
20 : connection_id(connection_id), 23 : connection_id(connection_id),
21 node_id(node_id) {} 24 node_id(node_id) {}
22 NodeId() : connection_id(0), node_id(0) {} 25 NodeId() : connection_id(0), node_id(0) {}
23 26
24 bool operator==(const NodeId& other) const { 27 bool operator==(const NodeId& other) const {
25 return other.connection_id == connection_id && 28 return other.connection_id == connection_id &&
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 68 }
66 69
67 inline ViewId ViewIdFromTransportId(TransportViewId id) { 70 inline ViewId ViewIdFromTransportId(TransportViewId id) {
68 return ViewId(HiWord(id), LoWord(id)); 71 return ViewId(HiWord(id), LoWord(id));
69 } 72 }
70 73
71 inline TransportViewId ViewIdToTransportId(const ViewId& id) { 74 inline TransportViewId ViewIdToTransportId(const ViewId& id) {
72 return (id.connection_id << 16) | id.view_id; 75 return (id.connection_id << 16) | id.view_id;
73 } 76 }
74 77
78 inline NodeId RootNodeId() {
79 return NodeId(kRootConnection, 1);
80 }
81
82 // Returns a NodeId that is reserved to indicate no node. That is, no node will
83 // ever be created with this id.
84 inline NodeId InvalidNodeId() {
85 return NodeId(kRootConnection, 0);
86 }
87
75 } // namespace service 88 } // namespace service
76 } // namespace view_manager 89 } // namespace view_manager
77 } // namespace mojo 90 } // namespace mojo
78 91
79 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_ 92 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/services/view_manager/node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698