Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: components/metrics/profiler/tracking_synchronizer.h

Issue 1021053003: Delivering the FIRST_NONEMPTY_PAINT phase changing event to base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@phase_splitting
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_ 5 #ifndef COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_
6 #define COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_ 6 #define COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // the current time, but can be something else in tests. 47 // the current time, but can be something else in tests.
48 explicit TrackingSynchronizer(const base::TimeTicks& now); 48 explicit TrackingSynchronizer(const base::TimeTicks& now);
49 49
50 // Contact all processes, and get them to upload to the browser any/all 50 // Contact all processes, and get them to upload to the browser any/all
51 // changes to profiler data. It calls |callback_object|'s SetData method with 51 // changes to profiler data. It calls |callback_object|'s SetData method with
52 // the data received from each sub-process. 52 // the data received from each sub-process.
53 // This method is accessible on UI thread. 53 // This method is accessible on UI thread.
54 static void FetchProfilerDataAsynchronously( 54 static void FetchProfilerDataAsynchronously(
55 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object); 55 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object);
56 56
57 // Called when a profiling phase completes. |profiling_event| is the event
58 // associated with completing the phase and starting a new one.
59 static void OnProfilingPhaseCompletion(
60 ProfilerEventProto::ProfilerEvent profiling_event);
61
57 // ------------------------------------------------------ 62 // ------------------------------------------------------
58 // ProfilerSubscriber methods for browser child processes 63 // ProfilerSubscriber methods for browser child processes
59 // ------------------------------------------------------ 64 // ------------------------------------------------------
60 65
61 // Update the number of pending processes for the given |sequence_number|. 66 // Update the number of pending processes for the given |sequence_number|.
62 // This is called on UI thread. 67 // This is called on UI thread.
63 void OnPendingProcesses(int sequence_number, 68 void OnPendingProcesses(int sequence_number,
64 int pending_processes, 69 int pending_processes,
65 bool end) override; 70 bool end) override;
66 71
72 protected:
73 ~TrackingSynchronizer() override;
74
75 // Update the sequence of completed phases with a new phase completion info.
76 // |now| is the current time, but can be something else in tests.
77 void RegisterPhaseCompletion(
78 ProfilerEventProto::ProfilerEvent profiling_event,
79 const base::TimeTicks& now);
80
81 // Notify |observer| about |profiler_data| received from process of type
82 // |process_type|. |now| is the current time, but can be something else in
83 // tests.
84 void SendData(const tracked_objects::ProcessDataSnapshot& profiler_data,
85 content::ProcessType process_type,
86 const base::TimeTicks& now,
87 TrackingSynchronizerObserver* observer) const;
88
67 private: 89 private:
68 friend class base::RefCountedThreadSafe<TrackingSynchronizer>; 90 friend class base::RefCountedThreadSafe<TrackingSynchronizer>;
69 // TODO(vadimt): Remove friending TrackingSynchronizerTest_ProfilerData_Test.
70 friend class TrackingSynchronizerTest_ProfilerData_Test;
71 91
72 class RequestContext; 92 class RequestContext;
73 93
74 ~TrackingSynchronizer() override;
75
76 // Send profiler_data back to callback_object_ by calling 94 // Send profiler_data back to callback_object_ by calling
77 // DecrementPendingProcessesAndSendData which records that we are waiting 95 // DecrementPendingProcessesAndSendData which records that we are waiting
78 // for one less profiler data from renderer or browser child process for the 96 // for one less profiler data from renderer or browser child process for the
79 // given sequence number. This method is accessible on UI thread. 97 // given sequence number. This method is accessible on UI thread.
80 void OnProfilerDataCollected( 98 void OnProfilerDataCollected(
81 int sequence_number, 99 int sequence_number,
82 const tracked_objects::ProcessDataSnapshot& profiler_data, 100 const tracked_objects::ProcessDataSnapshot& profiler_data,
83 content::ProcessType process_type) override; 101 content::ProcessType process_type) override;
84 102
85 // Establish a new sequence_number_, and use it to notify all the processes of 103 // Establish a new sequence_number_, and use it to notify all the processes of
86 // the need to supply, to the browser, their tracking data. It also registers 104 // the need to supply, to the browser, their tracking data. It also registers
87 // |callback_object| in |outstanding_requests_| map. Return the 105 // |callback_object| in |outstanding_requests_| map. Return the
88 // sequence_number_ that was used. This method is accessible on UI thread. 106 // sequence_number_ that was used. This method is accessible on UI thread.
89 int RegisterAndNotifyAllProcesses( 107 int RegisterAndNotifyAllProcesses(
90 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object); 108 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object);
91 109
92 // Notify |observer| about |profiler_data| received from process of type 110 // Notifies all processes of a completion of a profiling phase.
93 // |process_type|. |now| is the current time, but can be something else in 111 // |profiling_event| is the event associated with the phase change.
94 // tests. 112 void NotifyAllProcessesOfProfilingPhaseCompletion(
95 void SendData(const tracked_objects::ProcessDataSnapshot& profiler_data, 113 ProfilerEventProto::ProfilerEvent profiling_event);
96 content::ProcessType process_type,
97 const base::TimeTicks& now,
98 TrackingSynchronizerObserver* observer) const;
99 114
100 // It finds the RequestContext for the given |sequence_number| and notifies 115 // It finds the RequestContext for the given |sequence_number| and notifies
101 // the RequestContext's |callback_object_| about the |value|. This is called 116 // the RequestContext's |callback_object_| about the |value|. This is called
102 // whenever we receive profiler data from processes. It also records that we 117 // whenever we receive profiler data from processes. It also records that we
103 // are waiting for one less profiler data from a process for the given 118 // are waiting for one less profiler data from a process for the given
104 // sequence number. If we have received a response from all renderers and 119 // sequence number. If we have received a response from all renderers and
105 // browser processes, then it calls RequestContext's DeleteIfAllDone to delete 120 // browser processes, then it calls RequestContext's DeleteIfAllDone to delete
106 // the entry for sequence_number. This method is accessible on UI thread. 121 // the entry for sequence_number. This method is accessible on UI thread.
107 void DecrementPendingProcessesAndSendData( 122 void DecrementPendingProcessesAndSendData(
108 int sequence_number, 123 int sequence_number,
(...skipping 11 matching lines...) Expand all
120 // requests. All sequence numbers used are non-negative. 135 // requests. All sequence numbers used are non-negative.
121 // last_used_sequence_number_ is the most recently used number (used to avoid 136 // last_used_sequence_number_ is the most recently used number (used to avoid
122 // reuse for a long time). 137 // reuse for a long time).
123 int last_used_sequence_number_; 138 int last_used_sequence_number_;
124 139
125 // Sequence of events associated with already completed profiling phases. The 140 // Sequence of events associated with already completed profiling phases. The
126 // index in the vector is the phase number. The current phase is not included. 141 // index in the vector is the phase number. The current phase is not included.
127 std::vector<ProfilerEventProto::ProfilerEvent> 142 std::vector<ProfilerEventProto::ProfilerEvent>
128 phase_completion_events_sequence_; 143 phase_completion_events_sequence_;
129 144
130 // TODO(vadimt): consider moving 2 fields below to metrics service.
131 // Time of the profiling start. Used to calculate times of phase change 145 // Time of the profiling start. Used to calculate times of phase change
132 // moments relative to this value. 146 // moments relative to this value.
133 const base::TimeTicks start_time_; 147 const base::TimeTicks start_time_;
134 148
135 // Times of starts of all profiling phases, including the current phase. The 149 // Times of starts of all profiling phases, including the current phase. The
136 // index in the vector is the phase number. 150 // index in the vector is the phase number.
137 std::vector<base::TimeTicks> phase_start_times_; 151 std::vector<base::TimeTicks> phase_start_times_;
138 152
139 DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizer); 153 DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizer);
140 }; 154 };
141 155
142 } // namespace metrics 156 } // namespace metrics
143 157
144 #endif // COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_ 158 #endif // COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/first_web_contents_profiler.cc ('k') | components/metrics/profiler/tracking_synchronizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698