Update V8 to version 4.6.62.
[chromium-blink-merge.git] / components / metrics / profiler / tracking_synchronizer_observer.h
blobc9f88a73d41a1a16d3d31b757d7bb754cb78b1cc
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_OBSERVER_H_
6 #define COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_OBSERVER_H_
8 #include <vector>
10 #include "base/process/process_handle.h"
11 #include "base/time/time.h"
12 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
13 #include "content/public/common/process_type.h"
15 namespace base {
16 class TimeDelta;
19 namespace tracked_objects {
20 struct ProcessDataPhaseSnapshot;
23 namespace metrics {
25 // Set of profiling events, in no guaranteed order. Implemented as a vector
26 // because we don't need to have an efficient .find() on it, so vector<> is more
27 // efficient.
28 typedef std::vector<ProfilerEventProto::ProfilerEvent> ProfilerEvents;
30 // Attributes of profiler data passed to
31 // TrackingSynchronizerObserver::ReceivedProfilerData.
32 struct ProfilerDataAttributes {
33 ProfilerDataAttributes(int profiling_phase,
34 base::ProcessId process_id,
35 content::ProcessType process_type,
36 base::TimeTicks phase_start,
37 base::TimeTicks phase_finish);
39 // 0-indexed profiling phase number.
40 const int profiling_phase;
42 // ID of the process that reported the data.
43 const base::ProcessId process_id;
45 // Type of the process that reported the data.
46 const content::ProcessType process_type;
48 // Time of the profiling phase start.
49 const base::TimeTicks phase_start;
51 // Time of the profiling phase finish.
52 const base::TimeTicks phase_finish;
55 // Observer for notifications from the TrackingSynchronizer class.
56 class TrackingSynchronizerObserver {
57 public:
58 // Received |process_data_phase| for profiling phase and process defined by
59 // |attributes|.
60 // Each completed phase is associated with an event that triggered the
61 // completion of the phase. |past_events| contains the set of events that
62 // completed prior to the reported phase. This data structure is useful for
63 // quickly computing the full set of profiled traces that occurred before or
64 // after a given event.
65 // The observer should assume there might be more data coming until
66 // FinishedReceivingData() is called.
67 virtual void ReceivedProfilerData(
68 const ProfilerDataAttributes& attributes,
69 const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase,
70 const ProfilerEvents& past_events) = 0;
72 // The observer should not expect any more calls to |ReceivedProfilerData()|
73 // (without re-registering). This is sent either when data from all processes
74 // has been gathered, or when the request times out.
75 virtual void FinishedReceivingProfilerData() {}
77 protected:
78 TrackingSynchronizerObserver() {}
79 virtual ~TrackingSynchronizerObserver() {}
81 private:
82 DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizerObserver);
85 } // namespace metrics
87 #endif // COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_OBSERVER_H_