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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_
6#define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_
7
8#include <set>
9#include <string>
10
11#include "base/callback_forward.h"
12#include "base/memory/scoped_ptr.h"
13#include "chrome/browser/prefs/pref_hash_store.h"
14
15class HashStoreContents;
16class InterceptablePrefFilter;
17class PrefHashStore;
18
19// Sets up InterceptablePrefFilter::FilterOnLoadInterceptors on
20// |unprotected_pref_filter| and |protected_pref_filter| which prevents each
21// filter from running their on load operations until the interceptors decide to
22// hand the prefs back to them (after migration is complete). |
23// (un)protected_store_cleaner| and
24// |register_on_successful_(un)protected_store_write_callback| are used to do
25// post-migration cleanup tasks. Those should be bound to weak pointers to avoid
26// blocking shutdown. |(un)protected_pref_hash_store| and
27// |legacy_pref_hash_store| are used to migrate MACs along with their protected
28// preferences and/or from the legacy location in Local State. Migrated MACs
29// will only be cleared from their old location in a subsequent run. The
30// migration framework is resilient to a failed cleanup (it will simply try
31// again in the next Chrome run).
32void SetupTrackedPreferencesMigration(
33    const std::set<std::string>& unprotected_pref_names,
34    const std::set<std::string>& protected_pref_names,
35    const base::Callback<void(const std::string& key)>&
36        unprotected_store_cleaner,
37    const base::Callback<void(const std::string& key)>& protected_store_cleaner,
38    const base::Callback<void(const base::Closure&)>&
39        register_on_successful_unprotected_store_write_callback,
40    const base::Callback<void(const base::Closure&)>&
41        register_on_successful_protected_store_write_callback,
42    scoped_ptr<PrefHashStore> unprotected_pref_hash_store,
43    scoped_ptr<PrefHashStore> protected_pref_hash_store,
44    scoped_ptr<HashStoreContents> legacy_pref_hash_store,
45    InterceptablePrefFilter* unprotected_pref_filter,
46    InterceptablePrefFilter* protected_pref_filter);
47
48#endif  // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_
49