OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/user_prefs/tracked/pref_hash_filter.h" | 5 #include "components/user_prefs/tracked/pref_hash_filter.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 | 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" |
10 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
11 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
12 #include "base/prefs/pref_store.h" | 15 #include "base/prefs/pref_store.h" |
13 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
14 #include "base/time/time.h" | 17 #include "base/time/time.h" |
15 #include "base/values.h" | 18 #include "base/values.h" |
16 #include "components/pref_registry/pref_registry_syncable.h" | 19 #include "components/pref_registry/pref_registry_syncable.h" |
17 #include "components/user_prefs/tracked/dictionary_hash_store_contents.h" | 20 #include "components/user_prefs/tracked/dictionary_hash_store_contents.h" |
18 #include "components/user_prefs/tracked/pref_hash_store.h" | 21 #include "components/user_prefs/tracked/pref_hash_store.h" |
19 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" | 22 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 user_prefs::kPreferenceResetTime, | 106 user_prefs::kPreferenceResetTime, |
104 base::Int64ToString(base::Time().ToInternalValue())); | 107 base::Int64ToString(base::Time().ToInternalValue())); |
105 } | 108 } |
106 | 109 |
107 // static | 110 // static |
108 base::Time PrefHashFilter::GetResetTime(PrefService* user_prefs) { | 111 base::Time PrefHashFilter::GetResetTime(PrefService* user_prefs) { |
109 // Provide our own implementation (identical to the PrefService::GetInt64) in | 112 // Provide our own implementation (identical to the PrefService::GetInt64) in |
110 // order to ensure it remains consistent with the way we store this value | 113 // order to ensure it remains consistent with the way we store this value |
111 // (which we do via a PrefStore, preventing us from reusing | 114 // (which we do via a PrefStore, preventing us from reusing |
112 // PrefService::SetInt64). | 115 // PrefService::SetInt64). |
113 int64 internal_value = base::Time().ToInternalValue(); | 116 int64_t internal_value = base::Time().ToInternalValue(); |
114 if (!base::StringToInt64( | 117 if (!base::StringToInt64( |
115 user_prefs->GetString(user_prefs::kPreferenceResetTime), | 118 user_prefs->GetString(user_prefs::kPreferenceResetTime), |
116 &internal_value)) { | 119 &internal_value)) { |
117 // Somehow the value stored on disk is not a valid int64. | 120 // Somehow the value stored on disk is not a valid int64_t. |
118 NOTREACHED(); | 121 NOTREACHED(); |
119 return base::Time(); | 122 return base::Time(); |
120 } | 123 } |
121 return base::Time::FromInternalValue(internal_value); | 124 return base::Time::FromInternalValue(internal_value); |
122 } | 125 } |
123 | 126 |
124 // static | 127 // static |
125 void PrefHashFilter::ClearResetTime(PrefService* user_prefs) { | 128 void PrefHashFilter::ClearResetTime(PrefService* user_prefs) { |
126 user_prefs->ClearPref(user_prefs::kPreferenceResetTime); | 129 user_prefs->ClearPref(user_prefs::kPreferenceResetTime); |
127 } | 130 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 224 } |
222 | 225 |
223 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing | 226 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing |
224 // data has been gathered from the wild to be confident this doesn't | 227 // data has been gathered from the wild to be confident this doesn't |
225 // significantly affect startup. | 228 // significantly affect startup. |
226 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime", | 229 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime", |
227 base::TimeTicks::Now() - checkpoint); | 230 base::TimeTicks::Now() - checkpoint); |
228 | 231 |
229 post_filter_on_load_callback.Run(pref_store_contents.Pass(), prefs_altered); | 232 post_filter_on_load_callback.Run(pref_store_contents.Pass(), prefs_altered); |
230 } | 233 } |
OLD | NEW |