| Index: components/metrics/profiler/tracking_synchronizer.cc
|
| diff --git a/components/metrics/profiler/tracking_synchronizer.cc b/components/metrics/profiler/tracking_synchronizer.cc
|
| index ad3644195f2a9236851b6aa1706f47b420d1ce92..dc689c1cc33ded7a515154b8c422314dea7b93b6 100644
|
| --- a/components/metrics/profiler/tracking_synchronizer.cc
|
| +++ b/components/metrics/profiler/tracking_synchronizer.cc
|
| @@ -180,11 +180,13 @@ base::LazyInstance
|
|
|
| // TrackingSynchronizer methods and members.
|
|
|
| -TrackingSynchronizer::TrackingSynchronizer(base::TimeTicks now)
|
| - : last_used_sequence_number_(kNeverUsableSequenceNumber), start_time_(now) {
|
| +TrackingSynchronizer::TrackingSynchronizer(base::TickClock* clock)
|
| + : last_used_sequence_number_(kNeverUsableSequenceNumber),
|
| + clock_(clock),
|
| + start_time_(clock->NowTicks()) {
|
| DCHECK(!g_tracking_synchronizer);
|
| g_tracking_synchronizer = this;
|
| - phase_start_times_.push_back(now);
|
| + phase_start_times_.push_back(start_time_);
|
|
|
| #if !defined(OS_IOS)
|
| // TODO: This ifdef and other ifdefs for OS_IOS in this file are only
|
| @@ -227,6 +229,20 @@ void TrackingSynchronizer::FetchProfilerDataAsynchronously(
|
| base::TimeDelta::FromMinutes(1));
|
| }
|
|
|
| +// static
|
| +void TrackingSynchronizer::OnProfilingPhaseCompleted(
|
| + ProfilerEventProto::ProfilerEvent profiling_event) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + if (!g_tracking_synchronizer) {
|
| + // System teardown is happening.
|
| + return;
|
| + }
|
| +
|
| + g_tracking_synchronizer->NotifyAllProcessesOfProfilingPhaseCompletion(
|
| + profiling_event);
|
| +}
|
| +
|
| void TrackingSynchronizer::OnPendingProcesses(int sequence_number,
|
| int pending_processes,
|
| bool end) {
|
| @@ -261,24 +277,57 @@ int TrackingSynchronizer::RegisterAndNotifyAllProcesses(
|
| // Increment pending process count for sending browser's profiler data.
|
| request->IncrementProcessesPending();
|
|
|
| + int current_profiling_phase = phase_completion_events_sequence_.size();
|
| +
|
| #if !defined(OS_IOS)
|
| // Get profiler data from renderer and browser child processes.
|
| - content::ProfilerController::GetInstance()->GetProfilerData(sequence_number);
|
| + content::ProfilerController::GetInstance()->GetProfilerData(
|
| + sequence_number, current_profiling_phase);
|
| #endif
|
|
|
| // Send process data snapshot from browser process.
|
| tracked_objects::ProcessDataSnapshot process_data_snapshot;
|
| - tracked_objects::ThreadData::Snapshot(&process_data_snapshot);
|
| + tracked_objects::ThreadData::Snapshot(current_profiling_phase,
|
| + &process_data_snapshot);
|
| +
|
| DecrementPendingProcessesAndSendData(sequence_number, process_data_snapshot,
|
| content::PROCESS_TYPE_BROWSER);
|
|
|
| return sequence_number;
|
| }
|
|
|
| +void TrackingSynchronizer::RegisterPhaseCompletion(
|
| + ProfilerEventProto::ProfilerEvent profiling_event) {
|
| + phase_completion_events_sequence_.push_back(profiling_event);
|
| + phase_start_times_.push_back(clock_->NowTicks());
|
| +}
|
| +
|
| +void TrackingSynchronizer::NotifyAllProcessesOfProfilingPhaseCompletion(
|
| + ProfilerEventProto::ProfilerEvent profiling_event) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + if (variations::GetVariationParamValue("UMALogUploadInterval",
|
| + "send_split_profiles") != "true") {
|
| + return;
|
| + }
|
| +
|
| + int profiling_phase = phase_completion_events_sequence_.size();
|
| +
|
| + RegisterPhaseCompletion(profiling_event);
|
| +
|
| +#if !defined(OS_IOS)
|
| + // Notify renderer and browser child processes.
|
| + content::ProfilerController::GetInstance()->OnProfilingPhaseCompleted(
|
| + profiling_phase);
|
| +#endif
|
| +
|
| + // Notify browser process.
|
| + tracked_objects::ThreadData::OnProfilingPhaseCompleted(profiling_phase);
|
| +}
|
| +
|
| void TrackingSynchronizer::SendData(
|
| const tracked_objects::ProcessDataSnapshot& profiler_data,
|
| content::ProcessType process_type,
|
| - base::TimeTicks now,
|
| TrackingSynchronizerObserver* observer) const {
|
| // We are going to loop though past profiling phases and notify the request
|
| // about each phase that is contained in profiler_data. past_events
|
| @@ -299,7 +348,7 @@ void TrackingSynchronizer::SendData(
|
| phase_start_times_[phase] - start_time_;
|
| const base::TimeDelta phase_finish =
|
| (phase + 1 < phase_start_times_.size() ? phase_start_times_[phase + 1]
|
| - : now) -
|
| + : clock_->NowTicks()) -
|
| start_time_;
|
| observer->ReceivedProfilerData(it->second, profiler_data.process_id,
|
| process_type, phase, phase_start,
|
| @@ -324,7 +373,7 @@ void TrackingSynchronizer::DecrementPendingProcessesAndSendData(
|
|
|
| TrackingSynchronizerObserver* observer = request->callback_object_.get();
|
| if (observer)
|
| - SendData(profiler_data, process_type, base::TimeTicks::Now(), observer);
|
| + SendData(profiler_data, process_type, observer);
|
|
|
| // Delete request if we have heard back from all child processes.
|
| request->DecrementProcessesPending();
|
|
|