| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 BASE_TEST_TEST_REG_UTIL_H_ | 5 #ifndef BASE_TEST_TEST_REG_UTIL_H_ |
| 6 #define BASE_TEST_TEST_REG_UTIL_H_ | 6 #define BASE_TEST_TEST_REG_UTIL_H_ |
| 7 | 7 |
| 8 // Registry utility functions used only by tests. | 8 // Registry utility functions used only by tests. |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // two RegistryOverrideManagers created with the same timestamp. | 31 // two RegistryOverrideManagers created with the same timestamp. |
| 32 class RegistryOverrideManager { | 32 class RegistryOverrideManager { |
| 33 public: | 33 public: |
| 34 RegistryOverrideManager(); | 34 RegistryOverrideManager(); |
| 35 ~RegistryOverrideManager(); | 35 ~RegistryOverrideManager(); |
| 36 | 36 |
| 37 // Override the given registry hive using a temporary key named by temp_name | 37 // Override the given registry hive using a temporary key named by temp_name |
| 38 // under the temporary test key path. There is no need to randomize | 38 // under the temporary test key path. There is no need to randomize |
| 39 // |override_name|, as a random parent key is generated. Multiple overrides to | 39 // |override_name|, as a random parent key is generated. Multiple overrides to |
| 40 // the same hive are not supported and lead to undefined behavior. | 40 // the same hive are not supported and lead to undefined behavior. |
| 41 void OverrideRegistry(HKEY override, const string16& override_name); | 41 void OverrideRegistry(HKEY override, const base::string16& override_name); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 friend class RegistryOverrideManagerTest; | 44 friend class RegistryOverrideManagerTest; |
| 45 | 45 |
| 46 // Keeps track of one override. | 46 // Keeps track of one override. |
| 47 class ScopedRegistryKeyOverride { | 47 class ScopedRegistryKeyOverride { |
| 48 public: | 48 public: |
| 49 ScopedRegistryKeyOverride(HKEY override, const string16& key_path); | 49 ScopedRegistryKeyOverride(HKEY override, const base::string16& key_path); |
| 50 ~ScopedRegistryKeyOverride(); | 50 ~ScopedRegistryKeyOverride(); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 HKEY override_; | 53 HKEY override_; |
| 54 base::win::RegKey temp_key_; | 54 base::win::RegKey temp_key_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(ScopedRegistryKeyOverride); | 56 DISALLOW_COPY_AND_ASSIGN(ScopedRegistryKeyOverride); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Used for testing only. | 59 // Used for testing only. |
| 60 RegistryOverrideManager(const base::Time& timestamp, | 60 RegistryOverrideManager(const base::Time& timestamp, |
| 61 const string16& test_key_root); | 61 const base::string16& test_key_root); |
| 62 | 62 |
| 63 base::Time timestamp_; | 63 base::Time timestamp_; |
| 64 string16 guid_; | 64 base::string16 guid_; |
| 65 | 65 |
| 66 string16 test_key_root_; | 66 base::string16 test_key_root_; |
| 67 ScopedVector<ScopedRegistryKeyOverride> overrides_; | 67 ScopedVector<ScopedRegistryKeyOverride> overrides_; |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(RegistryOverrideManager); | 69 DISALLOW_COPY_AND_ASSIGN(RegistryOverrideManager); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 // Generates a temporary key path that will be eventually deleted | 72 // Generates a temporary key path that will be eventually deleted |
| 73 // automatically if the process crashes. | 73 // automatically if the process crashes. |
| 74 string16 GenerateTempKeyPath(); | 74 base::string16 GenerateTempKeyPath(); |
| 75 | 75 |
| 76 } // namespace registry_util | 76 } // namespace registry_util |
| 77 | 77 |
| 78 #endif // BASE_TEST_TEST_REG_UTIL_H_ | 78 #endif // BASE_TEST_TEST_REG_UTIL_H_ |
| OLD | NEW |