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

Unified Diff: components/metrics/profiler/tracking_synchronizer.cc

Issue 985773002: Introducing phased profiling framework (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@write_to_file
Patch Set: Only "API" 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/profiler/tracking_synchronizer.cc
diff --git a/components/metrics/profiler/tracking_synchronizer.cc b/components/metrics/profiler/tracking_synchronizer.cc
index 8d53bd2a7ec19f42df2336cd968f5dcf49eb89b2..501b2cd409d521b03089335093591b1eb25b6ce5 100644
--- a/components/metrics/profiler/tracking_synchronizer.cc
+++ b/components/metrics/profiler/tracking_synchronizer.cc
@@ -9,6 +9,7 @@
#include "base/threading/thread.h"
#include "base/tracked_objects.h"
#include "components/metrics/profiler/tracking_synchronizer_observer.h"
+#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/profiler_controller.h"
#include "content/public/common/process_type.h"
@@ -180,9 +181,11 @@ base::LazyInstance
// TrackingSynchronizer methods and members.
TrackingSynchronizer::TrackingSynchronizer()
- : last_used_sequence_number_(kNeverUsableSequenceNumber) {
+ : last_used_sequence_number_(kNeverUsableSequenceNumber),
+ start_time_(base::TimeTicks::Now()) {
DCHECK(!g_tracking_synchronizer);
g_tracking_synchronizer = this;
+ phase_start_times_.push_back(base::TimeTicks::Now());
content::ProfilerController::GetInstance()->Register(this);
}
@@ -253,10 +256,10 @@ int TrackingSynchronizer::RegisterAndNotifyAllProcesses(
// Get profiler data from renderer and browser child processes.
content::ProfilerController::GetInstance()->GetProfilerData(sequence_number);
- // Send profiler_data from browser process.
- tracked_objects::ProcessDataSnapshot process_data;
- tracked_objects::ThreadData::Snapshot(&process_data);
- DecrementPendingProcessesAndSendData(sequence_number, process_data,
+ // Send process_data_snapshot from browser process.
Alexei Svitkine (slow) 2015/03/09 17:13:35 Nit: surround in |'s or remove _'s.
vadimt 2015/03/13 23:18:01 Done.
+ tracked_objects::ProcessDataSnapshot process_data_snapshot;
+ tracked_objects::ThreadData::GetProcessDataSnapshot(&process_data_snapshot);
+ DecrementPendingProcessesAndSendData(sequence_number, process_data_snapshot,
content::PROCESS_TYPE_BROWSER);
return sequence_number;
@@ -273,8 +276,39 @@ void TrackingSynchronizer::DecrementPendingProcessesAndSendData(
return;
if (request->callback_object_.get()) {
- request->callback_object_
- ->ReceivedProfilerData(profiler_data, process_type);
+ // We are going to loop though past profiling phases and notify the request
+ // about each phase that is contained in profiler_data. past_profiler_events
+ // will track the set of past profiling events as we go.
+ ProfilerEventsSet past_profiler_events;
+
+ // Go though all completed phases, and though the current one. The current
Ilya Sherman 2015/03/10 00:48:10 nit: "though" -> "through" (twice)
vadimt 2015/03/13 23:18:01 Done.
+ // one is not in phase_completion_events_sequence_, but note the <=
+ // comparison.
Alexei Svitkine (slow) 2015/03/09 17:13:35 This logic seems sufficiently non trivial to warra
vadimt 2015/03/13 23:18:01 Done.
+ for (size_t phase = 0; phase <= phase_completion_events_sequence_.size();
+ ++phase) {
+ tracked_objects::PhasedProcessDataSnapshots::const_iterator it =
+ profiler_data.phased_process_data_snapshots.find(phase);
+
+ if (it != profiler_data.phased_process_data_snapshots.end()) {
+ // If the phase is contained in the received snapshot, notify the
+ // request.
+ const base::TimeDelta phase_start =
+ phase_start_times_[phase] - start_time_;
+ const base::TimeDelta phase_finish =
+ (phase + 1 < phase_start_times_.size()
+ ? phase_start_times_[phase + 1]
+ : base::TimeTicks::Now()) -
+ start_time_;
+ request->callback_object_->ReceivedProfilerData(
+ it->second, profiler_data.process_id, process_type, phase,
+ phase_start, phase_finish, past_profiler_events);
+ }
+
+ if (phase != phase_completion_events_sequence_.size()) {
+ past_profiler_events.push_back(
+ phase_completion_events_sequence_[phase]);
+ }
+ }
}
// Delete request if we have heard back from all child processes.

Powered by Google App Engine
This is Rietveld 408576698