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

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

Issue 260863008: Add support for mapping node tree on the client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
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/view_manager_types.h" 9 #include "mojo/services/public/cpp/view_manager/view_manager_types.h"
9 #include "mojo/services/view_manager/view_manager_export.h" 10 #include "mojo/services/view_manager/view_manager_export.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 namespace services { 13 namespace services {
13 namespace view_manager { 14 namespace view_manager {
14 15
15 // Adds a bit of type safety to node ids. 16 // Adds a bit of type safety to node ids.
16 struct MOJO_VIEW_MANAGER_EXPORT NodeId { 17 struct MOJO_VIEW_MANAGER_EXPORT NodeId {
17 NodeId(TransportConnectionId connection_id, 18 NodeId(TransportConnectionId connection_id,
(...skipping 30 matching lines...) Expand all
48 49
49 bool operator!=(const ViewId& other) const { 50 bool operator!=(const ViewId& other) const {
50 return !(*this == other); 51 return !(*this == other);
51 } 52 }
52 53
53 TransportConnectionId connection_id; 54 TransportConnectionId connection_id;
54 TransportConnectionSpecificViewId view_id; 55 TransportConnectionSpecificViewId view_id;
55 }; 56 };
56 57
57 // Functions for converting to/from structs and transport values. 58 // Functions for converting to/from structs and transport values.
58 inline uint16_t FirstIdFromTransportId(uint32_t id) {
59 return static_cast<uint16_t>((id >> 16) & 0xFFFF);
60 }
61
62 inline uint16_t SecondIdFromTransportId(uint32_t id) {
63 return static_cast<uint16_t>(id & 0xFFFF);
64 }
65
66 inline NodeId NodeIdFromTransportId(TransportNodeId id) { 59 inline NodeId NodeIdFromTransportId(TransportNodeId id) {
67 return NodeId(FirstIdFromTransportId(id), SecondIdFromTransportId(id)); 60 return NodeId(HiWord(id), LoWord(id));
68 } 61 }
69 62
70 inline TransportNodeId NodeIdToTransportId(const NodeId& id) { 63 inline TransportNodeId NodeIdToTransportId(const NodeId& id) {
71 return (id.connection_id << 16) | id.node_id; 64 return (id.connection_id << 16) | id.node_id;
72 } 65 }
73 66
74 inline ViewId ViewIdFromTransportId(TransportViewId id) { 67 inline ViewId ViewIdFromTransportId(TransportViewId id) {
75 return ViewId(FirstIdFromTransportId(id), SecondIdFromTransportId(id)); 68 return ViewId(HiWord(id), LoWord(id));
76 } 69 }
77 70
78 inline TransportViewId ViewIdToTransportId(const ViewId& id) { 71 inline TransportViewId ViewIdToTransportId(const ViewId& id) {
79 return (id.connection_id << 16) | id.view_id; 72 return (id.connection_id << 16) | id.view_id;
80 } 73 }
81 74
82 } // namespace view_manager 75 } // namespace view_manager
83 } // namespace services 76 } // namespace services
84 } // namespace mojo 77 } // namespace mojo
85 78
86 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_ 79 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_
OLDNEW
« no previous file with comments | « mojo/services/public/cpp/view_manager/view_tree_node.h ('k') | mojo/services/view_manager/view_manager_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698