Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_INSTALLER_UTIL_EXPERIMENT_H_ | |
| 6 #define CHROME_INSTALLER_UTIL_EXPERIMENT_H_ | |
| 7 | |
| 8 #include "base/time/time.h" | |
| 9 #include "chrome/installer/util/experiment_metrics.h" | |
| 10 | |
| 11 namespace installer { | |
| 12 | |
| 13 class ExperimentStorage; | |
| 14 | |
| 15 // The experiment state for the current user. Experiment state is a combination | |
| 16 // of the per-install ExperimentMetrics and the per-user experiment data. | |
| 17 class Experiment { | |
| 18 public: | |
| 19 Experiment(); | |
| 20 Experiment(Experiment&&); | |
| 21 Experiment(const Experiment&); | |
| 22 ~Experiment(); | |
| 23 Experiment& operator=(Experiment&&) = default; | |
| 24 Experiment& operator=(const Experiment&) = default; | |
| 25 | |
| 26 // Initializes this instance based on |metrics|. | |
| 27 void InitializeFromMetrics(const ExperimentMetrics& metrics); | |
| 28 | |
| 29 // Moves this user into |state|, updating metrics as appropriate. | |
| 30 void SetState(ExperimentMetrics::State state); | |
| 31 | |
| 32 // Assigns this user to |group|. | |
| 33 void AssignGroup(int group); | |
| 34 | |
| 35 // Setters for storing data relating to experiment. These should only be | |
| 36 // called if the experiment is between initial and terminal states. | |
| 37 | |
| 38 // Fill toast location value. | |
| 39 void SetToastLocation(ExperimentMetrics::ToastLocation location); | |
| 40 | |
| 41 // Fill number of days user was inactive before toast was shown. | |
| 42 void SetInactiveDays(int days); | |
| 43 | |
| 44 // Fill number of times toast was displayed. | |
| 45 void SetToastCount(int count); | |
| 46 | |
| 47 // Fill fine grained timestamp for first time the toast was shown. | |
| 48 void SetDisplayTime(const base::Time& time); | |
| 49 | |
| 50 // Time delta between user session start and toast display. | |
| 51 void SetUserSessionUptime(const base::TimeDelta& time_delta); | |
| 52 | |
| 53 // Time delta between user session start and action taken on toast display. | |
|
grt (UTC plus 2)
2017/05/31 12:24:09
this is the delta between presentation and action,
nikunjb
2017/06/02 05:11:23
Done.
| |
| 54 void SetActionDelay(const base::TimeDelta& time_delta); | |
| 55 | |
| 56 const ExperimentMetrics& metrics() const { return metrics_; } | |
| 57 | |
| 58 ExperimentMetrics::State state() const { return state_; } | |
| 59 | |
| 60 int group() const { return group_; } | |
| 61 | |
| 62 ExperimentMetrics::ToastLocation toast_location() const { | |
| 63 return toast_location_; | |
| 64 } | |
| 65 | |
| 66 int inactive_days() const { return inactive_days_; } | |
| 67 | |
| 68 int toast_count() const { return toast_count_; } | |
| 69 | |
| 70 const base::Time& first_display_time() const { return first_display_time_; } | |
| 71 | |
| 72 const base::Time& latest_display_time() const { return latest_display_time_; } | |
| 73 | |
| 74 const base::TimeDelta& user_session_uptime() const { | |
| 75 return user_session_uptime_; | |
| 76 } | |
| 77 | |
| 78 const base::TimeDelta& action_delay() const { return action_delay_; } | |
| 79 | |
| 80 private: | |
| 81 friend class ExperimentStorage; | |
| 82 | |
| 83 ExperimentMetrics metrics_ = ExperimentMetrics(); | |
| 84 ExperimentMetrics::State state_ = ExperimentMetrics::kUninitialized; | |
| 85 int group_ = 0; | |
| 86 ExperimentMetrics::ToastLocation toast_location_ = | |
| 87 ExperimentMetrics::kOverTaskbarPin; | |
| 88 int inactive_days_ = 0; | |
| 89 int toast_count_ = 0; | |
| 90 base::Time first_display_time_; | |
| 91 base::Time latest_display_time_; | |
| 92 base::TimeDelta user_session_uptime_; | |
| 93 base::TimeDelta action_delay_; | |
|
grt (UTC plus 2)
2017/05/31 12:24:09
hmm, i'm not sure why i called this action_delay_
nikunjb
2017/06/02 05:11:22
The name of registry key is ActionDelay, so, I lik
| |
| 94 }; | |
| 95 | |
| 96 } // namespace installer | |
| 97 | |
| 98 #endif // CHROME_INSTALLER_UTIL_EXPERIMENT_H_ | |
| OLD | NEW |