| 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 SERVICES_PREFERENCES_TRACKED_REGISTRY_HASH_STORE_CONTENTS_WIN_H_ | 5 #ifndef SERVICES_PREFERENCES_TRACKED_REGISTRY_HASH_STORE_CONTENTS_WIN_H_ |
| 6 #define SERVICES_PREFERENCES_TRACKED_REGISTRY_HASH_STORE_CONTENTS_WIN_H_ | 6 #define SERVICES_PREFERENCES_TRACKED_REGISTRY_HASH_STORE_CONTENTS_WIN_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "services/preferences/tracked/hash_store_contents.h" | 10 #include "services/preferences/tracked/hash_store_contents.h" |
| 11 #include "services/preferences/tracked/temp_scoped_dir_cleaner.h" |
| 12 |
| 13 // Helper object to clear registry entries for scoped temporary pref stores. |
| 14 class TempScopedDirRegistryCleaner : public TempScopedDirCleaner { |
| 15 public: |
| 16 void SetRegistryPath(const base::string16& registry_path); |
| 17 |
| 18 private: |
| 19 friend class base::RefCountedThreadSafe<TempScopedDirRegistryCleaner>; |
| 20 ~TempScopedDirRegistryCleaner() override; |
| 21 |
| 22 base::string16 registry_path_; |
| 23 }; |
| 11 | 24 |
| 12 // Implements HashStoreContents by storing MACs in the Windows registry. | 25 // Implements HashStoreContents by storing MACs in the Windows registry. |
| 13 class RegistryHashStoreContentsWin : public HashStoreContents { | 26 class RegistryHashStoreContentsWin : public HashStoreContents { |
| 14 public: | 27 public: |
| 15 // Constructs a RegistryHashStoreContents which acts on a registry entry | 28 // Constructs a RegistryHashStoreContents which acts on a registry entry |
| 16 // defined by |registry_path| and |store_key|. If |store_key| begins with | 29 // defined by |registry_path| and |store_key|. |
| 17 // base::ScopedTempDir::GetTempDirPrefix(), this RegistryHashStoreContentsWin | 30 explicit RegistryHashStoreContentsWin( |
| 18 // will self Reset() on destruction to avoid proliferating keys in tests that | 31 const base::string16& registry_path, |
| 19 // create a profile in a ScopedTempDir (https://crbug.com/721245). | 32 const base::string16& store_key, |
| 20 explicit RegistryHashStoreContentsWin(const base::string16& registry_path, | 33 scoped_refptr<TempScopedDirCleaner> temp_dir_cleaner); |
| 21 const base::string16& store_key); | |
| 22 | |
| 23 ~RegistryHashStoreContentsWin() override; | 34 ~RegistryHashStoreContentsWin() override; |
| 24 | 35 |
| 25 // HashStoreContents overrides: | 36 // HashStoreContents overrides: |
| 26 bool IsCopyable() const override; | 37 bool IsCopyable() const override; |
| 27 std::unique_ptr<HashStoreContents> MakeCopy() const override; | 38 std::unique_ptr<HashStoreContents> MakeCopy() const override; |
| 28 base::StringPiece GetUMASuffix() const override; | 39 base::StringPiece GetUMASuffix() const override; |
| 29 void Reset() override; | 40 void Reset() override; |
| 30 bool GetMac(const std::string& path, std::string* out_value) override; | 41 bool GetMac(const std::string& path, std::string* out_value) override; |
| 31 bool GetSplitMacs(const std::string& path, | 42 bool GetSplitMacs(const std::string& path, |
| 32 std::map<std::string, std::string>* split_macs) override; | 43 std::map<std::string, std::string>* split_macs) override; |
| 33 void SetMac(const std::string& path, const std::string& value) override; | 44 void SetMac(const std::string& path, const std::string& value) override; |
| 34 void SetSplitMac(const std::string& path, | 45 void SetSplitMac(const std::string& path, |
| 35 const std::string& split_path, | 46 const std::string& split_path, |
| 36 const std::string& value) override; | 47 const std::string& value) override; |
| 37 bool RemoveEntry(const std::string& path) override; | 48 bool RemoveEntry(const std::string& path) override; |
| 38 | 49 |
| 39 // Unsupported HashStoreContents overrides: | 50 // Unsupported HashStoreContents overrides: |
| 40 void ImportEntry(const std::string& path, | 51 void ImportEntry(const std::string& path, |
| 41 const base::Value* in_value) override; | 52 const base::Value* in_value) override; |
| 42 const base::DictionaryValue* GetContents() const override; | 53 const base::DictionaryValue* GetContents() const override; |
| 43 std::string GetSuperMac() const override; | 54 std::string GetSuperMac() const override; |
| 44 void SetSuperMac(const std::string& super_mac) override; | 55 void SetSuperMac(const std::string& super_mac) override; |
| 45 | 56 |
| 46 private: | 57 private: |
| 47 // Helper constructor for |MakeCopy|. | 58 // Helper constructor for |MakeCopy|. |
| 48 explicit RegistryHashStoreContentsWin( | 59 explicit RegistryHashStoreContentsWin( |
| 49 const RegistryHashStoreContentsWin& other); | 60 const RegistryHashStoreContentsWin& other); |
| 50 | 61 |
| 51 const base::string16 preference_key_name_; | 62 const base::string16 preference_key_name_; |
| 52 const bool reset_on_delete_; | 63 scoped_refptr<TempScopedDirCleaner> temp_dir_cleaner_; |
| 53 }; | 64 }; |
| 54 | 65 |
| 55 #endif // SERVICES_PREFERENCES_TRACKED_REGISTRY_HASH_STORE_CONTENTS_WIN_H_ | 66 #endif // SERVICES_PREFERENCES_TRACKED_REGISTRY_HASH_STORE_CONTENTS_WIN_H_ |
| OLD | NEW |