| OLD | NEW |
| 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 Loading... |
| 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_ |
| OLD | NEW |