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