Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: components/user_prefs/tracked/tracked_preferences_migration.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/tracked_preferences_migration.h" 5 #include "components/user_prefs/tracked/tracked_preferences_migration.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
11 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
12 #include "base/values.h" 14 #include "base/values.h"
13 #include "components/user_prefs/tracked/dictionary_hash_store_contents.h" 15 #include "components/user_prefs/tracked/dictionary_hash_store_contents.h"
14 #include "components/user_prefs/tracked/hash_store_contents.h" 16 #include "components/user_prefs/tracked/hash_store_contents.h"
15 #include "components/user_prefs/tracked/interceptable_pref_filter.h" 17 #include "components/user_prefs/tracked/interceptable_pref_filter.h"
16 #include "components/user_prefs/tracked/pref_hash_store.h" 18 #include "components/user_prefs/tracked/pref_hash_store.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 InterceptablePrefFilter* unprotected_pref_filter, 222 InterceptablePrefFilter* unprotected_pref_filter,
221 InterceptablePrefFilter* protected_pref_filter) 223 InterceptablePrefFilter* protected_pref_filter)
222 : unprotected_pref_names_(unprotected_pref_names), 224 : unprotected_pref_names_(unprotected_pref_names),
223 protected_pref_names_(protected_pref_names), 225 protected_pref_names_(protected_pref_names),
224 unprotected_store_cleaner_(unprotected_store_cleaner), 226 unprotected_store_cleaner_(unprotected_store_cleaner),
225 protected_store_cleaner_(protected_store_cleaner), 227 protected_store_cleaner_(protected_store_cleaner),
226 register_on_successful_unprotected_store_write_callback_( 228 register_on_successful_unprotected_store_write_callback_(
227 register_on_successful_unprotected_store_write_callback), 229 register_on_successful_unprotected_store_write_callback),
228 register_on_successful_protected_store_write_callback_( 230 register_on_successful_protected_store_write_callback_(
229 register_on_successful_protected_store_write_callback), 231 register_on_successful_protected_store_write_callback),
230 unprotected_pref_hash_store_(unprotected_pref_hash_store.Pass()), 232 unprotected_pref_hash_store_(std::move(unprotected_pref_hash_store)),
231 protected_pref_hash_store_(protected_pref_hash_store.Pass()), 233 protected_pref_hash_store_(std::move(protected_pref_hash_store)),
232 legacy_pref_hash_store_(legacy_pref_hash_store.Pass()) { 234 legacy_pref_hash_store_(std::move(legacy_pref_hash_store)) {
233 // The callbacks bound below will own this TrackedPreferencesMigrator by 235 // The callbacks bound below will own this TrackedPreferencesMigrator by
234 // reference. 236 // reference.
235 unprotected_pref_filter->InterceptNextFilterOnLoad( 237 unprotected_pref_filter->InterceptNextFilterOnLoad(
236 base::Bind(&TrackedPreferencesMigrator::InterceptFilterOnLoad, 238 base::Bind(&TrackedPreferencesMigrator::InterceptFilterOnLoad,
237 this, 239 this,
238 UNPROTECTED_PREF_FILTER)); 240 UNPROTECTED_PREF_FILTER));
239 protected_pref_filter->InterceptNextFilterOnLoad( 241 protected_pref_filter->InterceptNextFilterOnLoad(
240 base::Bind(&TrackedPreferencesMigrator::InterceptFilterOnLoad, 242 base::Bind(&TrackedPreferencesMigrator::InterceptFilterOnLoad,
241 this, 243 this,
242 PROTECTED_PREF_FILTER)); 244 PROTECTED_PREF_FILTER));
243 } 245 }
244 246
245 TrackedPreferencesMigrator::~TrackedPreferencesMigrator() {} 247 TrackedPreferencesMigrator::~TrackedPreferencesMigrator() {}
246 248
247 void TrackedPreferencesMigrator::InterceptFilterOnLoad( 249 void TrackedPreferencesMigrator::InterceptFilterOnLoad(
248 PrefFilterID id, 250 PrefFilterID id,
249 const InterceptablePrefFilter::FinalizeFilterOnLoadCallback& 251 const InterceptablePrefFilter::FinalizeFilterOnLoadCallback&
250 finalize_filter_on_load, 252 finalize_filter_on_load,
251 scoped_ptr<base::DictionaryValue> prefs) { 253 scoped_ptr<base::DictionaryValue> prefs) {
252 switch (id) { 254 switch (id) {
253 case UNPROTECTED_PREF_FILTER: 255 case UNPROTECTED_PREF_FILTER:
254 finalize_unprotected_filter_on_load_ = finalize_filter_on_load; 256 finalize_unprotected_filter_on_load_ = finalize_filter_on_load;
255 unprotected_prefs_ = prefs.Pass(); 257 unprotected_prefs_ = std::move(prefs);
256 break; 258 break;
257 case PROTECTED_PREF_FILTER: 259 case PROTECTED_PREF_FILTER:
258 finalize_protected_filter_on_load_ = finalize_filter_on_load; 260 finalize_protected_filter_on_load_ = finalize_filter_on_load;
259 protected_prefs_ = prefs.Pass(); 261 protected_prefs_ = std::move(prefs);
260 break; 262 break;
261 } 263 }
262 264
263 MigrateIfReady(); 265 MigrateIfReady();
264 } 266 }
265 267
266 void TrackedPreferencesMigrator::MigrateIfReady() { 268 void TrackedPreferencesMigrator::MigrateIfReady() {
267 // Wait for both stores to have been read before proceeding. 269 // Wait for both stores to have been read before proceeding.
268 if (!protected_prefs_ || !unprotected_prefs_) 270 if (!protected_prefs_ || !unprotected_prefs_)
269 return; 271 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 CleanupMigratedHashes(unprotected_pref_names_, 304 CleanupMigratedHashes(unprotected_pref_names_,
303 protected_pref_hash_store_.get(), 305 protected_pref_hash_store_.get(),
304 protected_prefs_.get()); 306 protected_prefs_.get());
305 CleanupMigratedHashes(protected_pref_names_, 307 CleanupMigratedHashes(protected_pref_names_,
306 unprotected_pref_hash_store_.get(), 308 unprotected_pref_hash_store_.get(),
307 unprotected_prefs_.get()); 309 unprotected_prefs_.get());
308 legacy_pref_hash_store_->Reset(); 310 legacy_pref_hash_store_->Reset();
309 } 311 }
310 312
311 // Hand the processed prefs back to their respective filters. 313 // Hand the processed prefs back to their respective filters.
312 finalize_unprotected_filter_on_load_.Run(unprotected_prefs_.Pass(), 314 finalize_unprotected_filter_on_load_.Run(std::move(unprotected_prefs_),
313 unprotected_prefs_altered); 315 unprotected_prefs_altered);
314 finalize_protected_filter_on_load_.Run(protected_prefs_.Pass(), 316 finalize_protected_filter_on_load_.Run(std::move(protected_prefs_),
315 protected_prefs_altered); 317 protected_prefs_altered);
316 318
317 if (unprotected_prefs_need_cleanup) { 319 if (unprotected_prefs_need_cleanup) {
318 // Schedule a cleanup of the |protected_pref_names_| from the unprotected 320 // Schedule a cleanup of the |protected_pref_names_| from the unprotected
319 // prefs once the protected prefs were successfully written to disk (or 321 // prefs once the protected prefs were successfully written to disk (or
320 // do it immediately if |!protected_prefs_altered|). 322 // do it immediately if |!protected_prefs_altered|).
321 ScheduleSourcePrefStoreCleanup( 323 ScheduleSourcePrefStoreCleanup(
322 register_on_successful_protected_store_write_callback_, 324 register_on_successful_protected_store_write_callback_,
323 unprotected_store_cleaner_, 325 unprotected_store_cleaner_,
324 protected_pref_names_, 326 protected_pref_names_,
(...skipping 24 matching lines...) Expand all
349 register_on_successful_unprotected_store_write_callback, 351 register_on_successful_unprotected_store_write_callback,
350 const base::Callback<void(const base::Closure&)>& 352 const base::Callback<void(const base::Closure&)>&
351 register_on_successful_protected_store_write_callback, 353 register_on_successful_protected_store_write_callback,
352 scoped_ptr<PrefHashStore> unprotected_pref_hash_store, 354 scoped_ptr<PrefHashStore> unprotected_pref_hash_store,
353 scoped_ptr<PrefHashStore> protected_pref_hash_store, 355 scoped_ptr<PrefHashStore> protected_pref_hash_store,
354 scoped_ptr<HashStoreContents> legacy_pref_hash_store, 356 scoped_ptr<HashStoreContents> legacy_pref_hash_store,
355 InterceptablePrefFilter* unprotected_pref_filter, 357 InterceptablePrefFilter* unprotected_pref_filter,
356 InterceptablePrefFilter* protected_pref_filter) { 358 InterceptablePrefFilter* protected_pref_filter) {
357 scoped_refptr<TrackedPreferencesMigrator> prefs_migrator( 359 scoped_refptr<TrackedPreferencesMigrator> prefs_migrator(
358 new TrackedPreferencesMigrator( 360 new TrackedPreferencesMigrator(
359 unprotected_pref_names, 361 unprotected_pref_names, protected_pref_names,
360 protected_pref_names, 362 unprotected_store_cleaner, protected_store_cleaner,
361 unprotected_store_cleaner,
362 protected_store_cleaner,
363 register_on_successful_unprotected_store_write_callback, 363 register_on_successful_unprotected_store_write_callback,
364 register_on_successful_protected_store_write_callback, 364 register_on_successful_protected_store_write_callback,
365 unprotected_pref_hash_store.Pass(), 365 std::move(unprotected_pref_hash_store),
366 protected_pref_hash_store.Pass(), 366 std::move(protected_pref_hash_store),
367 legacy_pref_hash_store.Pass(), 367 std::move(legacy_pref_hash_store), unprotected_pref_filter,
368 unprotected_pref_filter,
369 protected_pref_filter)); 368 protected_pref_filter));
370 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698