Chromium Code Reviews| 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; |
| + } |
| } |
| } |