summaryrefslogtreecommitdiffstats
path: root/toolkit/components/telemetry/core/ipc/TelemetryIPC.h
blob: bf4528005909dad9cb47faf30b0b7fb4045633cc (plain)
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
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef TelemetryIPC_h__
#define TelemetryIPC_h__

#include "mozilla/TelemetryProcessEnums.h"
#include "nsTArray.h"

// This module provides the interface to accumulate Telemetry from child
// processes. Top-level actors for different child processes types
// (ContentParent, GPUChild) will call this for messages from their respective
// processes.

namespace mozilla {

namespace Telemetry {

struct HistogramAccumulation;
struct KeyedHistogramAccumulation;
struct ScalarAction;
struct KeyedScalarAction;
struct DynamicScalarDefinition;
struct ChildEventData;
struct DiscardedData;

}  // namespace Telemetry

namespace TelemetryIPC {

/**
 * Accumulate child process data into histograms for the given process type.
 *
 * @param aProcessType - the process type to accumulate the histograms for
 * @param aAccumulations - accumulation actions to perform
 */
void AccumulateChildHistograms(
    Telemetry::ProcessID aProcessType,
    const nsTArray<Telemetry::HistogramAccumulation>& aAccumulations);

/**
 * Accumulate child process data into keyed histograms for the given process
 * type.
 *
 * @param aProcessType - the process type to accumulate the keyed histograms for
 * @param aAccumulations - accumulation actions to perform
 */
void AccumulateChildKeyedHistograms(
    Telemetry::ProcessID aProcessType,
    const nsTArray<Telemetry::KeyedHistogramAccumulation>& aAccumulations);

/**
 * Update scalars for the given process type with the data coming from child
 * process.
 *
 * @param aProcessType - the process type to process the scalar actions for
 * @param aScalarActions - actions to update the scalar data
 */
void UpdateChildScalars(
    Telemetry::ProcessID aProcessType,
    const nsTArray<Telemetry::ScalarAction>& aScalarActions);

/**
 * Update keyed scalars for the given process type with the data coming from
 * child process.
 *
 * @param aProcessType - the process type to process the keyed scalar actions
 *                       for
 * @param aScalarActions - actions to update the keyed scalar data
 */
void UpdateChildKeyedScalars(
    Telemetry::ProcessID aProcessType,
    const nsTArray<Telemetry::KeyedScalarAction>& aScalarActions);

/**
 * Record events for the given process type with the data coming from child
 * process.
 *
 * @param aProcessType - the process type to record the events for
 * @param aEvents - events to record
 */
void RecordChildEvents(Telemetry::ProcessID aProcessType,
                       const nsTArray<Telemetry::ChildEventData>& aEvents);

/**
 * Record the counts of data the child process had to discard
 *
 * @param aProcessType - the process reporting the discarded data
 * @param aDiscardedData - stats about the discarded data
 */
void RecordDiscardedData(Telemetry::ProcessID aProcessType,
                         const Telemetry::DiscardedData& aDiscardedData);

/**
 * Get the dynamic scalar definitions from the parent process.
 * @param aDefs - The array that will contain the scalar definitions.
 */
void GetDynamicScalarDefinitions(
    nsTArray<mozilla::Telemetry::DynamicScalarDefinition>& aDefs);

/**
 * Add the dynamic scalar definitions coming from the parent process
 * to the current child process.
 * @param aDefs - The array that contains the scalar definitions.
 */
void AddDynamicScalarDefinitions(
    const nsTArray<mozilla::Telemetry::DynamicScalarDefinition>& aDefs);

}  // namespace TelemetryIPC
}  // namespace mozilla

#endif  // TelemetryIPC_h__