| 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 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // items are non-null. | 71 // items are non-null. |
| 72 DCHECK(!external_validation_hash_store_pair_.has_value() || | 72 DCHECK(!external_validation_hash_store_pair_.has_value() || |
| 73 (external_validation_hash_store_pair_->first && | 73 (external_validation_hash_store_pair_->first && |
| 74 external_validation_hash_store_pair_->second)); | 74 external_validation_hash_store_pair_->second)); |
| 75 | 75 |
| 76 for (size_t i = 0; i < tracked_preferences.size(); ++i) { | 76 for (size_t i = 0; i < tracked_preferences.size(); ++i) { |
| 77 const TrackedPreferenceMetadata& metadata = tracked_preferences[i]; | 77 const TrackedPreferenceMetadata& metadata = tracked_preferences[i]; |
| 78 | 78 |
| 79 std::unique_ptr<TrackedPreference> tracked_preference; | 79 std::unique_ptr<TrackedPreference> tracked_preference; |
| 80 switch (metadata.strategy) { | 80 switch (metadata.strategy) { |
| 81 case TRACKING_STRATEGY_ATOMIC: | 81 case PrefTrackingStrategy::ATOMIC: |
| 82 tracked_preference.reset( | 82 tracked_preference.reset( |
| 83 new TrackedAtomicPreference(metadata.name, | 83 new TrackedAtomicPreference(metadata.name, |
| 84 metadata.reporting_id, | 84 metadata.reporting_id, |
| 85 reporting_ids_count, | 85 reporting_ids_count, |
| 86 metadata.enforcement_level, | 86 metadata.enforcement_level, |
| 87 metadata.value_type, | 87 metadata.value_type, |
| 88 delegate)); | 88 delegate)); |
| 89 break; | 89 break; |
| 90 case TRACKING_STRATEGY_SPLIT: | 90 case PrefTrackingStrategy::SPLIT: |
| 91 tracked_preference.reset( | 91 tracked_preference.reset( |
| 92 new TrackedSplitPreference(metadata.name, | 92 new TrackedSplitPreference(metadata.name, |
| 93 metadata.reporting_id, | 93 metadata.reporting_id, |
| 94 reporting_ids_count, | 94 reporting_ids_count, |
| 95 metadata.enforcement_level, | 95 metadata.enforcement_level, |
| 96 metadata.value_type, | 96 metadata.value_type, |
| 97 delegate)); | 97 delegate)); |
| 98 break; | 98 break; |
| 99 } | 99 } |
| 100 DCHECK(tracked_preference); | 100 DCHECK(tracked_preference); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 if (did_reset) { | 250 if (did_reset) { |
| 251 pref_store_contents->Set(user_prefs::kPreferenceResetTime, | 251 pref_store_contents->Set(user_prefs::kPreferenceResetTime, |
| 252 new base::Value(base::Int64ToString( | 252 new base::Value(base::Int64ToString( |
| 253 base::Time::Now().ToInternalValue()))); | 253 base::Time::Now().ToInternalValue()))); |
| 254 FilterUpdate(user_prefs::kPreferenceResetTime); | 254 FilterUpdate(user_prefs::kPreferenceResetTime); |
| 255 | 255 |
| 256 if (!on_reset_on_load_.is_null()) | 256 if (!on_reset_on_load_.is_null()) |
| 257 on_reset_on_load_.Run(); | 257 on_reset_on_load_.Run(); |
| 258 } | 258 } |
| 259 on_reset_on_load_.Reset(); |
| 259 | 260 |
| 260 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime", | 261 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime", |
| 261 base::TimeTicks::Now() - checkpoint); | 262 base::TimeTicks::Now() - checkpoint); |
| 262 | 263 |
| 263 post_filter_on_load_callback.Run(std::move(pref_store_contents), | 264 post_filter_on_load_callback.Run(std::move(pref_store_contents), |
| 264 prefs_altered); | 265 prefs_altered); |
| 265 } | 266 } |
| 266 | 267 |
| 267 // static | 268 // static |
| 268 void PrefHashFilter::ClearFromExternalStore( | 269 void PrefHashFilter::ClearFromExternalStore( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // which owns the pointers. | 362 // which owns the pointers. |
| 362 HashStoreContents* raw_contents = hash_store_contents_copy.get(); | 363 HashStoreContents* raw_contents = hash_store_contents_copy.get(); |
| 363 base::DictionaryValue* raw_changed_paths_macs = changed_paths_macs.get(); | 364 base::DictionaryValue* raw_changed_paths_macs = changed_paths_macs.get(); |
| 364 | 365 |
| 365 return std::make_pair( | 366 return std::make_pair( |
| 366 base::Bind(&ClearFromExternalStore, base::Unretained(raw_contents), | 367 base::Bind(&ClearFromExternalStore, base::Unretained(raw_contents), |
| 367 base::Unretained(raw_changed_paths_macs)), | 368 base::Unretained(raw_changed_paths_macs)), |
| 368 base::Bind(&FlushToExternalStore, base::Passed(&hash_store_contents_copy), | 369 base::Bind(&FlushToExternalStore, base::Passed(&hash_store_contents_copy), |
| 369 base::Passed(&changed_paths_macs))); | 370 base::Passed(&changed_paths_macs))); |
| 370 } | 371 } |
| OLD | NEW |