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

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

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: All comments addressed. Created 3 years, 7 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 15 matching lines...) Expand all
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/features.h" 27 #include "components/ntp_snippets/features.h"
28 #include "components/ntp_snippets/pref_names.h" 28 #include "components/ntp_snippets/pref_names.h"
29 #include "components/ntp_snippets/remote/remote_suggestions_database.h" 29 #include "components/ntp_snippets/remote/remote_suggestions_database.h"
30 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" 30 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h"
31 #include "components/ntp_snippets/switches.h" 31 #include "components/ntp_snippets/switches.h"
32 #include "components/prefs/pref_registry_simple.h" 32 #include "components/prefs/pref_registry_simple.h"
33 #include "components/prefs/pref_service.h" 33 #include "components/prefs/pref_service.h"
34 #include "components/strings/grit/components_strings.h" 34 #include "components/strings/grit/components_strings.h"
35 #include "components/variations/variations_associated_data.h" 35 #include "components/variations/variations_associated_data.h"
36 #include "net/traffic_annotation/network_traffic_annotation.h"
36 #include "ui/gfx/geometry/size.h" 37 #include "ui/gfx/geometry/size.h"
37 #include "ui/gfx/image/image.h" 38 #include "ui/gfx/image/image.h"
38 39
39 namespace ntp_snippets { 40 namespace ntp_snippets {
40 41
41 namespace { 42 namespace {
42 43
43 // Number of suggestions requested to the server. Consider replacing sparse UMA 44 // Number of suggestions requested to the server. Consider replacing sparse UMA
44 // histograms with COUNTS() if this number increases beyond 50. 45 // histograms with COUNTS() if this number increases beyond 50.
45 const int kMaxSuggestionCount = 10; 46 const int kMaxSuggestionCount = 10;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 const ImageFetchedCallback& callback) { 282 const ImageFetchedCallback& callback) {
282 if (url.is_empty() || !thumbnail_requests_throttler_.DemandQuotaForRequest( 283 if (url.is_empty() || !thumbnail_requests_throttler_.DemandQuotaForRequest(
283 /*interactive_request=*/true)) { 284 /*interactive_request=*/true)) {
284 // Return an empty image. Directly, this is never synchronous with the 285 // Return an empty image. Directly, this is never synchronous with the
285 // original FetchSuggestionImage() call - an asynchronous database query has 286 // original FetchSuggestionImage() call - an asynchronous database query has
286 // happened in the meantime. 287 // happened in the meantime.
287 callback.Run(gfx::Image()); 288 callback.Run(gfx::Image());
288 return; 289 return;
289 } 290 }
290 291
292 net::NetworkTrafficAnnotationTag traffic_annotation =
293 net::DefineNetworkTrafficAnnotation("remote_suggestions_service", R"(
Marc Treib 2017/05/09 14:08:19 Sorry, this should be remote_suggestions_provider
Ramin Halavati 2017/05/10 05:41:02 Done.
294 semantics {
295 sender: "Content Suggestion Thumbnail Fetch"
296 description:
297 "Retrieves thumbnails for content suggestions, for display on the "
298 "New Tab page or Chrome Home."
299 trigger:
300 "Triggered when the user looks at a content suggestion (and its "
301 "thumbnail isn't cached yet)."
302 data: "None."
303 destination: GOOGLE_OWNED_SERVICE
304 }
305 policy {
306 cookies_allowed: false
307 setting: "Currently not available, but in progress: crbug.com/703684"
308 chrome_policy {
309 NTPContentSuggestionsEnabled {
310 policy_options {mode: MANDATORY}
311 NTPContentSuggestionsEnabled: false
312 }
313 }
314 })");
291 image_fetcher_->StartOrQueueNetworkRequest( 315 image_fetcher_->StartOrQueueNetworkRequest(
292 suggestion_id.id_within_category(), url, 316 suggestion_id.id_within_category(), url,
293 base::Bind(&CachedImageFetcher::OnImageDecodingDone, 317 base::Bind(&CachedImageFetcher::OnImageDecodingDone,
294 base::Unretained(this), callback)); 318 base::Unretained(this), callback),
319 traffic_annotation);
295 } 320 }
296 321
297 RemoteSuggestionsProviderImpl::RemoteSuggestionsProviderImpl( 322 RemoteSuggestionsProviderImpl::RemoteSuggestionsProviderImpl(
298 Observer* observer, 323 Observer* observer,
299 PrefService* pref_service, 324 PrefService* pref_service,
300 const std::string& application_language_code, 325 const std::string& application_language_code,
301 CategoryRanker* category_ranker, 326 CategoryRanker* category_ranker,
302 RemoteSuggestionsScheduler* scheduler, 327 RemoteSuggestionsScheduler* scheduler,
303 std::unique_ptr<RemoteSuggestionsFetcher> suggestions_fetcher, 328 std::unique_ptr<RemoteSuggestionsFetcher> suggestions_fetcher,
304 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher, 329 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher,
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent( 1373 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent(
1349 CategoryContent&&) = default; 1374 CategoryContent&&) = default;
1350 1375
1351 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default; 1376 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default;
1352 1377
1353 RemoteSuggestionsProviderImpl::CategoryContent& 1378 RemoteSuggestionsProviderImpl::CategoryContent&
1354 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) = 1379 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) =
1355 default; 1380 default;
1356 1381
1357 } // namespace ntp_snippets 1382 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698