Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1561)

Unified Diff: chrome/browser/importer/ie_importer_test_registry_overrider_win.h

Issue 14143010: Introduce IEImporterTestRegistryOverrider to be able to override the registry for a test and flag t… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: grammar Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..d282dc6432520705b53e6c820c6ea6c1ad202df9
--- /dev/null
+++ b/chrome/browser/importer/ie_importer_test_registry_overrider_win.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_
+#define CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_
+
+#include "base/basictypes.h"
+
+// A helper class to override HKEY_CURRENT_USER to point to a test key from this
+// process' point of view. Also provides functionality (via an environment
+// variable) to let child processes check whether they should also override.
+// Always unsets any existing override upon being deleted.
+class IEImporterTestRegistryOverrider {
+ public:
+ IEImporterTestRegistryOverrider() : override_set_by_current_process_(false) {}
+
+ // Unsets any existing registry override and deletes the temporary registry
+ // key if |override_set_by_current_process_|.
+ ~IEImporterTestRegistryOverrider();
+
+ // Calls StartRegistryOverride() and sets an environment variable so that
+ // future calls to StartRegistryOverrideIfNeeded() from child processes also
+ // result in an overriden registry.
+ // Returns false on unexpected failure.
+ bool SetRegistryOverride();
robertshield 2013/04/26 19:20:53 If I am reading this correctly, a caller should ne
gab 2013/04/29 02:00:43 Changed the interface quite a bit, let me know if
+
+ // Calls StartRegistryOverride() if the environment was set by a parent
+ // process via SetRegistryOverride().
+ // Returns false on unexpected failure.
+ bool StartRegistryOverrideIfNeeded();
+
+ private:
+ // Overrides HKCU to point to a test key from this process' point of view.
+ // Returns false on unexpected failure.
+ bool StartRegistryOverride();
+
+ // Whether a registry override was initiated in the current process.
+ bool override_active_;
robertshield 2013/04/26 19:20:53 should this be static?
gab 2013/04/29 02:00:43 See main comment.
+
+ // Wheter this process is the one that set the override (and thus should be
robertshield 2013/04/26 19:20:53 nit: Whether
gab 2013/04/29 02:00:43 Done.
+ // the one deleting the temporary key when done).
+ bool override_set_by_current_process_;
+
+ DISALLOW_COPY_AND_ASSIGN(IEImporterTestRegistryOverrider);
+};
+
+#endif // CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698