OLD | NEW |
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 "base/prefs/json_pref_store.h" | 5 #include "base/prefs/json_pref_store.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 const base::Value* value, | 53 const base::Value* value, |
54 const base::FilePath& path, | 54 const base::FilePath& path, |
55 int error_code, | 55 int error_code, |
56 const std::string& error_msg) { | 56 const std::string& error_msg) { |
57 if (!value) { | 57 if (!value) { |
58 DVLOG(1) << "Error while loading JSON file: " << error_msg | 58 DVLOG(1) << "Error while loading JSON file: " << error_msg |
59 << ", file: " << path.value(); | 59 << ", file: " << path.value(); |
60 switch (error_code) { | 60 switch (error_code) { |
61 case JSONFileValueDeserializer::JSON_ACCESS_DENIED: | 61 case JSONFileValueDeserializer::JSON_ACCESS_DENIED: |
62 return PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED; | 62 return PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED; |
63 break; | |
64 case JSONFileValueDeserializer::JSON_CANNOT_READ_FILE: | 63 case JSONFileValueDeserializer::JSON_CANNOT_READ_FILE: |
65 return PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER; | 64 return PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER; |
66 break; | |
67 case JSONFileValueDeserializer::JSON_FILE_LOCKED: | 65 case JSONFileValueDeserializer::JSON_FILE_LOCKED: |
68 return PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED; | 66 return PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED; |
69 break; | |
70 case JSONFileValueDeserializer::JSON_NO_SUCH_FILE: | 67 case JSONFileValueDeserializer::JSON_NO_SUCH_FILE: |
71 return PersistentPrefStore::PREF_READ_ERROR_NO_FILE; | 68 return PersistentPrefStore::PREF_READ_ERROR_NO_FILE; |
72 break; | |
73 default: | 69 default: |
74 // JSON errors indicate file corruption of some sort. | 70 // JSON errors indicate file corruption of some sort. |
75 // Since the file is corrupt, move it to the side and continue with | 71 // Since the file is corrupt, move it to the side and continue with |
76 // empty preferences. This will result in them losing their settings. | 72 // empty preferences. This will result in them losing their settings. |
77 // We keep the old file for possible support and debugging assistance | 73 // We keep the old file for possible support and debugging assistance |
78 // as well as to detect if they're seeing these errors repeatedly. | 74 // as well as to detect if they're seeing these errors repeatedly. |
79 // TODO(erikkay) Instead, use the last known good file. | 75 // TODO(erikkay) Instead, use the last known good file. |
80 base::FilePath bad = path.ReplaceExtension(kBadExtension); | 76 base::FilePath bad = path.ReplaceExtension(kBadExtension); |
81 | 77 |
82 // If they've ever had a parse error before, put them in another bucket. | 78 // If they've ever had a parse error before, put them in another bucket. |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 DCHECK_EQ(31, num_buckets); | 526 DCHECK_EQ(31, num_buckets); |
531 | 527 |
532 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 528 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
533 // macro adapted to allow for a dynamically suffixed histogram name. | 529 // macro adapted to allow for a dynamically suffixed histogram name. |
534 // Note: The factory creates and owns the histogram. | 530 // Note: The factory creates and owns the histogram. |
535 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 531 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
536 histogram_name, min_value, max_value, num_buckets, | 532 histogram_name, min_value, max_value, num_buckets, |
537 base::HistogramBase::kUmaTargetedHistogramFlag); | 533 base::HistogramBase::kUmaTargetedHistogramFlag); |
538 return histogram; | 534 return histogram; |
539 } | 535 } |
OLD | NEW |