Index: chrome/browser/metrics/perf_provider_chromeos.h |
diff --git a/chrome/browser/metrics/perf_provider_chromeos.h b/chrome/browser/metrics/perf_provider_chromeos.h |
index 3bd0f467867821098f57d46ec3db82f149def38d..9b984cbd02064af9ff99366a3b0d5a254331bb3a 100644 |
--- a/chrome/browser/metrics/perf_provider_chromeos.h |
+++ b/chrome/browser/metrics/perf_provider_chromeos.h |
@@ -13,7 +13,7 @@ |
#include "base/time/time.h" |
#include "base/timer/timer.h" |
#include "chromeos/login/login_state.h" |
-#include "components/metrics/proto/perf_data.pb.h" |
+#include "components/metrics/proto/sampled_profile.pb.h" |
namespace metrics { |
@@ -27,9 +27,9 @@ class PerfProvider : public base::NonThreadSafe { |
PerfProvider(); |
~PerfProvider(); |
- // Writes collected perf data protobufs to |perf_data|. Clears all the stored |
- // perf data. Returns true if it wrote to |perf_data|. |
- bool GetPerfData(std::vector<PerfDataProto>* perf_data); |
+ // Stores collected perf data protobufs in |sampled_profiles|. Clears all the |
+ // stored profile data. Returns true if it wrote to |sampled_profiles|. |
+ bool GetSampledProfiles(std::vector<SampledProfile>* sampled_profiles); |
private: |
// Class that listens for changes to the login state. When a normal user logs |
@@ -48,35 +48,38 @@ class PerfProvider : public base::NonThreadSafe { |
PerfProvider* perf_provider_; |
}; |
- // Turns on perf collection. Resets the timer that's used to schedule |
+ // Turns on perf collection. Starts the timer that's used to schedule |
// collections. |
- void Activate(); |
+ void OnUserLoggedIn(); |
// Turns off perf collection. Does not delete any data that was already |
// collected and stored in |cached_perf_data_|. |
void Deactivate(); |
- // Starts an internal timer to start collecting perf data. The timer is set to |
- // trigger |interval| after this function call. |
- void ScheduleCollection(const base::TimeDelta& interval); |
+ // Selects a random time in the upcoming profiling interval that begins at |
+ // |next_profiling_interval_start_|. Schedules |timer_| to invoke |
+ // DoPeriodicCollection() when that time comes. |
+ void ScheduleCollection(); |
- // Collects perf data if it has not been consumed by calling GetPerfData() |
- // (see above). |
- void CollectIfNecessary(); |
+ // Collects perf data for a given |trigger_event|. Calls perf via the ChromeOS |
+ // debug daemon's dbus interface. |
+ void CollectIfNecessary(SampledProfile::TriggerEvent trigger_event); |
- // Collects perf data by calling CollectIfNecessary() and reschedules it to be |
- // collected again. |
- void CollectIfNecessaryAndReschedule(); |
+ // Collects perf data on a repeating basis by calling CollectIfNecessary() and |
+ // reschedules it to be collected again. |
+ void DoPeriodicCollection(); |
- // Parses a protobuf from the |data| passed in only if the |
+ // Parses a perf data protobuf from the |data| passed in only if the |
// |incognito_observer| indicates that no incognito window had been opened |
// during the profile collection period. |
+ // |trigger_event| is the cause of the perf data collection. |
void ParseProtoIfValid( |
scoped_ptr<WindowedIncognitoObserver> incognito_observer, |
+ SampledProfile::TriggerEvent trigger_event, |
const std::vector<uint8>& data); |
- // Vector of perf data protobufs. |
- std::vector<PerfDataProto> cached_perf_data_; |
+ // Vector of SampledProfile protobufs containing perf profiles. |
+ std::vector<SampledProfile> cached_perf_data_; |
// For scheduling collection of perf data. |
base::OneShotTimer<PerfProvider> timer_; |
@@ -84,6 +87,12 @@ class PerfProvider : public base::NonThreadSafe { |
// For detecting when changes to the login state. |
LoginObserver login_observer_; |
+ // Record of the last login time. |
+ base::TimeTicks login_time_; |
+ |
+ // Record of the start of the upcoming profiling interval. |
+ base::TimeTicks next_profiling_interval_start_; |
+ |
// To pass around the "this" pointer across threads safely. |
base::WeakPtrFactory<PerfProvider> weak_factory_; |