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 0b5a67f83687c838b7723790af6f0953dc435e9f..504c2ba755d0c286c27466b7a6e69b173677cfb8 100644 |
| --- a/chrome/browser/extensions/external_registry_loader_win.cc |
| +++ b/chrome/browser/extensions/external_registry_loader_win.cc |
| @@ -61,9 +61,8 @@ void ExternalRegistryLoader::StartLoading() { |
| base::Bind(&ExternalRegistryLoader::LoadOnFileThread, this)); |
| } |
| -void ExternalRegistryLoader::LoadOnFileThread() { |
| +void ExternalRegistryLoader::LoadPrefsOnFileThread() { |
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| - base::TimeTicks start_time = base::TimeTicks::Now(); |
| scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); |
| // A map of IDs, to weed out duplicates between HKCU and HKLM. |
| @@ -183,11 +182,72 @@ void ExternalRegistryLoader::LoadOnFileThread() { |
| } |
| prefs_.reset(prefs.release()); |
| +} |
| + |
| +void ExternalRegistryLoader::LoadOnFileThread() { |
| + base::TimeTicks start_time = base::TimeTicks::Now(); |
| + LoadPrefsOnFileThread(); |
| LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin", |
| base::TimeTicks::Now() - start_time); |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| - base::Bind(&ExternalRegistryLoader::LoadFinished, this)); |
| + base::Bind( |
| + &ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry, this)); |
| +} |
| + |
| +void ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry() { |
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + LoadFinished(); |
| + |
| + // Start watching registry. |
| + // TODO(lazyboy): Is using KEY_WOW64_32KEY correct? |
| + if (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), |
|
asargent_no_longer_on_chrome
2016/01/20 22:49:00
I know that reading from the registry must be done
lazyboy
2016/01/21 21:02:12
I've based my changes on plugin_service_impl.cc, w
|
| + base::Unretained(&hklm_key_)); |
| + hklm_key_.StartWatching(callback); |
| + } else { |
| + // TODO(lazyboy): Error handling. |
| + LOG(ERROR) << "Error observing HKLM."; |
| + } |
| + |
| + if (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 { |
| + // TODO(lazyboy): Error handling. |
| + LOG(ERROR) << "Error observing HKCU."; |
| + } |
| +} |
| + |
| +void ExternalRegistryLoader::OnRegistryKeyChanged(base::win::RegKey* key) { |
| + key->StartWatching( |
|
Devlin
2016/01/21 00:14:26
Save the reader the lookup into win/registry.h wit
lazyboy
2016/01/21 21:02:12
Done.
|
| + base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged, |
| + base::Unretained(this), |
| + base::Unretained(key))); |
| + |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&ExternalRegistryLoader::UpdatePrefsOnFileThread, this)); |
| +} |
| + |
| +void ExternalRegistryLoader::UpdatePrefsOnFileThread() { |
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| + base::TimeTicks start_time = base::TimeTicks::Now(); |
| + LoadPrefsOnFileThread(); |
| + LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWinUpdate", |
| + base::TimeTicks::Now() - start_time); |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + base::Bind(&ExternalRegistryLoader::OnUpdated, this)); |
| } |
| } // namespace extensions |