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

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

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: 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/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 if Chrome does not have a favicon for a "
376 "particular page. This is done in two scenarios:\n"
377 " 1- For articles suggestions on the new tab page (URLs are public "
378 " and provided by Google).\n"
379 " 2- For server-suggested most visited tiles on the new tab page "
380 " (User gets these URLs from Google, only if history sync is "
381 " enabled)."
382 data: "Page URL and desired icon size."
383 destination: GOOGLE_OWNED_SERVICE
384 }
385 policy {
386 cookies_allowed: false
387 setting: "This feature cannot be disabled by settings."
388 policy_exception_justification: "Not implemented."
389 })");
367 image_fetcher_->StartOrQueueNetworkRequest( 390 image_fetcher_->StartOrQueueNetworkRequest(
368 server_request_url.spec(), server_request_url, 391 server_request_url.spec(), server_request_url,
369 base::Bind(&OnFetchIconFromGoogleServerComplete, favicon_service_, 392 base::Bind(&OnFetchIconFromGoogleServerComplete, favicon_service_,
370 page_url, callback)); 393 page_url, callback),
394 traffic_annotation);
371 } 395 }
372 396
373 base::CancelableTaskTracker::TaskId 397 base::CancelableTaskTracker::TaskId
374 LargeIconService::GetLargeIconOrFallbackStyleImpl( 398 LargeIconService::GetLargeIconOrFallbackStyleImpl(
375 const GURL& page_url, 399 const GURL& page_url,
376 int min_source_size_in_pixel, 400 int min_source_size_in_pixel,
377 int desired_size_in_pixel, 401 int desired_size_in_pixel,
378 const favicon_base::LargeIconCallback& raw_bitmap_callback, 402 const favicon_base::LargeIconCallback& raw_bitmap_callback,
379 const favicon_base::LargeIconImageCallback& image_callback, 403 const favicon_base::LargeIconImageCallback& image_callback,
380 base::CancelableTaskTracker* tracker) { 404 base::CancelableTaskTracker* tracker) {
381 DCHECK_LE(1, min_source_size_in_pixel); 405 DCHECK_LE(1, min_source_size_in_pixel);
382 DCHECK_LE(0, desired_size_in_pixel); 406 DCHECK_LE(0, desired_size_in_pixel);
383 407
384 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker( 408 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker(
385 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback, 409 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback,
386 image_callback, background_task_runner_, tracker); 410 image_callback, background_task_runner_, tracker);
387 411
388 // TODO(beaudoin): For now this is just a wrapper around 412 // TODO(beaudoin): For now this is just a wrapper around
389 // GetLargestRawFaviconForPageURL. Add the logic required to select the best 413 // GetLargestRawFaviconForPageURL. Add the logic required to select the best
390 // possible large icon. Also add logic to fetch-on-demand when the URL of 414 // 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. 415 // a large icon is known but its bitmap is not available.
392 return favicon_service_->GetLargestRawFaviconForPageURL( 416 return favicon_service_->GetLargestRawFaviconForPageURL(
393 page_url, large_icon_types_, min_source_size_in_pixel, 417 page_url, large_icon_types_, min_source_size_in_pixel,
394 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker); 418 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker);
395 } 419 }
396 420
397 } // namespace favicon 421 } // namespace favicon
OLDNEW
« no previous file with comments | « components/doodle/doodle_service_unittest.cc ('k') | components/favicon/core/large_icon_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698