Chromium Code Reviews| Index: components/metrics/profiler/tracking_synchronizer.h |
| diff --git a/components/metrics/profiler/tracking_synchronizer.h b/components/metrics/profiler/tracking_synchronizer.h |
| index fefe8d9457eb7c9e91798261f890cf3b7c9590d6..c7e87e3a2a025bb7c5d80d7cb7ac5195a2209283 100644 |
| --- a/components/metrics/profiler/tracking_synchronizer.h |
| +++ b/components/metrics/profiler/tracking_synchronizer.h |
| @@ -13,6 +13,8 @@ |
| #include "base/lazy_instance.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/time/time.h" |
| +#include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
| #include "content/public/browser/profiler_subscriber.h" |
| // This class maintains state that is used to upload profiler data from the |
| @@ -42,7 +44,7 @@ class TrackingSynchronizer |
| // used to communicate between the IO and UI thread, and is destroyed only as |
| // the main thread (browser_main) terminates, which means the IO thread has |
| // already completed, and will not need this instance any further. |
| - TrackingSynchronizer(); |
| + TrackingSynchronizer(const base::TimeTicks& current_time); |
|
Ilya Sherman
2015/03/14 00:20:35
nit: explicit
vadimt
2015/03/14 01:39:15
Done.
|
| // Contact all processes, and get them to upload to the browser any/all |
| // changes to profiler data. It calls |callback_object|'s SetData method with |
| @@ -63,6 +65,7 @@ class TrackingSynchronizer |
| private: |
| friend class base::RefCountedThreadSafe<TrackingSynchronizer>; |
| + friend class TrackingSynchronizerTest_ProfilerData_Test; |
|
Ilya Sherman
2015/03/14 00:20:35
Please use protected methods rather than friending
vadimt
2015/03/14 01:39:15
Promising to do in the next CL.
The code is not co
|
| class RequestContext; |
| @@ -75,7 +78,7 @@ class TrackingSynchronizer |
| void OnProfilerDataCollected( |
| int sequence_number, |
| const tracked_objects::ProcessDataSnapshot& profiler_data, |
| - int process_type) override; |
| + content::ProcessType process_type) override; |
| // Establish a new sequence_number_, and use it to notify all the processes of |
| // the need to supply, to the browser, their tracking data. It also registers |
| @@ -84,6 +87,13 @@ class TrackingSynchronizer |
| int RegisterAndNotifyAllProcesses( |
| const base::WeakPtr<TrackingSynchronizerObserver>& callback_object); |
| + // Notify |observer| about |profiler_data| received from process of type |
| + // |process_type|. |
| + void SendData(const tracked_objects::ProcessDataSnapshot& profiler_data, |
| + content::ProcessType process_type, |
| + const base::TimeTicks& current_time, |
| + TrackingSynchronizerObserver* observer) const; |
| + |
| // It finds the RequestContext for the given |sequence_number| and notifies |
| // the RequestContext's |callback_object_| about the |value|. This is called |
| // whenever we receive profiler data from processes. It also records that we |
| @@ -94,7 +104,7 @@ class TrackingSynchronizer |
| void DecrementPendingProcessesAndSendData( |
| int sequence_number, |
| const tracked_objects::ProcessDataSnapshot& profiler_data, |
| - int process_type); |
| + content::ProcessType process_type); |
| // Get a new sequence number to be sent to processes from browser process. |
| // This method is accessible on UI thread. |
| @@ -109,6 +119,19 @@ class TrackingSynchronizer |
| // reuse for a long time). |
| int last_used_sequence_number_; |
| + // Sequence of events associated with already completed profiling phases. The |
| + // index in the vector is the phase number. The current phase is not included. |
| + std::vector<ProfilerEventProto::ProfilerEvent> |
| + phase_completion_events_sequence_; |
| + |
| + // Time of the profiling start. Used to calculate times of phase change |
| + // moments relative to this value. |
| + const base::TimeTicks start_time_; |
| + |
| + // Times of starts of all profiling phases, including the current phase. The |
| + // index in the vector is the phase number. |
| + std::vector<base::TimeTicks> phase_start_times_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizer); |
| }; |