blob: c9f88a73d41a1a16d3d31b757d7bb754cb78b1cc (
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
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_OBSERVER_H_
#define COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_OBSERVER_H_
#include <vector>
#include "base/process/process_handle.h"
#include "base/time/time.h"
#include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
#include "content/public/common/process_type.h"
namespace base {
class TimeDelta;
}
namespace tracked_objects {
struct ProcessDataPhaseSnapshot;
}
namespace metrics {
// Set of profiling events, in no guaranteed order. Implemented as a vector
// because we don't need to have an efficient .find() on it, so vector<> is more
// efficient.
typedef std::vector<ProfilerEventProto::ProfilerEvent> ProfilerEvents;
// Attributes of profiler data passed to
// TrackingSynchronizerObserver::ReceivedProfilerData.
struct ProfilerDataAttributes {
ProfilerDataAttributes(int profiling_phase,
base::ProcessId process_id,
content::ProcessType process_type,
base::TimeTicks phase_start,
base::TimeTicks phase_finish);
// 0-indexed profiling phase number.
const int profiling_phase;
// ID of the process that reported the data.
const base::ProcessId process_id;
// Type of the process that reported the data.
const content::ProcessType process_type;
// Time of the profiling phase start.
const base::TimeTicks phase_start;
// Time of the profiling phase finish.
const base::TimeTicks phase_finish;
};
// Observer for notifications from the TrackingSynchronizer class.
class TrackingSynchronizerObserver {
public:
// Received |process_data_phase| for profiling phase and process defined by
// |attributes|.
// Each completed phase is associated with an event that triggered the
// completion of the phase. |past_events| contains the set of events that
// completed prior to the reported phase. This data structure is useful for
// quickly computing the full set of profiled traces that occurred before or
// after a given event.
// The observer should assume there might be more data coming until
// FinishedReceivingData() is called.
virtual void ReceivedProfilerData(
const ProfilerDataAttributes& attributes,
const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase,
const ProfilerEvents& past_events) = 0;
// The observer should not expect any more calls to |ReceivedProfilerData()|
// (without re-registering). This is sent either when data from all processes
// has been gathered, or when the request times out.
virtual void FinishedReceivingProfilerData() {}
protected:
TrackingSynchronizerObserver() {}
virtual ~TrackingSynchronizerObserver() {}
private:
DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizerObserver);
};
} // namespace metrics
#endif // COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_OBSERVER_H_
|