OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 DCHECK_GT(next_expiry, expiry); | 622 DCHECK_GT(next_expiry, expiry); |
623 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, | 623 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, |
624 base::Bind(&NTPSnippetsService::ClearExpiredSnippets, | 624 base::Bind(&NTPSnippetsService::ClearExpiredSnippets, |
625 base::Unretained(this))); | 625 base::Unretained(this))); |
626 } | 626 } |
627 | 627 |
628 void NTPSnippetsService::OnSnippetImageFetchedFromDatabase( | 628 void NTPSnippetsService::OnSnippetImageFetchedFromDatabase( |
629 const std::string& snippet_id, | 629 const std::string& snippet_id, |
630 const ImageFetchedCallback& callback, | 630 const ImageFetchedCallback& callback, |
631 std::string data) { | 631 std::string data) { |
632 // |image_decoder_| is null on iOS and in tests. | 632 // |image_decoder_| is null in tests. |
633 if (image_decoder_ && !data.empty()) { | 633 if (image_decoder_ && !data.empty()) { |
634 image_decoder_->DecodeImage( | 634 image_decoder_->DecodeImage( |
635 std::move(data), | 635 std::move(data), |
636 base::Bind(&NTPSnippetsService::OnSnippetImageDecoded, | 636 base::Bind(&NTPSnippetsService::OnSnippetImageDecoded, |
637 base::Unretained(this), snippet_id, callback)); | 637 base::Unretained(this), snippet_id, callback)); |
638 return; | 638 return; |
639 } | 639 } |
640 | 640 |
641 // Fetching from the DB failed; start a network fetch. | 641 // Fetching from the DB failed; start a network fetch. |
642 FetchSnippetImageFromNetwork(snippet_id, callback); | 642 FetchSnippetImageFromNetwork(snippet_id, callback); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 return; | 806 return; |
807 } | 807 } |
808 } | 808 } |
809 | 809 |
810 void NTPSnippetsService::ClearDeprecatedPrefs() { | 810 void NTPSnippetsService::ClearDeprecatedPrefs() { |
811 pref_service_->ClearPref(prefs::kDeprecatedSnippets); | 811 pref_service_->ClearPref(prefs::kDeprecatedSnippets); |
812 pref_service_->ClearPref(prefs::kDeprecatedDiscardedSnippets); | 812 pref_service_->ClearPref(prefs::kDeprecatedDiscardedSnippets); |
813 } | 813 } |
814 | 814 |
815 } // namespace ntp_snippets | 815 } // namespace ntp_snippets |
OLD | NEW |