Chromium Code Reviews| Index: components/metrics/profiler/tracking_synchronizer.cc |
| diff --git a/components/metrics/profiler/tracking_synchronizer.cc b/components/metrics/profiler/tracking_synchronizer.cc |
| index 3a0a77c9b15ac4b95bcd3b9edfd9c6939992d422..f84602677cc2a8965f2ad608a76284bf1096724f 100644 |
| --- a/components/metrics/profiler/tracking_synchronizer.cc |
| +++ b/components/metrics/profiler/tracking_synchronizer.cc |
| @@ -227,6 +227,20 @@ void TrackingSynchronizer::FetchProfilerDataAsynchronously( |
| base::TimeDelta::FromMinutes(1)); |
| } |
| +// static |
| +void TrackingSynchronizer::OnProfilingPhaseCompletion( |
| + ProfilerEventProto::ProfilerEvent profiling_event) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
|
Ilya Sherman
2015/04/07 01:15:30
Throughout, please use DCHECK_CURRENTLY_ON
vadimt
2015/04/07 21:44:14
Done.
|
| + |
| + 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,20 +275,55 @@ 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, |
| + base::TimeTicks now) { |
| + phase_completion_events_sequence_.push_back(profiling_event); |
| + phase_start_times_.push_back(now); |
| +} |
| + |
| +void TrackingSynchronizer::NotifyAllProcessesOfProfilingPhaseCompletion( |
| + ProfilerEventProto::ProfilerEvent profiling_event) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + if (variations::GetVariationParamValue("UMALogUploadInterval", |
| + "send_split_profiles") != "true") { |
| + return; |
| + } |
| + |
| + int profiling_phase = phase_completion_events_sequence_.size(); |
| + |
| + RegisterPhaseCompletion(profiling_event, base::TimeTicks::Now()); |
| + |
| +#if !defined(OS_IOS) |
| + // Notify renderer and browser child processes. |
| + content::ProfilerController::GetInstance()->OnProfilingPhaseCompletion( |
| + profiling_phase); |
| +#endif |
| + |
| + // Notify browser process. |
| + tracked_objects::ThreadData::OnProfilingPhaseCompletion(profiling_phase); |
| +} |
| + |
| void TrackingSynchronizer::SendData( |
| const tracked_objects::ProcessDataSnapshot& profiler_data, |
| content::ProcessType process_type, |