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

Side by Side Diff: components/translate/core/browser/language_model.cc

Issue 2662783003: [LanguageModel] Clear the model when clearing full history (Closed)
Patch Set: Manual merge Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/translate/core/browser/language_model.h" 5 #include "components/translate/core/browser/language_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 base::DictionaryValue* dict = update.Get(); 125 base::DictionaryValue* dict = update.Get();
126 int counter_value = 0; 126 int counter_value = 0;
127 // If the key |language_code| does not exist, |counter_value| stays 0. 127 // If the key |language_code| does not exist, |counter_value| stays 0.
128 dict->GetInteger(language_code, &counter_value); 128 dict->GetInteger(language_code, &counter_value);
129 dict->SetInteger(language_code, counter_value + 1); 129 dict->SetInteger(language_code, counter_value + 1);
130 130
131 if (GetCountersSum(*dict) > kMaxCountersSum) 131 if (GetCountersSum(*dict) > kMaxCountersSum)
132 DiscountAndCleanCounters(dict); 132 DiscountAndCleanCounters(dict);
133 } 133 }
134 134
135 void LanguageModel::ClearHistory(base::Time begin, base::Time end) {
136 // Ignore all partial removals and react only to "entire" history removal.
137 bool is_entire_history = (begin == base::Time() && end == base::Time::Max());
138 if (!is_entire_history) {
139 return;
140 }
141
142 pref_service_->ClearPref(kLanguageModelCounters);
143 }
144
135 } // namespace translate 145 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/core/browser/language_model.h ('k') | components/translate/core/browser/language_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698