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

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

Issue 985773002: Introducing phased profiling framework (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@write_to_file
Patch Set: Fixing Android compile errors. 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.h
diff --git a/components/metrics/profiler/tracking_synchronizer.h b/components/metrics/profiler/tracking_synchronizer.h
index fefe8d9457eb7c9e91798261f890cf3b7c9590d6..590f3c32ad084e3bc9a78a57b6db0984d3ac406c 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
@@ -41,8 +43,9 @@ class TrackingSynchronizer
// Construction also sets up the global singleton instance. This instance is
// 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();
+ // already completed, and will not need this instance any further. |now| is
+ // the current time, but can be something else in tests.
+ explicit TrackingSynchronizer(base::TimeTicks now);
// 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 +66,8 @@ class TrackingSynchronizer
private:
friend class base::RefCountedThreadSafe<TrackingSynchronizer>;
+ // TODO(vadimt): Remove friending TrackingSynchronizerTest_ProfilerData_Test.
+ friend class TrackingSynchronizerTest_ProfilerData_Test;
class RequestContext;
@@ -75,7 +80,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 +89,14 @@ class TrackingSynchronizer
int RegisterAndNotifyAllProcesses(
const base::WeakPtr<TrackingSynchronizerObserver>& callback_object);
+ // Notify |observer| about |profiler_data| received from process of type
+ // |process_type|. |now| is the current time, but can be something else in
+ // tests.
+ void SendData(const tracked_objects::ProcessDataSnapshot& profiler_data,
+ content::ProcessType process_type,
+ base::TimeTicks now,
+ 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 +107,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 +122,20 @@ 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_;
+
+ // TODO(vadimt): consider moving 2 fields below to metrics service.
+ // 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);
};

Powered by Google App Engine
This is Rietveld 408576698