File: metrics_utils.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; 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,811; 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 (70 lines) | stat: -rw-r--r-- 2,846 bytes parent folder | download | duplicates (6)
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
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_METRICS_UTILS_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_METRICS_UTILS_H_

#include <optional>

#include "base/time/time.h"

namespace device_signals {

enum class SignalCollectionError;
enum class SignalName;
enum class UserPermission;

// Set of possible errors encountered when parsing some signal values from a
// file or other data source. Do not reorder the values. Also change
// DeviceSignalsParsingError in enums.xml if adding new values here.
enum class SignalsParsingError {
  kHitMaxDataSize = 0,
  kDataMalformed = 1,
  kBase64DecodingFailed = 2,
  kJsonParsingFailed = 3,
  kMissingRequiredProperty = 4,
  kMaxValue = kMissingRequiredProperty
};

// Records that `permission` was the outcome of a permission check.
void LogUserPermissionChecked(UserPermission permission);

// Records that a request to collect `signal_name` was received.
void LogSignalCollectionRequested(SignalName signal_name);

// Records that a request to collect `number_of_signals` was received.
void LogSignalsCountRequested(size_t number_of_signals);

// Records that a request to collect the parameterized signal named
// `signal_name` was received with `number_of_items` parameters.
void LogSignalCollectionRequestedWithItems(SignalName signal_name,
                                           size_t number_of_items);

// Records that the collection of the signal `signal_name` failed with `error`,
// which, based on `is_top_level_error`, is either a top-level aggregation
// error, or a collection-level error. `start_time` is the time at which the
// signal collection request was received.
void LogSignalCollectionFailed(SignalName signal_name,
                               base::TimeTicks start_time,
                               SignalCollectionError error,
                               bool is_top_level_error);

// Records that the collection of the signal `signal_name` was successful.
// If applicable, will also record the number of items collected as given by
// `signal_collection_size`. `start_time` is the time at which the
// signal collection request was received. `signal_request_size` is the number
// of items that were part of the signal collection request.
void LogSignalCollectionSucceeded(
    SignalName signal_name,
    base::TimeTicks start_time,
    std::optional<size_t> signal_collection_size,
    std::optional<size_t> signal_request_size = std::nullopt);

// Records that an error occurred when trying to parse signals from the
// CrowdStrike data.zta file.
void LogCrowdStrikeParsingError(SignalsParsingError error);

}  // namespace device_signals

#endif  // COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_METRICS_UTILS_H_