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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 2280543003: Remove snippet_id from ImageFetchedCallback (Closed)
Patch Set: Created 4 years, 3 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 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 688
689 // Fetching from the DB failed; start a network fetch. 689 // Fetching from the DB failed; start a network fetch.
690 FetchSnippetImageFromNetwork(snippet_id, callback); 690 FetchSnippetImageFromNetwork(snippet_id, callback);
691 } 691 }
692 692
693 void NTPSnippetsService::OnSnippetImageDecodedFromDatabase( 693 void NTPSnippetsService::OnSnippetImageDecodedFromDatabase(
694 const ImageFetchedCallback& callback, 694 const ImageFetchedCallback& callback,
695 const std::string& snippet_id, 695 const std::string& snippet_id,
696 const gfx::Image& image) { 696 const gfx::Image& image) {
697 if (!image.IsEmpty()) { 697 if (!image.IsEmpty()) {
698 callback.Run(MakeUniqueID(provided_category_, snippet_id), image); 698 callback.Run(image);
699 return; 699 return;
700 } 700 }
701 701
702 // If decoding the image failed, delete the DB entry. 702 // If decoding the image failed, delete the DB entry.
703 database_->DeleteImage(snippet_id); 703 database_->DeleteImage(snippet_id);
704 704
705 FetchSnippetImageFromNetwork(snippet_id, callback); 705 FetchSnippetImageFromNetwork(snippet_id, callback);
706 } 706 }
707 707
708 void NTPSnippetsService::FetchSnippetImageFromNetwork( 708 void NTPSnippetsService::FetchSnippetImageFromNetwork(
(...skipping 26 matching lines...) Expand all
735 image_fetcher_->StartOrQueueNetworkRequest( 735 image_fetcher_->StartOrQueueNetworkRequest(
736 snippet.id(), snippet.salient_image_url(), 736 snippet.id(), snippet.salient_image_url(),
737 base::Bind(&NTPSnippetsService::OnSnippetImageDecodedFromNetwork, 737 base::Bind(&NTPSnippetsService::OnSnippetImageDecodedFromNetwork,
738 base::Unretained(this), callback)); 738 base::Unretained(this), callback));
739 } 739 }
740 740
741 void NTPSnippetsService::OnSnippetImageDecodedFromNetwork( 741 void NTPSnippetsService::OnSnippetImageDecodedFromNetwork(
742 const ImageFetchedCallback& callback, 742 const ImageFetchedCallback& callback,
743 const std::string& snippet_id, 743 const std::string& snippet_id,
744 const gfx::Image& image) { 744 const gfx::Image& image) {
745 callback.Run(MakeUniqueID(provided_category_, snippet_id), image); 745 callback.Run(image);
746 } 746 }
747 747
748 void NTPSnippetsService::EnterStateEnabled(bool fetch_snippets) { 748 void NTPSnippetsService::EnterStateEnabled(bool fetch_snippets) {
749 if (fetch_snippets) 749 if (fetch_snippets)
750 FetchSnippets(/*force_request=*/false); 750 FetchSnippets(/*force_request=*/false);
751 751
752 // FetchSnippets should set the status to |AVAILABLE_LOADING| if relevant, 752 // FetchSnippets should set the status to |AVAILABLE_LOADING| if relevant,
753 // otherwise we transition to |AVAILABLE| here. 753 // otherwise we transition to |AVAILABLE| here.
754 if (category_status_ != CategoryStatus::AVAILABLE_LOADING) 754 if (category_status_ != CategoryStatus::AVAILABLE_LOADING)
755 UpdateCategoryStatus(CategoryStatus::AVAILABLE); 755 UpdateCategoryStatus(CategoryStatus::AVAILABLE);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) { 887 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) {
888 if (status == category_status_) 888 if (status == category_status_)
889 return; 889 return;
890 890
891 category_status_ = status; 891 category_status_ = status;
892 observer()->OnCategoryStatusChanged(this, provided_category_, 892 observer()->OnCategoryStatusChanged(this, provided_category_,
893 category_status_); 893 category_status_);
894 } 894 }
895 895
896 } // namespace ntp_snippets 896 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698