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

Side by Side Diff: components/favicon/core/large_icon_service.cc

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: Annotation updated. 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/favicon/core/large_icon_service.h" 5 #include "components/favicon/core/large_icon_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 if (!server_request_url.is_valid() || !trimmed_page_url.is_valid() || 357 if (!server_request_url.is_valid() || !trimmed_page_url.is_valid() ||
358 !image_fetcher_ || 358 !image_fetcher_ ||
359 favicon_service_->WasUnableToDownloadFavicon(server_request_url)) { 359 favicon_service_->WasUnableToDownloadFavicon(server_request_url)) {
360 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 360 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
361 base::Bind(callback, false)); 361 base::Bind(callback, false));
362 return; 362 return;
363 } 363 }
364 364
365 image_fetcher_->SetDataUseServiceName( 365 image_fetcher_->SetDataUseServiceName(
366 data_use_measurement::DataUseUserData::LARGE_ICON_SERVICE); 366 data_use_measurement::DataUseUserData::LARGE_ICON_SERVICE);
367 net::NetworkTrafficAnnotationTag traffic_annotation =
368 net::DefineNetworkTrafficAnnotation("favicon_component", R"(
369 semantics {
370 sender: "Favicon Component"
371 description:
372 "Sends a request to a Google server to retrieve the favicon bitmap "
373 "for a page URL."
374 trigger:
375 "A request can be sent for signed-in users when Chrome does not "
376 "have a favicon for a particular page. This is done in two "
377 "scenarios:\n"
378 " 1- For articles suggestions on the new tab page (URLs are public "
379 " and provided by Google).\n"
380 " 2- For server-suggested most visited tiles on the new tab page "
381 " (User gets these URLs from Google, only if history sync is "
382 " enabled)."
383 data: "Page URL and desired icon size."
384 destination: GOOGLE_OWNED_SERVICE
385 }
386 policy {
387 cookies_allowed: false
388 setting: "This feature cannot be disabled by settings."
msramek 2017/05/19 08:47:38 Since the trigger says "signed-in users", should t
Ramin Halavati 2017/05/19 09:03:37 But scenario one is not covered by this policy. I
389 policy_exception_justification: "Not implemented."
390 })");
367 image_fetcher_->StartOrQueueNetworkRequest( 391 image_fetcher_->StartOrQueueNetworkRequest(
368 server_request_url.spec(), server_request_url, 392 server_request_url.spec(), server_request_url,
369 base::Bind(&OnFetchIconFromGoogleServerComplete, favicon_service_, 393 base::Bind(&OnFetchIconFromGoogleServerComplete, favicon_service_,
370 page_url, callback)); 394 page_url, callback),
395 traffic_annotation);
371 } 396 }
372 397
373 base::CancelableTaskTracker::TaskId 398 base::CancelableTaskTracker::TaskId
374 LargeIconService::GetLargeIconOrFallbackStyleImpl( 399 LargeIconService::GetLargeIconOrFallbackStyleImpl(
375 const GURL& page_url, 400 const GURL& page_url,
376 int min_source_size_in_pixel, 401 int min_source_size_in_pixel,
377 int desired_size_in_pixel, 402 int desired_size_in_pixel,
378 const favicon_base::LargeIconCallback& raw_bitmap_callback, 403 const favicon_base::LargeIconCallback& raw_bitmap_callback,
379 const favicon_base::LargeIconImageCallback& image_callback, 404 const favicon_base::LargeIconImageCallback& image_callback,
380 base::CancelableTaskTracker* tracker) { 405 base::CancelableTaskTracker* tracker) {
381 DCHECK_LE(1, min_source_size_in_pixel); 406 DCHECK_LE(1, min_source_size_in_pixel);
382 DCHECK_LE(0, desired_size_in_pixel); 407 DCHECK_LE(0, desired_size_in_pixel);
383 408
384 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker( 409 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker(
385 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback, 410 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback,
386 image_callback, background_task_runner_, tracker); 411 image_callback, background_task_runner_, tracker);
387 412
388 // TODO(beaudoin): For now this is just a wrapper around 413 // TODO(beaudoin): For now this is just a wrapper around
389 // GetLargestRawFaviconForPageURL. Add the logic required to select the best 414 // GetLargestRawFaviconForPageURL. Add the logic required to select the best
390 // possible large icon. Also add logic to fetch-on-demand when the URL of 415 // possible large icon. Also add logic to fetch-on-demand when the URL of
391 // a large icon is known but its bitmap is not available. 416 // a large icon is known but its bitmap is not available.
392 return favicon_service_->GetLargestRawFaviconForPageURL( 417 return favicon_service_->GetLargestRawFaviconForPageURL(
393 page_url, large_icon_types_, min_source_size_in_pixel, 418 page_url, large_icon_types_, min_source_size_in_pixel,
394 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker); 419 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker);
395 } 420 }
396 421
397 } // namespace favicon 422 } // namespace favicon
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698