File: routine_converters.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (171 lines) | stat: -rw-r--r-- 6,961 bytes parent folder | download | duplicates (7)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_TELEMETRY_EXTENSION_ROUTINES_ROUTINE_CONVERTERS_H_
#define CHROMEOS_ASH_COMPONENTS_TELEMETRY_EXTENSION_ROUTINES_ROUTINE_CONVERTERS_H_

#include <type_traits>
#include <utility>

#include "chromeos/ash/services/cros_healthd/public/mojom/cros_healthd_routines.mojom.h"
#include "chromeos/crosapi/mojom/telemetry_diagnostic_routine_service.mojom.h"

namespace ash::converters {

// This file contains helper functions used by
// TelemetryDiagnosticsRoutineServiceAsh to convert its types to/from
// cros_healthd routine types.

// Contains conversion functions that skip checking the `mojo::InlinedStructPtr`
// for null.
namespace unchecked {

crosapi::mojom::TelemetryDiagnosticMemtesterResultPtr UncheckedConvertPtr(
    cros_healthd::mojom::MemtesterResultPtr input);

crosapi::mojom::TelemetryDiagnosticMemoryRoutineDetailPtr UncheckedConvertPtr(
    cros_healthd::mojom::MemoryRoutineDetailPtr input);

crosapi::mojom::TelemetryDiagnosticFanRoutineDetailPtr UncheckedConvertPtr(
    cros_healthd::mojom::FanRoutineDetailPtr input);

crosapi::mojom::TelemetryDiagnosticNetworkBandwidthRoutineDetailPtr
UncheckedConvertPtr(
    cros_healthd::mojom::NetworkBandwidthRoutineDetailPtr input);

crosapi::mojom::TelemetryDiagnosticCameraFrameAnalysisRoutineDetailPtr
UncheckedConvertPtr(
    cros_healthd::mojom::CameraFrameAnalysisRoutineDetailPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineStateInitializedPtr
UncheckedConvertPtr(cros_healthd::mojom::RoutineStateInitializedPtr input);

crosapi::mojom::TelemetryDiagnosticNetworkBandwidthRoutineRunningInfoPtr
UncheckedConvertPtr(
    cros_healthd::mojom::NetworkBandwidthRoutineRunningInfoPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineRunningInfoPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineRunningInfoPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineStateRunningPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineStateRunningPtr input);

crosapi::mojom::TelemetryDiagnosticCheckLedLitUpStateInquiryPtr
UncheckedConvertPtr(cros_healthd::mojom::CheckLedLitUpStateInquiryPtr input);

crosapi::mojom::TelemetryDiagnosticCheckKeyboardBacklightStateInquiryPtr
UncheckedConvertPtr(
    cros_healthd::mojom::CheckKeyboardBacklightStateInquiryPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineInquiryPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineInquiryPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineInteractionPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineInteractionPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineStateWaitingPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineStateWaitingPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineDetailPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineDetailPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineStateFinishedPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineStateFinishedPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineStateUnionPtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineStateUnionPtr input);

crosapi::mojom::TelemetryDiagnosticRoutineStatePtr UncheckedConvertPtr(
    cros_healthd::mojom::RoutineStatePtr input);

cros_healthd::mojom::RoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticRoutineArgumentPtr input);

cros_healthd::mojom::MemoryRoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticMemoryRoutineArgumentPtr input);

cros_healthd::mojom::VolumeButtonRoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticVolumeButtonRoutineArgumentPtr input);

cros_healthd::mojom::FanRoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticFanRoutineArgumentPtr input);

cros_healthd::mojom::LedLitUpRoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticLedLitUpRoutineArgumentPtr input);

cros_healthd::mojom::CheckLedLitUpStateReplyPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticCheckLedLitUpStateReplyPtr input);

cros_healthd::mojom::CheckKeyboardBacklightStateReplyPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticCheckKeyboardBacklightStateReplyPtr
        input);

cros_healthd::mojom::RoutineInquiryReplyPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticRoutineInquiryReplyPtr input);

cros_healthd::mojom::NetworkBandwidthRoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticNetworkBandwidthRoutineArgumentPtr
        input);

cros_healthd::mojom::CameraFrameAnalysisRoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticCameraFrameAnalysisRoutineArgumentPtr
        input);

cros_healthd::mojom::KeyboardBacklightRoutineArgumentPtr UncheckedConvertPtr(
    crosapi::mojom::TelemetryDiagnosticKeyboardBacklightRoutineArgumentPtr
        input);

}  // namespace unchecked

cros_healthd::mojom::LedName Convert(
    crosapi::mojom::TelemetryDiagnosticLedName input);

cros_healthd::mojom::LedColor Convert(
    crosapi::mojom::TelemetryDiagnosticLedColor input);

cros_healthd::mojom::CheckLedLitUpStateReply::State Convert(
    crosapi::mojom::TelemetryDiagnosticCheckLedLitUpStateReply::State input);

cros_healthd::mojom::CheckKeyboardBacklightStateReply::State Convert(
    crosapi::mojom::TelemetryDiagnosticCheckKeyboardBacklightStateReply::State
        input);

crosapi::mojom::TelemetryDiagnosticMemtesterTestItemEnum Convert(
    cros_healthd::mojom::MemtesterTestItemEnum input);

crosapi::mojom::TelemetryDiagnosticHardwarePresenceStatus Convert(
    cros_healthd::mojom::HardwarePresenceStatus input);

crosapi::mojom::TelemetryDiagnosticRoutineStateWaiting::Reason Convert(
    cros_healthd::mojom::RoutineStateWaiting::Reason input);

crosapi::mojom::TelemetryDiagnosticNetworkBandwidthRoutineRunningInfo::Type
Convert(cros_healthd::mojom::NetworkBandwidthRoutineRunningInfo::Type input);

crosapi::mojom::TelemetryDiagnosticCameraFrameAnalysisRoutineDetail::Issue
Convert(cros_healthd::mojom::CameraFrameAnalysisRoutineDetail::Issue input);

crosapi::mojom::TelemetryDiagnosticCameraSubtestResult Convert(
    cros_healthd::mojom::CameraSubtestResult input);

template <class InputT,
          class OutputT = decltype(Convert(std::declval<InputT>())),
          class = std::enable_if_t<std::is_enum_v<InputT>, bool>>
std::vector<OutputT> ConvertVector(std::vector<InputT> input) {
  std::vector<OutputT> result;
  for (auto elem : input) {
    result.push_back(Convert(elem));
  }
  return result;
}

template <class InputT>
auto ConvertRoutinePtr(InputT input) {
  return (!input.is_null()) ? unchecked::UncheckedConvertPtr(std::move(input))
                            : nullptr;
}

}  // namespace ash::converters

#endif  // CHROMEOS_ASH_COMPONENTS_TELEMETRY_EXTENSION_ROUTINES_ROUTINE_CONVERTERS_H_