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 16 matching lines...) Expand all Loading... |
27 // - The test key root, HKCU\Software\Chromium\TempTestKeys\ | 27 // - The test key root, HKCU\Software\Chromium\TempTestKeys\ |
28 // - The base::Time::ToInternalValue of the creation time. This is used to | 28 // - The base::Time::ToInternalValue of the creation time. This is used to |
29 // delete stale keys left over from crashed tests. | 29 // delete stale keys left over from crashed tests. |
30 // - A GUID used for preventing name collisions (although unlikely) between | 30 // - A GUID used for preventing name collisions (although unlikely) between |
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 randomly generated temporary key. |
38 // under the temporary test key path. There is no need to randomize | 38 // Multiple overrides to the same hive are not supported and lead to undefined |
39 // |override_name|, as a random parent key is generated. Multiple overrides to | 39 // behavior. |
40 // the same hive are not supported and lead to undefined behavior. | 40 void OverrideRegistry(HKEY override); |
41 void OverrideRegistry(HKEY override, const base::string16& override_name); | |
42 | 41 |
43 private: | 42 private: |
44 friend class RegistryOverrideManagerTest; | 43 friend class RegistryOverrideManagerTest; |
45 | 44 |
46 // Keeps track of one override. | 45 // Keeps track of one override. |
47 class ScopedRegistryKeyOverride { | 46 class ScopedRegistryKeyOverride { |
48 public: | 47 public: |
49 ScopedRegistryKeyOverride(HKEY override, const base::string16& key_path); | 48 ScopedRegistryKeyOverride(HKEY override, const base::string16& key_path); |
50 ~ScopedRegistryKeyOverride(); | 49 ~ScopedRegistryKeyOverride(); |
51 | 50 |
(...skipping 17 matching lines...) Expand all Loading... |
69 DISALLOW_COPY_AND_ASSIGN(RegistryOverrideManager); | 68 DISALLOW_COPY_AND_ASSIGN(RegistryOverrideManager); |
70 }; | 69 }; |
71 | 70 |
72 // Generates a temporary key path that will be eventually deleted | 71 // Generates a temporary key path that will be eventually deleted |
73 // automatically if the process crashes. | 72 // automatically if the process crashes. |
74 base::string16 GenerateTempKeyPath(); | 73 base::string16 GenerateTempKeyPath(); |
75 | 74 |
76 } // namespace registry_util | 75 } // namespace registry_util |
77 | 76 |
78 #endif // BASE_TEST_TEST_REG_UTIL_H_ | 77 #endif // BASE_TEST_TEST_REG_UTIL_H_ |
OLD | NEW |