Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_COMMON_ORIGIN_TRIALS_CHROME_ORIGIN_TRIAL_POLICY_H_ | 5 #ifndef CHROME_INSTALLER_SETUP_PERSISTENT_HISTOGRAM_STORAGE_H_ |
| 6 #define CHROME_COMMON_ORIGIN_TRIALS_CHROME_ORIGIN_TRIAL_POLICY_H_ | 6 #define CHROME_INSTALLER_SETUP_PERSISTENT_HISTOGRAM_STORAGE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include "base/files/file_path.h" |
| 9 #include <string> | 9 #include "base/macros.h" |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 namespace installer { |
| 12 #include "base/strings/string_piece.h" | |
| 13 #include "content/public/common/origin_trial_policy.h" | |
| 14 | 12 |
| 15 // This class is instantiated on the main/ui thread, but its methods can be | 13 // When a PersistentHistogramStorage is destructed, histograms recorded during |
| 16 // accessed from any thread. | 14 // its lifetime are persisted in the directory set by set_storage_dir(). |
| 17 class ChromeOriginTrialPolicy : public content::OriginTrialPolicy { | 15 // Histograms are not persisted if set_storage_dir() has not been called or if |
| 16 // the storage directory does not exist on destruction. | |
| 17 // PersistentHistogramStorage should be instantiated as early as possible in the | |
| 18 // process lifetime and should never be instantiated again. Persisted histograms | |
| 19 // will eventually be reported by the browser process. | |
| 20 class PersistentHistogramStorage { | |
| 18 public: | 21 public: |
| 19 ChromeOriginTrialPolicy(); | 22 PersistentHistogramStorage(); |
| 20 ~ChromeOriginTrialPolicy() override; | 23 ~PersistentHistogramStorage(); |
| 21 | 24 |
| 22 // OriginTrialPolicy interface | 25 // Sets |storage_dir| as the directory in which histograms will be persisted |
| 23 base::StringPiece GetPublicKey() const override; | 26 // when this PersistentHistogramStorage is destructed. |
| 24 bool IsFeatureDisabled(base::StringPiece feature) const override; | 27 void set_storage_dir(const base::FilePath& storage_dir) { |
|
bcwhite
2016/09/13 19:53:53
You have set_storage_dir and GetStorageDir, only o
fdoray
2016/09/13 20:18:25
Done.
| |
| 28 storage_dir_ = storage_dir; | |
| 29 } | |
| 25 | 30 |
| 26 bool SetPublicKeyFromASCIIString(const std::string& ascii_public_key); | 31 // Returns a directory from which a product installed in |target_path| reports |
| 27 bool SetDisabledFeatures(const std::string& disabled_feature_list); | 32 // persisted histograms. Should be used as an argument to set_storage_dir(). |
| 33 static base::FilePath GetStorageDir(const base::FilePath& target_path); | |
| 28 | 34 |
| 29 private: | 35 private: |
| 30 std::string public_key_; | 36 base::FilePath storage_dir_; |
| 31 std::set<std::string> disabled_features_; | |
| 32 | 37 |
| 33 DISALLOW_COPY_AND_ASSIGN(ChromeOriginTrialPolicy); | 38 DISALLOW_COPY_AND_ASSIGN(PersistentHistogramStorage); |
| 34 }; | 39 }; |
| 35 | 40 |
| 36 #endif // CHROME_COMMON_ORIGIN_TRIALS_CHROME_ORIGIN_TRIAL_POLICY_H_ | 41 } // namespace installer |
| 42 | |
| 43 #endif // CHROME_INSTALLER_SETUP_PERSISTENT_HISTOGRAM_STORAGE_H_ | |
| OLD | NEW |