OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_ID_H_ | |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_ID_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 namespace mojo { | |
11 namespace internal { | |
12 | |
13 // The size of the type matters because it is directly used in messages. | |
14 using InterfaceId = uint32_t; | |
15 | |
16 // 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: | |
18 // 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 | |
20 // generated with the namespace bit set to 0. | |
21 const uint32_t kInterfaceIdNamespaceMask = 0x80000000; | |
22 | |
23 const InterfaceId kMasterInterfaceId = 0x00000000; | |
24 const InterfaceId kInvalidInterfaceId = 0xFFFFFFFF; | |
25 | |
26 inline bool IsMasterInterfaceId(InterfaceId id) { | |
27 return id == kMasterInterfaceId; | |
28 } | |
29 | |
30 inline bool IsValidInterfaceId(InterfaceId id) { | |
31 return id != kInvalidInterfaceId; | |
32 } | |
33 | |
34 } // namespace internal | |
35 } // namespace mojo | |
36 | |
37 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_ID_H_ | |
OLD | NEW |