Index: chrome/browser/importer/ie_importer_test_registry_overrider_win.h |
diff --git a/chrome/browser/importer/ie_importer_test_registry_overrider_win.h b/chrome/browser/importer/ie_importer_test_registry_overrider_win.h |
index 543c196b77b4e59cb913ddcc862138bc7edea3ec..0a6726a17d1aabb0066e6f243cfb5da2ac789e00 100644 |
--- a/chrome/browser/importer/ie_importer_test_registry_overrider_win.h |
+++ b/chrome/browser/importer/ie_importer_test_registry_overrider_win.h |
@@ -6,62 +6,27 @@ |
#define CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_ |
#include "base/basictypes.h" |
-#include "base/lazy_instance.h" |
#include "base/string16.h" |
-#include "base/synchronization/lock.h" |
-// A helper class to override HKEY_CURRENT_USER to point to a test key from this |
-// process' point of view. Uses a random guid as a subkey for the override in |
-// order for multiple tests to be able to use this functionality in parallel. |
-// Also provides functionality (via an environment variable) to let child |
-// processes check whether they should also override. This class is thread-safe. |
-// Always unsets any existing override upon being deleted. |
+// A helper class to let tests generate a random registry key to be used in |
+// HKEY_CURRENT_USER in tests. After the key has been generated by constructing |
+// an IEImporterTestRegistryOverrider, consumers in this process (or in any |
+// child processes created after the key has been generated) can obtain the key |
+// via GetTestRegistryOverride(). IEImporterTestRegistryOverrider will delete |
+// the temporary key upon being deleted itself. Only one |
+// IEImporterTestRegistryOverrider should live at once in a given process |
+// hiearchy. |
class IEImporterTestRegistryOverrider { |
public: |
IEImporterTestRegistryOverrider(); |
- |
- // Unsets any existing registry override and deletes the temporary registry |
- // key if |override_initiated_|. |
~IEImporterTestRegistryOverrider(); |
- // Calls StartRegistryOverride() and sets an environment variable so that |
- // future calls to StartRegistryOverrideIfNeeded() from child processes also |
- // result in an overriden HKEY_CURRENT_USER hive. This method should only be |
- // called once across all processes. |
- // Returns false on unexpected failure. |
- bool SetRegistryOverride(); |
- |
- // Calls StartRegistryOverride() if the environment was set by a parent |
- // process via SetRegistryOverride(). |
- // Returns false on unexpected failure. |
- bool StartRegistryOverrideIfNeeded(); |
+ // Returns a test key if one was chosen and set by a call to |
+ // SetTestRegistryOverride(); returns the empty string if none. |
+ static base::string16 GetTestRegistryOverride(); |
private: |
- // Overrides HKCU to point to a test key (ending with |subkey|) from this |
- // process' point of view. Re-applies the override without taking ownership if |
- // |override_active_in_process_|. |
- // Returns false on unexpected failure. |
- bool StartRegistryOverride(const base::string16& subkey); |
- |
- // Reads the environment variable set by SetRegistryOverride into |subkey| if |
- // it exists. Returns true if the variable was successfully read. |
- bool GetSubKeyFromEnvironment(base::string16* subkey); |
- |
- // Whether this object started an override for the current process (and thus |
- // will be responsible for unsetting it when done). |
- bool override_performed_; |
- |
- // Whether this object is the one that initiated the override via |
- // SetRegistryOverride() (and thus will be the one responsible for deleting |
- // the temporary key when done). |
- bool override_initiated_; |
- |
- // Whether a registry override was initiated in the current process. |
- static bool override_active_in_process_; |
- |
- // This lock should be held before accessing this class' static data and any |
- // of its objects' members. |
- static base::LazyInstance<base::Lock>::Leaky lock_; |
+ base::string16 temporary_key_; |
DISALLOW_COPY_AND_ASSIGN(IEImporterTestRegistryOverrider); |
}; |