OLD | NEW |
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/suggestions/suggestions_store.h" | 5 #include "components/suggestions/suggestions_store.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | |
9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
10 | 10 |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/time/default_clock.h" | 13 #include "base/time/default_clock.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
16 #include "components/suggestions/suggestions_pref_names.h" | 16 #include "components/suggestions/suggestions_pref_names.h" |
17 | 17 |
18 namespace suggestions { | 18 namespace suggestions { |
19 | 19 |
20 SuggestionsStore::SuggestionsStore(PrefService* profile_prefs) | 20 SuggestionsStore::SuggestionsStore(PrefService* profile_prefs) |
21 : pref_service_(profile_prefs), clock_(new base::DefaultClock()) { | 21 : pref_service_(profile_prefs), clock_(new base::DefaultClock()) { |
22 DCHECK(profile_prefs); | 22 DCHECK(profile_prefs); |
23 } | 23 } |
24 | 24 |
25 SuggestionsStore::SuggestionsStore() { | 25 SuggestionsStore::SuggestionsStore() { |
26 } | 26 } |
27 | 27 |
28 SuggestionsStore::~SuggestionsStore() {} | 28 SuggestionsStore::~SuggestionsStore() {} |
29 | 29 |
30 void SuggestionsStore::SetClockForTesting(scoped_ptr<base::Clock> test_clock) { | 30 void SuggestionsStore::SetClockForTesting(scoped_ptr<base::Clock> test_clock) { |
31 this->clock_ = test_clock.Pass(); | 31 this->clock_ = std::move(test_clock); |
32 } | 32 } |
33 | 33 |
34 bool SuggestionsStore::LoadSuggestions(SuggestionsProfile* suggestions) { | 34 bool SuggestionsStore::LoadSuggestions(SuggestionsProfile* suggestions) { |
35 DCHECK(suggestions); | 35 DCHECK(suggestions); |
36 | 36 |
37 const std::string base64_suggestions_data = | 37 const std::string base64_suggestions_data = |
38 pref_service_->GetString(prefs::kSuggestionsData); | 38 pref_service_->GetString(prefs::kSuggestionsData); |
39 if (base64_suggestions_data.empty()) { | 39 if (base64_suggestions_data.empty()) { |
40 suggestions->Clear(); | 40 suggestions->Clear(); |
41 return false; | 41 return false; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 pref_service_->ClearPref(prefs::kSuggestionsData); | 98 pref_service_->ClearPref(prefs::kSuggestionsData); |
99 } | 99 } |
100 | 100 |
101 // static | 101 // static |
102 void SuggestionsStore::RegisterProfilePrefs( | 102 void SuggestionsStore::RegisterProfilePrefs( |
103 user_prefs::PrefRegistrySyncable* registry) { | 103 user_prefs::PrefRegistrySyncable* registry) { |
104 registry->RegisterStringPref(prefs::kSuggestionsData, std::string()); | 104 registry->RegisterStringPref(prefs::kSuggestionsData, std::string()); |
105 } | 105 } |
106 | 106 |
107 } // namespace suggestions | 107 } // namespace suggestions |
OLD | NEW |