| 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> | 7 #include <stdint.h> |
| 8 | |
| 9 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/prefs/pref_store.h" | 15 #include "base/prefs/pref_store.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/pref_registry/pref_registry_syncable.h" | 19 #include "components/pref_registry/pref_registry_syncable.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 PrefHashFilter::PrefHashFilter( | 50 PrefHashFilter::PrefHashFilter( |
| 51 scoped_ptr<PrefHashStore> pref_hash_store, | 51 scoped_ptr<PrefHashStore> pref_hash_store, |
| 52 const std::vector<TrackedPreferenceMetadata>& tracked_preferences, | 52 const std::vector<TrackedPreferenceMetadata>& tracked_preferences, |
| 53 const base::Closure& on_reset_on_load, | 53 const base::Closure& on_reset_on_load, |
| 54 TrackedPreferenceValidationDelegate* delegate, | 54 TrackedPreferenceValidationDelegate* delegate, |
| 55 size_t reporting_ids_count, | 55 size_t reporting_ids_count, |
| 56 bool report_super_mac_validity) | 56 bool report_super_mac_validity) |
| 57 : pref_hash_store_(pref_hash_store.Pass()), | 57 : pref_hash_store_(std::move(pref_hash_store)), |
| 58 on_reset_on_load_(on_reset_on_load), | 58 on_reset_on_load_(on_reset_on_load), |
| 59 report_super_mac_validity_(report_super_mac_validity) { | 59 report_super_mac_validity_(report_super_mac_validity) { |
| 60 DCHECK(pref_hash_store_); | 60 DCHECK(pref_hash_store_); |
| 61 DCHECK_GE(reporting_ids_count, tracked_preferences.size()); | 61 DCHECK_GE(reporting_ids_count, tracked_preferences.size()); |
| 62 | 62 |
| 63 for (size_t i = 0; i < tracked_preferences.size(); ++i) { | 63 for (size_t i = 0; i < tracked_preferences.size(); ++i) { |
| 64 const TrackedPreferenceMetadata& metadata = tracked_preferences[i]; | 64 const TrackedPreferenceMetadata& metadata = tracked_preferences[i]; |
| 65 | 65 |
| 66 scoped_ptr<TrackedPreference> tracked_preference; | 66 scoped_ptr<TrackedPreference> tracked_preference; |
| 67 switch (metadata.strategy) { | 67 switch (metadata.strategy) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 79 new TrackedSplitPreference(metadata.name, | 79 new TrackedSplitPreference(metadata.name, |
| 80 metadata.reporting_id, | 80 metadata.reporting_id, |
| 81 reporting_ids_count, | 81 reporting_ids_count, |
| 82 metadata.enforcement_level, | 82 metadata.enforcement_level, |
| 83 metadata.value_type, | 83 metadata.value_type, |
| 84 delegate)); | 84 delegate)); |
| 85 break; | 85 break; |
| 86 } | 86 } |
| 87 DCHECK(tracked_preference); | 87 DCHECK(tracked_preference); |
| 88 | 88 |
| 89 bool is_new = tracked_paths_.add(metadata.name, | 89 bool is_new = |
| 90 tracked_preference.Pass()).second; | 90 tracked_paths_.add(metadata.name, std::move(tracked_preference)).second; |
| 91 DCHECK(is_new); | 91 DCHECK(is_new); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 PrefHashFilter::~PrefHashFilter() { | 95 PrefHashFilter::~PrefHashFilter() { |
| 96 // Ensure new values for all |changed_paths_| have been flushed to | 96 // Ensure new values for all |changed_paths_| have been flushed to |
| 97 // |pref_hash_store_| already. | 97 // |pref_hash_store_| already. |
| 98 DCHECK(changed_paths_.empty()); | 98 DCHECK(changed_paths_.empty()); |
| 99 } | 99 } |
| 100 | 100 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (!on_reset_on_load_.is_null()) | 222 if (!on_reset_on_load_.is_null()) |
| 223 on_reset_on_load_.Run(); | 223 on_reset_on_load_.Run(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // 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 |
| 227 // 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 |
| 228 // significantly affect startup. | 228 // significantly affect startup. |
| 229 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime", | 229 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime", |
| 230 base::TimeTicks::Now() - checkpoint); | 230 base::TimeTicks::Now() - checkpoint); |
| 231 | 231 |
| 232 post_filter_on_load_callback.Run(pref_store_contents.Pass(), prefs_altered); | 232 post_filter_on_load_callback.Run(std::move(pref_store_contents), |
| 233 prefs_altered); |
| 233 } | 234 } |
| OLD | NEW |