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

Unified Diff: chrome/browser/extensions/external_registry_loader_win.cc

Issue 2796783002: [Ext Registry] Do not try to re-watch registry if we are already watching it. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « chrome/browser/extensions/external_registry_loader_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/external_registry_loader_win.cc
diff --git a/chrome/browser/extensions/external_registry_loader_win.cc b/chrome/browser/extensions/external_registry_loader_win.cc
index b54835aff5923dc09df2e599efa9688b7d330261..02466345cedb9592cfa048c5e9b0d34a3d476d8c 100644
--- a/chrome/browser/extensions/external_registry_loader_win.cc
+++ b/chrome/browser/extensions/external_registry_loader_win.cc
@@ -54,6 +54,9 @@ std::string MakePrefName(const std::string& extension_id,
namespace extensions {
+ExternalRegistryLoader::ExternalRegistryLoader()
+ : is_watching_hklm_(false), is_watching_hkcu_(false) {}
+
void ExternalRegistryLoader::StartLoading() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
@@ -200,27 +203,33 @@ void ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
LoadFinished();
- // Start watching registry.
+ // Start watching registry if we are not already.
LONG result = ERROR_SUCCESS;
- if ((result = hklm_key_.Create(HKEY_LOCAL_MACHINE, kRegistryExtensions,
- KEY_NOTIFY | KEY_WOW64_32KEY)) ==
- ERROR_SUCCESS) {
- base::win::RegKey::ChangeCallback callback =
- base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged,
- base::Unretained(this), base::Unretained(&hklm_key_));
- hklm_key_.StartWatching(callback);
- } else {
- LOG(WARNING) << "Error observing HKLM: " << result;
+ if (!is_watching_hklm_) {
Devlin 2017/04/04 01:44:07 Do we want these (this and is_watching_hkcu_) as s
lazyboy 2017/04/04 18:45:10 These can independently fail. Or at least HKLM can
Devlin 2017/04/04 20:48:35 So, my question here is more around whether or not
lazyboy 2017/04/04 21:47:23 Note that a watcher that previously failed would a
+ if ((result = hklm_key_.Create(HKEY_LOCAL_MACHINE, kRegistryExtensions,
+ KEY_NOTIFY | KEY_WOW64_32KEY)) ==
+ ERROR_SUCCESS) {
+ base::win::RegKey::ChangeCallback callback =
+ base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged,
+ base::Unretained(this), base::Unretained(&hklm_key_));
+ hklm_key_.StartWatching(callback);
+ is_watching_hklm_ = true;
+ } else {
+ LOG(WARNING) << "Error observing HKLM: " << result;
+ }
}
- if ((result = hkcu_key_.Create(HKEY_CURRENT_USER, kRegistryExtensions,
- KEY_NOTIFY)) == ERROR_SUCCESS) {
- base::win::RegKey::ChangeCallback callback =
- base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged,
- base::Unretained(this), base::Unretained(&hkcu_key_));
- hkcu_key_.StartWatching(callback);
- } else {
- LOG(WARNING) << "Error observing HKCU: " << result;
+ if (!is_watching_hkcu_) {
+ if ((result = hkcu_key_.Create(HKEY_CURRENT_USER, kRegistryExtensions,
+ KEY_NOTIFY)) == ERROR_SUCCESS) {
+ base::win::RegKey::ChangeCallback callback =
+ base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged,
+ base::Unretained(this), base::Unretained(&hkcu_key_));
+ hkcu_key_.StartWatching(callback);
+ is_watching_hkcu_ = true;
+ } else {
+ LOG(WARNING) << "Error observing HKCU: " << result;
+ }
}
}
« no previous file with comments | « chrome/browser/extensions/external_registry_loader_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698