summaryrefslogtreecommitdiffstats
path: root/chrome/common/ipc_maybe.h
blob: de45dc02b43b67c0c28355130e1bbf8d33d1c842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef CHROME_COMMON_MAYBE_H_
#define CHROME_COMMON_MAYBE_H_

namespace IPC {

// The Maybe type can be used to avoid serialising a type when it's invalid.
// This is most useful in conjunction with FileDescriptor, as there's no
// possible invalid value which can be serialised (one can type to use -1, but
// the IPC channel will fail). It may also be useful if the invalid value is
// otherwise expensive to serialise.
template<typename A>
struct Maybe {
  bool valid;
  A value;
};

}  // namespace IPC

#endif  // CHROME_COMMON_MAYBE_H_