1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ash / components / arc / session / mojo_init_data.h [blame]
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_COMPONENTS_ARC_SESSION_MOJO_INIT_DATA_H_
#define ASH_COMPONENTS_ARC_SESSION_MOJO_INIT_DATA_H_
#include <fcntl.h>
#include <cstdint>
#include <string>
#include <vector>
#include "base/token.h"
namespace arc {
// Contains data to be sent to ARC during bootstrap connection.
class MojoInitData {
public:
struct InterfaceVersion {
base::Token uuid;
uint32_t version;
// Comparison as a tuple of (`uuid`, `version`).
constexpr bool operator<(const InterfaceVersion& other) const;
};
MojoInitData();
MojoInitData(const MojoInitData&) = delete;
MojoInitData& operator=(const MojoInitData&) = delete;
~MojoInitData();
// Returns a vector containing the pointer to each data.
// Note that the returned value is no longer available after `MojoInitData`
// being destroyed.
//
// Protocol version 0:
// Send version, token_length, and token.
// Protocol version 1:
// Send version, token_length, and token.
// After that, send the number of interfaces and the list of
// {uuid, version} for each interface.
std::vector<iovec> AsIOvecVector();
const std::string& token() const { return token_; }
private:
const uint8_t protocol_version_;
// Token is sent at the beginning of the communication and used as the name of
// the message pipe.
const std::string token_;
};
} // namespace arc
#endif // ASH_COMPONENTS_ARC_SESSION_MOJO_INIT_DATA_H_