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

Side by Side Diff: chrome/installer/util/experiment_storage.h

Issue 2933043002: Installer support for Windows 10 inactive user toast. (Closed)
Patch Set: review feedback Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/installer/util/experiment_metrics.h ('k') | chrome/installer/util/experiment_storage.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_INSTALLER_UTIL_EXPERIMENT_STORAGE_H_ 5 #ifndef CHROME_INSTALLER_UTIL_EXPERIMENT_STORAGE_H_
6 #define CHROME_INSTALLER_UTIL_EXPERIMENT_STORAGE_H_ 6 #define CHROME_INSTALLER_UTIL_EXPERIMENT_STORAGE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/win/scoped_handle.h" 12 #include "base/win/scoped_handle.h"
13 13
14 namespace installer { 14 namespace installer {
15 15
16 class Experiment; 16 class Experiment;
17 struct ExperimentMetrics; 17 struct ExperimentMetrics;
18 18
19 // Manages the storage of experiment state on the machine. 19 // Manages the storage of experiment state on the machine.
20 // 20 //
21 // Participation is a per-install property evaluated one time to determine 21 // Participation is a per-install property evaluated one time to determine which
22 // whether or not the install as a whole participates in the study. It is 22 // study the client participates in. It is stored in the install's ClientState
23 // stored in the install's ClientState key. 23 // key.
24 // 24 //
25 // ExperimentMetrics are stored in a per-install experiment_label, while the 25 // ExperimentMetrics are stored in a per-install experiment_label, while the
26 // fine-grained Experiment data are stored in a per-user key in Chrome's 26 // fine-grained Experiment data are stored in a per-user key in Chrome's
27 // ClientState or ClientStateMedium key. For system-level installs, metrics are 27 // ClientState or ClientStateMedium key. For system-level installs, metrics are
28 // reported for only a single user on the machine, so only that one user will 28 // reported for only a single user on the machine, so only that one user will
29 // participate in the experiment. 29 // participate in the experiment.
30 // 30 //
31 // Owing to this "metrics are per-install" property in the face of potentially 31 // Owing to this "metrics are per-install" property in the face of potentially
32 // multiple users running the same install, ExperimentMetrics are considered the 32 // multiple users running the same install, ExperimentMetrics are considered the
33 // source of truth for an install's participation in the experiment. For any 33 // source of truth for an install's participation in the experiment. For any
34 // given state expressed in the experiment_label holding these metrics, there 34 // given state expressed in the experiment_label holding these metrics, there
35 // should be matching Experiment data for precisely one user. 35 // should be matching Experiment data for precisely one user.
36 // 36 //
37 // As state is written across multiple locations in the registry, a global 37 // As state is written across multiple locations in the registry, a global
38 // mutex is used for all reads and writes to ensure consistent state. 38 // mutex is used for all reads and writes to ensure consistent state.
39 class ExperimentStorage { 39 class ExperimentStorage {
40 public: 40 public:
41 enum class Participation { 41 // An identifier of which study the install participates in.
42 // No participation state was found for the install. 42 enum Study : uint32_t {
43 kNotEvaluated, 43 kNoStudySelected = 0,
44 44 kStudyOne = 1,
45 // The client is not participating in the study. 45 kStudyTwo = 2,
46 kNotParticipating,
47
48 // The client is participating in the study.
49 kIsParticipating,
50 }; 46 };
51 47
52 // Grants the holder exclusive access to the data in the registry. Consumers 48 // Grants the holder exclusive access to the data in the registry. Consumers
53 // are expected to not hold an instance across any blocking operations. 49 // are expected to not hold an instance across any blocking operations.
54 class Lock { 50 class Lock {
55 public: 51 public:
56 ~Lock(); 52 ~Lock();
57 53
58 // Reads the participation state for the install. Returns false in case of 54 // Reads the participation state for the install. Returns false in case of
59 // error. 55 // error. |participation| is set to kNotEvaluated if no value is present;
60 bool ReadParticipation(Participation* participation); 56 // otherwise, it is set to the value found.
57 bool ReadParticipation(Study* participation);
61 58
62 // Writes the participation state for the install. Returns false if the 59 // Writes the participation state for the install. Returns false if the
63 // write failed. 60 // write failed.
64 bool WriteParticipation(Participation participation); 61 bool WriteParticipation(Study participation);
65 62
66 // Loads the experiment metrics and data from the registry. Returns false if 63 // Loads the experiment metrics and data from the registry. Returns false if
67 // the state in the registry corresponds to a different user or could not be 64 // the state in the registry corresponds to a different user or could not be
68 // read. 65 // read.
69 bool LoadExperiment(Experiment* experiment); 66 bool LoadExperiment(Experiment* experiment);
70 67
71 // Stores the experiment metrics and data in |experiment| into the registry. 68 // Stores the experiment metrics and data in |experiment| into the registry.
72 bool StoreExperiment(const Experiment& experiment); 69 bool StoreExperiment(const Experiment& experiment);
73 70
74 // Loads per-install experiment metrics into |metrics|. Returns true if a 71 // Loads per-install experiment metrics into |metrics|. Returns true if a
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 140
144 // A global mutex with a distinct name for the current installation. 141 // A global mutex with a distinct name for the current installation.
145 base::win::ScopedHandle mutex_; 142 base::win::ScopedHandle mutex_;
146 143
147 DISALLOW_COPY_AND_ASSIGN(ExperimentStorage); 144 DISALLOW_COPY_AND_ASSIGN(ExperimentStorage);
148 }; 145 };
149 146
150 } // namespace installer 147 } // namespace installer
151 148
152 #endif // CHROME_INSTALLER_UTIL_EXPERIMENT_STORAGE_H_ 149 #endif // CHROME_INSTALLER_UTIL_EXPERIMENT_STORAGE_H_
OLDNEW
« no previous file with comments | « chrome/installer/util/experiment_metrics.h ('k') | chrome/installer/util/experiment_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698