| 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..6f5792ff837781b807719ec835faabe3807c2b55 100644
|
| --- a/chrome/browser/importer/ie_importer_test_registry_overrider_win.h
|
| +++ b/chrome/browser/importer/ie_importer_test_registry_overrider_win.h
|
| @@ -6,16 +6,14 @@
|
| #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 via
|
| +// SetTestRegistryOverride(), 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.
|
| class IEImporterTestRegistryOverrider {
|
| public:
|
| IEImporterTestRegistryOverrider();
|
| @@ -24,45 +22,23 @@ class IEImporterTestRegistryOverrider {
|
| // 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();
|
| + // Sets an environment variable so that future calls to
|
| + // GetTestRegistryOverride() from this process and child processes result in
|
| + // the test key being returned to the caller. This method should only be
|
| + // called once. Returns false on failure to set the environment variable.
|
| + // NOTE: This method does not create the key itself.
|
| + bool SetTestRegistryOverride();
|
|
|
| - // 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).
|
| + // SetTestRegistryOverride() (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_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(IEImporterTestRegistryOverrider);
|
| };
|
|
|
|
|