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

Side by Side Diff: chrome/browser/extensions/external_registry_loader_win.cc

Issue 2693223002: Log the error result when observing a registry key fails. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/external_registry_loader_win.h" 5 #include "chrome/browser/extensions/external_registry_loader_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_file.h" 10 #include "base/files/scoped_file.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 BrowserThread::UI, FROM_HERE, 194 BrowserThread::UI, FROM_HERE,
195 base::Bind(&ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry, 195 base::Bind(&ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry,
196 this)); 196 this));
197 } 197 }
198 198
199 void ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry() { 199 void ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry() {
200 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 200 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
201 LoadFinished(); 201 LoadFinished();
202 202
203 // Start watching registry. 203 // Start watching registry.
204 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, kRegistryExtensions, 204 LONG result = ERROR_SUCCESS;
205 KEY_NOTIFY | KEY_WOW64_32KEY) == ERROR_SUCCESS) { 205 if ((result = hklm_key_.Create(HKEY_LOCAL_MACHINE, kRegistryExtensions,
206 KEY_NOTIFY | KEY_WOW64_32KEY)) ==
207 ERROR_SUCCESS) {
206 base::win::RegKey::ChangeCallback callback = 208 base::win::RegKey::ChangeCallback callback =
207 base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged, 209 base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged,
208 base::Unretained(this), base::Unretained(&hklm_key_)); 210 base::Unretained(this), base::Unretained(&hklm_key_));
209 hklm_key_.StartWatching(callback); 211 hklm_key_.StartWatching(callback);
210 } else { 212 } else {
211 LOG(WARNING) << "Error observing HKLM."; 213 LOG(WARNING) << "Error observing HKLM: " << result;
lazyboy 2017/02/15 00:19:56 Maybe we should remove logging this and keep only
Wez 2017/02/15 00:33:21 Actually it seems like a legitimate error; IIUC co
212 } 214 }
213 215
214 if (hkcu_key_.Create(HKEY_CURRENT_USER, kRegistryExtensions, KEY_NOTIFY) == 216 if ((result = hkcu_key_.Create(HKEY_CURRENT_USER, kRegistryExtensions,
215 ERROR_SUCCESS) { 217 KEY_NOTIFY)) == ERROR_SUCCESS) {
216 base::win::RegKey::ChangeCallback callback = 218 base::win::RegKey::ChangeCallback callback =
217 base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged, 219 base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged,
218 base::Unretained(this), base::Unretained(&hkcu_key_)); 220 base::Unretained(this), base::Unretained(&hkcu_key_));
219 hkcu_key_.StartWatching(callback); 221 hkcu_key_.StartWatching(callback);
220 } else { 222 } else {
221 LOG(WARNING) << "Error observing HKCU."; 223 LOG(WARNING) << "Error observing HKCU: " << result;
222 } 224 }
223 } 225 }
224 226
225 void ExternalRegistryLoader::OnRegistryKeyChanged(base::win::RegKey* key) { 227 void ExternalRegistryLoader::OnRegistryKeyChanged(base::win::RegKey* key) {
226 // |OnRegistryKeyChanged| is removed as an observer when the ChangeCallback is 228 // |OnRegistryKeyChanged| is removed as an observer when the ChangeCallback is
227 // called, so we need to re-register. 229 // called, so we need to re-register.
228 key->StartWatching(base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged, 230 key->StartWatching(base::Bind(&ExternalRegistryLoader::OnRegistryKeyChanged,
229 base::Unretained(this), base::Unretained(key))); 231 base::Unretained(this), base::Unretained(key)));
230 232
231 BrowserThread::PostTask( 233 BrowserThread::PostTask(
232 BrowserThread::FILE, FROM_HERE, 234 BrowserThread::FILE, FROM_HERE,
233 base::Bind(&ExternalRegistryLoader::UpdatePrefsOnFileThread, this)); 235 base::Bind(&ExternalRegistryLoader::UpdatePrefsOnFileThread, this));
234 } 236 }
235 237
236 void ExternalRegistryLoader::UpdatePrefsOnFileThread() { 238 void ExternalRegistryLoader::UpdatePrefsOnFileThread() {
237 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 239 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
238 base::TimeTicks start_time = base::TimeTicks::Now(); 240 base::TimeTicks start_time = base::TimeTicks::Now();
239 std::unique_ptr<base::DictionaryValue> prefs = LoadPrefsOnFileThread(); 241 std::unique_ptr<base::DictionaryValue> prefs = LoadPrefsOnFileThread();
240 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWinUpdate", 242 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWinUpdate",
241 base::TimeTicks::Now() - start_time); 243 base::TimeTicks::Now() - start_time);
242 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 244 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
243 base::Bind(&ExternalRegistryLoader::OnUpdated, this, 245 base::Bind(&ExternalRegistryLoader::OnUpdated, this,
244 base::Passed(&prefs))); 246 base::Passed(&prefs)));
245 } 247 }
246 248
247 } // namespace extensions 249 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698