Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / components / suggestions / suggestions_store.h
blob78ff7f6b17cb900816060ed5f2dbcb3ce3bdf0da
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.
5 #ifndef COMPONENTS_SUGGESTIONS_SUGGESTIONS_STORE_H_
6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_STORE_H_
8 #include "base/macros.h"
9 #include "components/suggestions/proto/suggestions.pb.h"
11 class PrefService;
13 namespace user_prefs {
14 class PrefRegistrySyncable;
15 } // namespace user_prefs
17 namespace suggestions {
19 // A helper class for reading and writing the suggestions to the profile's
20 // preference file.
21 class SuggestionsStore {
22 public:
23 explicit SuggestionsStore(PrefService* profile_prefs);
24 virtual ~SuggestionsStore();
26 // Loads the suggestion data from the profile's preferences into
27 // |suggestions|. If there is a problem with loading, the pref value is
28 // cleared, false is returned and |suggestions| is cleared. If successful,
29 // |suggestions| will contain the loaded data and true is returned.
30 virtual bool LoadSuggestions(SuggestionsProfile* suggestions);
32 // Stores the provided |suggestions| to the profile's preferences, using
33 // a base64 encoding of its protobuf serialization.
34 virtual bool StoreSuggestions(const SuggestionsProfile& suggestions);
36 // Clears any suggestion data from the profile's preferences.
37 virtual void ClearSuggestions();
39 // Register SuggestionsStore related prefs in the Profile prefs.
40 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
42 protected:
43 // Test seam. For simplicity of mock creation.
44 SuggestionsStore() {}
46 private:
47 // The pref service used to persist the suggestions data.
48 PrefService* pref_service_;
50 DISALLOW_COPY_AND_ASSIGN(SuggestionsStore);
52 // Filters expired suggestions.
53 void FilterExpiredSuggestions(SuggestionsProfile* suggestions);
56 } // namespace suggestions
58 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_STORE_H_