OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_ID_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ID_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_ID_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ID_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 namespace internal { | |
12 | 11 |
13 // The size of the type matters because it is directly used in messages. | 12 // The size of the type matters because it is directly used in messages. |
14 using InterfaceId = uint32_t; | 13 using InterfaceId = uint32_t; |
15 | 14 |
16 // IDs of associated interface can be generated at both sides of the message | 15 // IDs of associated interface can be generated at both sides of the message |
17 // pipe. In order to avoid collision, the highest bit is used as namespace bit: | 16 // pipe. In order to avoid collision, the highest bit is used as namespace bit: |
18 // at the side where the client-side of the master interface lives, IDs are | 17 // at the side where the client-side of the master interface lives, IDs are |
19 // generated with the namespace bit set to 1; at the opposite side IDs are | 18 // generated with the namespace bit set to 1; at the opposite side IDs are |
20 // generated with the namespace bit set to 0. | 19 // generated with the namespace bit set to 0. |
21 const uint32_t kInterfaceIdNamespaceMask = 0x80000000; | 20 const uint32_t kInterfaceIdNamespaceMask = 0x80000000; |
22 | 21 |
23 const InterfaceId kMasterInterfaceId = 0x00000000; | 22 const InterfaceId kMasterInterfaceId = 0x00000000; |
24 const InterfaceId kInvalidInterfaceId = 0xFFFFFFFF; | 23 const InterfaceId kInvalidInterfaceId = 0xFFFFFFFF; |
25 | 24 |
26 inline bool IsMasterInterfaceId(InterfaceId id) { | 25 inline bool IsMasterInterfaceId(InterfaceId id) { |
27 return id == kMasterInterfaceId; | 26 return id == kMasterInterfaceId; |
28 } | 27 } |
29 | 28 |
30 inline bool IsValidInterfaceId(InterfaceId id) { | 29 inline bool IsValidInterfaceId(InterfaceId id) { |
31 return id != kInvalidInterfaceId; | 30 return id != kInvalidInterfaceId; |
32 } | 31 } |
33 | 32 |
34 } // namespace internal | |
35 } // namespace mojo | 33 } // namespace mojo |
36 | 34 |
37 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_ID_H_ | 35 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ID_H_ |
OLD | NEW |