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

Side by Side Diff: components/ntp_tiles/icon_cacher_impl.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_tiles/icon_cacher_impl.h" 5 #include "components/ntp_tiles/icon_cacher_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "components/favicon/core/favicon_service.h" 10 #include "components/favicon/core/favicon_service.h"
11 #include "components/favicon/core/favicon_util.h" 11 #include "components/favicon/core/favicon_util.h"
12 #include "components/favicon/core/large_icon_service.h" 12 #include "components/favicon/core/large_icon_service.h"
13 #include "components/favicon_base/fallback_icon_style.h" 13 #include "components/favicon_base/fallback_icon_style.h"
14 #include "components/favicon_base/favicon_types.h" 14 #include "components/favicon_base/favicon_types.h"
15 #include "components/favicon_base/favicon_util.h" 15 #include "components/favicon_base/favicon_util.h"
16 #include "components/image_fetcher/core/image_decoder.h" 16 #include "components/image_fetcher/core/image_decoder.h"
17 #include "components/image_fetcher/core/image_fetcher.h" 17 #include "components/image_fetcher/core/image_fetcher.h"
18 #include "net/traffic_annotation/network_traffic_annotation.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
20 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 namespace ntp_tiles { 24 namespace ntp_tiles {
24 25
25 namespace { 26 namespace {
26 27
27 constexpr int kDesiredFrameSize = 128; 28 constexpr int kDesiredFrameSize = 128;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const base::Closure& preliminary_icon_available, 94 const base::Closure& preliminary_icon_available,
94 const favicon_base::FaviconImageResult& result) { 95 const favicon_base::FaviconImageResult& result) {
95 if (!result.image.IsEmpty()) { 96 if (!result.image.IsEmpty()) {
96 FinishRequestAndNotifyIconAvailable(site.url, /*newly_available=*/false); 97 FinishRequestAndNotifyIconAvailable(site.url, /*newly_available=*/false);
97 return; 98 return;
98 } 99 }
99 100
100 std::unique_ptr<CancelableImageCallback> preliminary_callback = 101 std::unique_ptr<CancelableImageCallback> preliminary_callback =
101 MaybeProvideDefaultIcon(site, preliminary_icon_available); 102 MaybeProvideDefaultIcon(site, preliminary_icon_available);
102 103
104 net::NetworkTrafficAnnotationTag traffic_annotation =
105 net::DefineNetworkTrafficAnnotation("icon_cacher", R"(
106 semantics {
107 sender: "Popular Sites New Tab Fetch"
108 description:
109 "Chrome may display a list of regionally-popular web sites on the "
110 "New Tab Page. This service fetches icons from those sites."
111 trigger:
112 "Whenever a popular site would be displayed, but its icon is not "
113 "yet cached in the browser."
114 data: "The URL for which to retrieve an icon."
115 destination: WEBSITE
116 }
117 policy {
118 cookies_allowed: false
119 setting: "This feature cannot be disabled in settings."
120 policy_exception_justification: "Not implemented."
121 })");
103 image_fetcher_->StartOrQueueNetworkRequest( 122 image_fetcher_->StartOrQueueNetworkRequest(
104 std::string(), IconURL(site), 123 std::string(), IconURL(site),
105 base::Bind(&IconCacherImpl::OnPopularSitesFaviconDownloaded, 124 base::Bind(&IconCacherImpl::OnPopularSitesFaviconDownloaded,
106 base::Unretained(this), site, 125 base::Unretained(this), site,
107 base::Passed(std::move(preliminary_callback)))); 126 base::Passed(std::move(preliminary_callback))),
127 traffic_annotation);
108 } 128 }
109 129
110 void IconCacherImpl::OnPopularSitesFaviconDownloaded( 130 void IconCacherImpl::OnPopularSitesFaviconDownloaded(
111 PopularSites::Site site, 131 PopularSites::Site site,
112 std::unique_ptr<CancelableImageCallback> preliminary_callback, 132 std::unique_ptr<CancelableImageCallback> preliminary_callback,
113 const std::string& id, 133 const std::string& id,
114 const gfx::Image& fetched_image, 134 const gfx::Image& fetched_image,
115 const image_fetcher::RequestMetadata& metadata) { 135 const image_fetcher::RequestMetadata& metadata) {
116 if (fetched_image.IsEmpty()) { 136 if (fetched_image.IsEmpty()) {
117 FinishRequestAndNotifyIconAvailable(site.url, /*newly_available=*/false); 137 FinishRequestAndNotifyIconAvailable(site.url, /*newly_available=*/false);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return; 237 return;
218 } 238 }
219 for (const base::Closure& callback : callbacks) { 239 for (const base::Closure& callback : callbacks) {
220 if (callback) { 240 if (callback) {
221 callback.Run(); 241 callback.Run();
222 } 242 }
223 } 243 }
224 } 244 }
225 245
226 } // namespace ntp_tiles 246 } // namespace ntp_tiles
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698