Index: chrome/browser/metrics/perf/perf_provider_chromeos.h |
diff --git a/chrome/browser/metrics/perf/perf_provider_chromeos.h b/chrome/browser/metrics/perf/perf_provider_chromeos.h |
index 64b28d2330bbfb3f354df5942c47c6652d3f50bb..081f16dc124dca107ed92a954bb0417700472547 100644 |
--- a/chrome/browser/metrics/perf/perf_provider_chromeos.h |
+++ b/chrome/browser/metrics/perf/perf_provider_chromeos.h |
@@ -6,6 +6,7 @@ |
#define CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ |
#include <string> |
+#include <type_traits> |
Alexei Svitkine (slow)
2015/10/09 21:23:27
Out of curiosity, what's this for?
dhsharp
2015/10/09 21:33:18
Leftovers... I'll remove it.
I had been using:
s
|
#include <vector> |
#include "base/basictypes.h" |
@@ -35,6 +36,84 @@ class PerfProvider : public base::NonThreadSafe, |
bool GetSampledProfiles(std::vector<SampledProfile>* sampled_profiles); |
protected: |
+ typedef int64_t TimeDeltaInternalType; |
+ |
+ class CollectionParams { |
+ public: |
+ class TriggerParams { |
+ public: |
+ TriggerParams(int64_t sampling_factor, |
+ base::TimeDelta max_collection_delay); |
+ |
+ int64_t sampling_factor() const { return sampling_factor_; } |
+ void set_sampling_factor(int64_t factor) { sampling_factor_ = factor; } |
+ |
+ base::TimeDelta max_collection_delay() const { |
+ return base::TimeDelta::FromInternalValue(max_collection_delay_); |
+ } |
+ void set_max_collection_delay(base::TimeDelta delay) { |
+ max_collection_delay_ = delay.ToInternalValue(); |
+ } |
+ |
+ private: |
+ TriggerParams() = default; // POD |
+ |
+ // Limit the number of profiles collected. |
+ int64_t sampling_factor_; |
+ |
+ // Add a random delay before collecting after the trigger. |
+ // The delay should be randomly selected between 0 and this value. |
+ TimeDeltaInternalType max_collection_delay_; |
+ }; |
+ |
+ CollectionParams(base::TimeDelta collection_duration, |
+ base::TimeDelta periodic_interval, |
+ TriggerParams resume_from_suspend, |
+ TriggerParams restore_session); |
+ |
+ base::TimeDelta collection_duration() const { |
+ return base::TimeDelta::FromInternalValue(collection_duration_); |
+ } |
+ void set_collection_duration(base::TimeDelta duration) { |
+ collection_duration_ = duration.ToInternalValue(); |
+ } |
+ |
+ base::TimeDelta periodic_interval() const { |
+ return base::TimeDelta::FromInternalValue(periodic_interval_); |
+ } |
+ void set_periodic_interval(base::TimeDelta interval) { |
+ periodic_interval_ = interval.ToInternalValue(); |
+ } |
+ |
+ const TriggerParams& resume_from_suspend() const { |
+ return resume_from_suspend_; |
+ } |
+ TriggerParams* mutable_resume_from_suspend() { |
+ return &resume_from_suspend_; |
+ } |
+ const TriggerParams& restore_session() const { |
+ return restore_session_; |
+ } |
+ TriggerParams* mutable_restore_session() { |
+ return &restore_session_; |
+ } |
+ |
+ private: |
+ CollectionParams() = default; // POD |
+ |
+ // Time perf is run for. |
+ TimeDeltaInternalType collection_duration_; |
+ |
+ // For PERIODIC_COLLECTION, partition time since login into successive |
+ // intervals of this duration. In each interval, a random time is picked to |
+ // collect a profile. |
+ TimeDeltaInternalType periodic_interval_; |
+ |
+ // Parameters for RESUME_FROM_SUSPEND and RESTORE_SESSION collections: |
+ TriggerParams resume_from_suspend_; |
+ TriggerParams restore_session_; |
+ }; |
+ |
// Parses a PerfDataProto from serialized data |perf_data|, if it exists. |
// Parses a PerfStatProto from serialized data |perf_stat|, if it exists. |
// Only one of these may contain data. If both |perf_data| and |perf_stat| |
@@ -53,6 +132,8 @@ class PerfProvider : public base::NonThreadSafe, |
const std::vector<uint8>& perf_stat); |
private: |
+ static const CollectionParams kDefaultParameters; |
+ |
// Class that listens for changes to the login state. When a normal user logs |
// in, it updates PerfProvider to start collecting data. |
class LoginObserver : public chromeos::LoginState::Observer { |
@@ -111,6 +192,9 @@ class PerfProvider : public base::NonThreadSafe, |
const base::TimeDelta& time_after_restore, |
int num_tabs_restored); |
+ // Parameters controlling how profiles are collected. |
+ CollectionParams collection_params_; |
+ |
// Vector of SampledProfile protobufs containing perf profiles. |
std::vector<SampledProfile> cached_perf_data_; |