| 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/content_suggestions_service.h" | 5 #include "components/ntp_snippets/content_suggestions_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 LOG(WARNING) << "Requested image for suggestion " << suggestion_id | 74 LOG(WARNING) << "Requested image for suggestion " << suggestion_id |
| 75 << " for unavailable category " << category; | 75 << " for unavailable category " << category; |
| 76 base::ThreadTaskRunnerHandle::Get()->PostTask( | 76 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 77 FROM_HERE, base::Bind(callback, gfx::Image())); | 77 FROM_HERE, base::Bind(callback, gfx::Image())); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 providers_by_category_[category]->FetchSuggestionImage(suggestion_id, | 80 providers_by_category_[category]->FetchSuggestionImage(suggestion_id, |
| 81 callback); | 81 callback); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ContentSuggestionsService::ClearHistory( |
| 85 base::Time begin, |
| 86 base::Time end, |
| 87 base::Callback<bool(const GURL& url)> filter) { |
| 88 for (const auto& provider : providers_) { |
| 89 provider->ClearHistory(begin, end, filter); |
| 90 } |
| 91 } |
| 92 |
| 84 void ContentSuggestionsService::ClearAllCachedSuggestions() { | 93 void ContentSuggestionsService::ClearAllCachedSuggestions() { |
| 85 suggestions_by_category_.clear(); | 94 suggestions_by_category_.clear(); |
| 86 id_category_map_.clear(); | 95 id_category_map_.clear(); |
| 87 for (const auto& category_provider_pair : providers_by_category_) { | 96 for (const auto& category_provider_pair : providers_by_category_) { |
| 88 category_provider_pair.second->ClearCachedSuggestions( | 97 category_provider_pair.second->ClearCachedSuggestions( |
| 89 category_provider_pair.first); | 98 category_provider_pair.first); |
| 90 FOR_EACH_OBSERVER(Observer, observers_, | 99 FOR_EACH_OBSERVER(Observer, observers_, |
| 91 OnNewSuggestions(category_provider_pair.first)); | 100 OnNewSuggestions(category_provider_pair.first)); |
| 92 } | 101 } |
| 93 } | 102 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 if (left.IsKnownCategory(KnownCategories::BOOKMARKS)) | 292 if (left.IsKnownCategory(KnownCategories::BOOKMARKS)) |
| 284 return false; | 293 return false; |
| 285 if (right.IsKnownCategory(KnownCategories::BOOKMARKS)) | 294 if (right.IsKnownCategory(KnownCategories::BOOKMARKS)) |
| 286 return true; | 295 return true; |
| 287 } | 296 } |
| 288 return category_factory_.CompareCategories(left, right); | 297 return category_factory_.CompareCategories(left, right); |
| 289 }); | 298 }); |
| 290 } | 299 } |
| 291 | 300 |
| 292 } // namespace ntp_snippets | 301 } // namespace ntp_snippets |
| OLD | NEW |