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

Side by Side Diff: components/ntp_snippets/remote/remote_suggestions_provider_impl.cc

Issue 2715153006: Set desired_image_size when decoding images for NTP Tile icons. (Closed)
Patch Set: comment formatting Created 3 years, 9 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/remote/remote_suggestions_provider_impl.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "components/data_use_measurement/core/data_use_user_data.h" 23 #include "components/data_use_measurement/core/data_use_user_data.h"
24 #include "components/image_fetcher/image_decoder.h" 24 #include "components/image_fetcher/image_decoder.h"
25 #include "components/image_fetcher/image_fetcher.h" 25 #include "components/image_fetcher/image_fetcher.h"
26 #include "components/ntp_snippets/category_rankers/category_ranker.h" 26 #include "components/ntp_snippets/category_rankers/category_ranker.h"
27 #include "components/ntp_snippets/pref_names.h" 27 #include "components/ntp_snippets/pref_names.h"
28 #include "components/ntp_snippets/remote/remote_suggestions_database.h" 28 #include "components/ntp_snippets/remote/remote_suggestions_database.h"
29 #include "components/ntp_snippets/switches.h" 29 #include "components/ntp_snippets/switches.h"
30 #include "components/prefs/pref_registry_simple.h" 30 #include "components/prefs/pref_registry_simple.h"
31 #include "components/prefs/pref_service.h" 31 #include "components/prefs/pref_service.h"
32 #include "components/strings/grit/components_strings.h" 32 #include "components/strings/grit/components_strings.h"
33 #include "ui/gfx/geometry/size.h"
33 #include "ui/gfx/image/image.h" 34 #include "ui/gfx/image/image.h"
34 35
35 namespace ntp_snippets { 36 namespace ntp_snippets {
36 37
37 namespace { 38 namespace {
38 39
39 // Number of suggestions requested to the server. Consider replacing sparse UMA 40 // Number of suggestions requested to the server. Consider replacing sparse UMA
40 // histograms with COUNTS() if this number increases beyond 50. 41 // histograms with COUNTS() if this number increases beyond 50.
41 const int kMaxSuggestionCount = 10; 42 const int kMaxSuggestionCount = 10;
42 43
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 209 }
209 210
210 void CachedImageFetcher::OnImageFetchedFromDatabase( 211 void CachedImageFetcher::OnImageFetchedFromDatabase(
211 const ImageFetchedCallback& callback, 212 const ImageFetchedCallback& callback,
212 const ContentSuggestion::ID& suggestion_id, 213 const ContentSuggestion::ID& suggestion_id,
213 const GURL& url, 214 const GURL& url,
214 std::string data) { // SnippetImageCallback requires by-value. 215 std::string data) { // SnippetImageCallback requires by-value.
215 // |image_decoder_| is null in tests. 216 // |image_decoder_| is null in tests.
216 if (image_decoder_ && !data.empty()) { 217 if (image_decoder_ && !data.empty()) {
217 image_decoder_->DecodeImage( 218 image_decoder_->DecodeImage(
218 data, base::Bind(&CachedImageFetcher::OnImageDecodedFromDatabase, 219 data,
219 base::Unretained(this), callback, suggestion_id, url)); 220 // We're not dealing with multi-frame images.
221 /*desired_image_frame_size=*/gfx::Size(),
222 base::Bind(&CachedImageFetcher::OnImageDecodedFromDatabase,
223 base::Unretained(this), callback, suggestion_id, url));
220 return; 224 return;
221 } 225 }
222 // Fetching from the DB failed; start a network fetch. 226 // Fetching from the DB failed; start a network fetch.
223 FetchImageFromNetwork(suggestion_id, url, callback); 227 FetchImageFromNetwork(suggestion_id, url, callback);
224 } 228 }
225 229
226 void CachedImageFetcher::OnImageDecodedFromDatabase( 230 void CachedImageFetcher::OnImageDecodedFromDatabase(
227 const ImageFetchedCallback& callback, 231 const ImageFetchedCallback& callback,
228 const ContentSuggestion::ID& suggestion_id, 232 const ContentSuggestion::ID& suggestion_id,
229 const GURL& url, 233 const GURL& url,
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent( 1274 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent(
1271 CategoryContent&&) = default; 1275 CategoryContent&&) = default;
1272 1276
1273 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default; 1277 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default;
1274 1278
1275 RemoteSuggestionsProviderImpl::CategoryContent& 1279 RemoteSuggestionsProviderImpl::CategoryContent&
1276 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) = 1280 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) =
1277 default; 1281 default;
1278 1282
1279 } // namespace ntp_snippets 1283 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698