OLD | NEW |
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/ntp_snippets/category_rankers/click_based_category_ranker.h
" | 5 #include "components/ntp_snippets/category_rankers/click_based_category_ranker.h
" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 AppendKnownCategory(known_category); | 377 AppendKnownCategory(known_category); |
378 } | 378 } |
379 | 379 |
380 StoreOrderToPrefs(ordered_categories_); | 380 StoreOrderToPrefs(ordered_categories_); |
381 } | 381 } |
382 | 382 |
383 void ClickBasedCategoryRanker::AppendKnownCategory( | 383 void ClickBasedCategoryRanker::AppendKnownCategory( |
384 KnownCategories known_category) { | 384 KnownCategories known_category) { |
385 Category category = Category::FromKnownCategory(known_category); | 385 Category category = Category::FromKnownCategory(known_category); |
386 DCHECK(!ContainsCategory(category)); | 386 DCHECK(!ContainsCategory(category)); |
387 ordered_categories_.push_back(RankedCategory( | 387 ordered_categories_.push_back( |
388 category, /*clicks=*/0, /*last_dismissed=*/base::Time())); | 388 RankedCategory(category, /*clicks=*/0, /*last_dismissed=*/base::Time())); |
389 } | 389 } |
390 | 390 |
391 namespace { | 391 namespace { |
392 | 392 |
393 base::Time ParseLastDismissedDate(const base::DictionaryValue& value) { | 393 base::Time ParseLastDismissedDate(const base::DictionaryValue& value) { |
394 // We don't expect the last-dismissed value to be present in all cases (we | 394 // We don't expect the last-dismissed value to be present in all cases (we |
395 // added this after the fact). | 395 // added this after the fact). |
396 std::string serialized_value; | 396 std::string serialized_value; |
397 int64_t parsed_value; | 397 int64_t parsed_value; |
398 if (value.GetString(kLastDismissedKey, &serialized_value) && | 398 if (value.GetString(kLastDismissedKey, &serialized_value) && |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 num_pending_decays * GetTimeBetweenDecays()); | 519 num_pending_decays * GetTimeBetweenDecays()); |
520 | 520 |
521 if (executed_decays > 0) { | 521 if (executed_decays > 0) { |
522 StoreOrderToPrefs(ordered_categories_); | 522 StoreOrderToPrefs(ordered_categories_); |
523 return true; | 523 return true; |
524 } | 524 } |
525 return false; | 525 return false; |
526 } | 526 } |
527 | 527 |
528 } // namespace ntp_snippets | 528 } // namespace ntp_snippets |
OLD | NEW |