| 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 "components/prefs/json_pref_store.h" | 5 #include "components/prefs/json_pref_store.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 // If they've ever had a parse error before, put them in another bucket. | 83 // If they've ever had a parse error before, put them in another bucket. |
| 84 // TODO(erikkay) if we keep this error checking for very long, we may | 84 // TODO(erikkay) if we keep this error checking for very long, we may |
| 85 // want to differentiate between recent and long ago errors. | 85 // want to differentiate between recent and long ago errors. |
| 86 bool bad_existed = base::PathExists(bad); | 86 bool bad_existed = base::PathExists(bad); |
| 87 base::Move(path, bad); | 87 base::Move(path, bad); |
| 88 return bad_existed ? PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT | 88 return bad_existed ? PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT |
| 89 : PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE; | 89 : PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 if (!value->IsType(base::Value::TYPE_DICTIONARY)) | 92 if (!value->IsType(base::Value::Type::DICTIONARY)) |
| 93 return PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; | 93 return PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; |
| 94 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 94 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Records a sample for |size| in the Settings.JsonDataReadSizeKilobytes | 97 // Records a sample for |size| in the Settings.JsonDataReadSizeKilobytes |
| 98 // histogram suffixed with the base name of the JSON file under |path|. | 98 // histogram suffixed with the base name of the JSON file under |path|. |
| 99 void RecordJsonDataSizeHistogram(const base::FilePath& path, size_t size) { | 99 void RecordJsonDataSizeHistogram(const base::FilePath& path, size_t size) { |
| 100 std::string spaceless_basename; | 100 std::string spaceless_basename; |
| 101 base::ReplaceChars(path.BaseName().MaybeAsASCII(), " ", "_", | 101 base::ReplaceChars(path.BaseName().MaybeAsASCII(), " ", "_", |
| 102 &spaceless_basename); | 102 &spaceless_basename); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 DCHECK_EQ(31, num_buckets); | 599 DCHECK_EQ(31, num_buckets); |
| 600 | 600 |
| 601 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 601 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
| 602 // macro adapted to allow for a dynamically suffixed histogram name. | 602 // macro adapted to allow for a dynamically suffixed histogram name. |
| 603 // Note: The factory creates and owns the histogram. | 603 // Note: The factory creates and owns the histogram. |
| 604 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 604 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
| 605 histogram_name, min_value, max_value, num_buckets, | 605 histogram_name, min_value, max_value, num_buckets, |
| 606 base::HistogramBase::kUmaTargetedHistogramFlag); | 606 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 607 return histogram; | 607 return histogram; |
| 608 } | 608 } |
| OLD | NEW |