| 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" | |
| 9 #include "mojo/services/public/cpp/view_manager/view_manager_types.h" | 8 #include "mojo/services/public/cpp/view_manager/view_manager_types.h" |
| 10 #include "mojo/services/view_manager/view_manager_export.h" | 9 #include "mojo/services/view_manager/view_manager_export.h" |
| 11 | 10 |
| 12 namespace mojo { | 11 namespace mojo { |
| 13 namespace services { | 12 namespace services { |
| 14 namespace view_manager { | 13 namespace view_manager { |
| 15 | 14 |
| 16 // Adds a bit of type safety to node ids. | 15 // Adds a bit of type safety to node ids. |
| 17 struct MOJO_VIEW_MANAGER_EXPORT NodeId { | 16 struct MOJO_VIEW_MANAGER_EXPORT NodeId { |
| 18 NodeId(TransportConnectionId connection_id, | 17 NodeId(TransportConnectionId connection_id, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 49 | 48 |
| 50 bool operator!=(const ViewId& other) const { | 49 bool operator!=(const ViewId& other) const { |
| 51 return !(*this == other); | 50 return !(*this == other); |
| 52 } | 51 } |
| 53 | 52 |
| 54 TransportConnectionId connection_id; | 53 TransportConnectionId connection_id; |
| 55 TransportConnectionSpecificViewId view_id; | 54 TransportConnectionSpecificViewId view_id; |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 // Functions for converting to/from structs and transport values. | 57 // 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 |
| 59 inline NodeId NodeIdFromTransportId(TransportNodeId id) { | 66 inline NodeId NodeIdFromTransportId(TransportNodeId id) { |
| 60 return NodeId(HiWord(id), LoWord(id)); | 67 return NodeId(FirstIdFromTransportId(id), SecondIdFromTransportId(id)); |
| 61 } | 68 } |
| 62 | 69 |
| 63 inline TransportNodeId NodeIdToTransportId(const NodeId& id) { | 70 inline TransportNodeId NodeIdToTransportId(const NodeId& id) { |
| 64 return (id.connection_id << 16) | id.node_id; | 71 return (id.connection_id << 16) | id.node_id; |
| 65 } | 72 } |
| 66 | 73 |
| 67 inline ViewId ViewIdFromTransportId(TransportViewId id) { | 74 inline ViewId ViewIdFromTransportId(TransportViewId id) { |
| 68 return ViewId(HiWord(id), LoWord(id)); | 75 return ViewId(FirstIdFromTransportId(id), SecondIdFromTransportId(id)); |
| 69 } | 76 } |
| 70 | 77 |
| 71 inline TransportViewId ViewIdToTransportId(const ViewId& id) { | 78 inline TransportViewId ViewIdToTransportId(const ViewId& id) { |
| 72 return (id.connection_id << 16) | id.view_id; | 79 return (id.connection_id << 16) | id.view_id; |
| 73 } | 80 } |
| 74 | 81 |
| 75 } // namespace view_manager | 82 } // namespace view_manager |
| 76 } // namespace services | 83 } // namespace services |
| 77 } // namespace mojo | 84 } // namespace mojo |
| 78 | 85 |
| 79 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_ | 86 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_ |
| OLD | NEW |