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

Side by Side Diff: chrome/browser/prefs/chrome_pref_service_factory.cc

Issue 571893002: Added an error message when local state corruption is detected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Error message is suppressed in case of no error or no file. Created 6 years, 3 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/prefs/chrome_pref_service_factory.h" 5 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Specifically enable extension settings enforcement. 300 // Specifically enable extension settings enforcement.
301 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; 301 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD;
302 } 302 }
303 #endif 303 #endif
304 304
305 result.push_back(data); 305 result.push_back(data);
306 } 306 }
307 return result; 307 return result;
308 } 308 }
309 309
310
311 // Shows notifications which correspond to PersistentPrefStore's reading errors. 310 // Shows notifications which correspond to PersistentPrefStore's reading errors.
312 void HandleReadError(PersistentPrefStore::PrefReadError error) { 311 void HandleReadError(PersistentPrefStore::PrefReadError error) {
312 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE &&
313 error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) {
314 LOG(ERROR) << "An error happened during prefs loading: " << error;
315 }
316
313 // Sample the histogram also for the successful case in order to get a 317 // Sample the histogram also for the successful case in order to get a
314 // baseline on the success rate in addition to the error distribution. 318 // baseline on the success rate in addition to the error distribution.
315 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, 319 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error,
316 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); 320 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM);
317 321
318 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { 322 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) {
319 #if !defined(OS_CHROMEOS) 323 #if !defined(OS_CHROMEOS)
320 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for 324 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for
321 // an example problem that this can cause. 325 // an example problem that this can cause.
322 // Do some diagnosis and try to avoid losing data. 326 // Do some diagnosis and try to avoid losing data.
323 int message_id = 0; 327 int message_id = 0;
324 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE || 328 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE ||
325 error == PersistentPrefStore::PREF_READ_ERROR_LEVELDB_CORRUPTION) { 329 error == PersistentPrefStore::PREF_READ_ERROR_LEVELDB_CORRUPTION) {
326 message_id = IDS_PREFERENCES_CORRUPT_ERROR; 330 message_id = IDS_PREFERENCES_CORRUPT_ERROR;
327 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { 331 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) {
328 message_id = IDS_PREFERENCES_UNREADABLE_ERROR; 332 message_id = IDS_PREFERENCES_UNREADABLE_ERROR;
329 } 333 }
330 334
331 if (message_id) { 335 if (message_id) {
332 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 336 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
333 base::Bind(&ShowProfileErrorDialog, 337 base::Bind(&ShowProfileErrorDialog,
334 PROFILE_ERROR_PREFERENCES, 338 PROFILE_ERROR_PREFERENCES,
335 message_id)); 339 message_id));
336 } 340 }
337 #else 341 #else
338 // On ChromeOS error screen with message about broken local state 342 // On ChromeOS error screen with message about broken local state
339 // will be displayed. 343 // will be displayed.
Bernhard Bauer 2014/09/15 11:41:33 Shouldn't this take care of broken Local State?
ygorshenin1 2014/09/15 12:54:59 Recovery logic (on OOBE/login screen) is here: htt
Bernhard Bauer 2014/09/15 13:32:09 So, there is code that shows an error if Local Sta
340 #endif 344 #endif
341 } 345 }
342 } 346 }
343 347
344 scoped_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager( 348 scoped_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager(
345 const base::FilePath& profile_path) { 349 const base::FilePath& profile_path) {
346 std::string device_id; 350 std::string device_id;
347 #if defined(OS_WIN) && defined(ENABLE_RLZ) 351 #if defined(OS_WIN) && defined(ENABLE_RLZ)
348 // This is used by 352 // This is used by
349 // chrome/browser/extensions/api/music_manager_private/device_id_win.cc 353 // chrome/browser/extensions/api/music_manager_private/device_id_win.cc
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 521
518 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { 522 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
519 ProfilePrefStoreManager::RegisterProfilePrefs(registry); 523 ProfilePrefStoreManager::RegisterProfilePrefs(registry);
520 } 524 }
521 525
522 void RegisterPrefs(PrefRegistrySimple* registry) { 526 void RegisterPrefs(PrefRegistrySimple* registry) {
523 ProfilePrefStoreManager::RegisterPrefs(registry); 527 ProfilePrefStoreManager::RegisterPrefs(registry);
524 } 528 }
525 529
526 } // namespace chrome_prefs 530 } // namespace chrome_prefs
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