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

Side by Side Diff: components/search_provider_logos/logo_tracker.cc

Issue 2718443002: Network traffic annotation added to logo_tracker. (Closed)
Patch Set: Annotation updated. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/search_provider_logos/logo_tracker.h" 5 #include "components/search_provider_logos/logo_tracker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/task_runner_util.h" 13 #include "base/task_runner_util.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/time/default_clock.h" 15 #include "base/time/default_clock.h"
16 #include "components/data_use_measurement/core/data_use_user_data.h" 16 #include "components/data_use_measurement/core/data_use_user_data.h"
17 #include "components/search_provider_logos/switches.h" 17 #include "components/search_provider_logos/switches.h"
18 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
19 #include "net/http/http_status_code.h" 19 #include "net/http/http_status_code.h"
20 #include "net/traffic_annotation/network_traffic_annotation.h"
20 #include "net/url_request/url_fetcher.h" 21 #include "net/url_request/url_fetcher.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 #include "net/url_request/url_request_status.h" 23 #include "net/url_request/url_request_status.h"
23 24
24 namespace search_provider_logos { 25 namespace search_provider_logos {
25 26
26 namespace { 27 namespace {
27 28
28 const int64_t kMaxDownloadBytes = 1024 * 1024; 29 const int64_t kMaxDownloadBytes = 1024 * 1024;
29 30
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 220 }
220 GURL url; 221 GURL url;
221 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 222 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
222 if (command_line->HasSwitch(switches::kGoogleDoodleUrl)) { 223 if (command_line->HasSwitch(switches::kGoogleDoodleUrl)) {
223 url = GURL(command_line->GetSwitchValueASCII(switches::kGoogleDoodleUrl)); 224 url = GURL(command_line->GetSwitchValueASCII(switches::kGoogleDoodleUrl));
224 } else { 225 } else {
225 url = append_queryparams_func_.Run( 226 url = append_queryparams_func_.Run(
226 logo_url_, fingerprint, wants_cta_, transparent_); 227 logo_url_, fingerprint, wants_cta_, transparent_);
227 } 228 }
228 229
229 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); 230 net::NetworkTrafficAnnotationTag traffic_annotation =
231 net::DefineNetworkTrafficAnnotation("logo_tracker", R"(
232 semantics {
233 sender: "Logo Tracker"
234 description:
235 "Provides the logo image for a search provider (e.g. Google or "
236 "Yahoo!)."
237 trigger: "Displaying the new tab page on iOS or Android."
238 data: "Link to logo image and metadata."
Marc Treib 2017/02/27 09:52:59 Wait, if I interpret the proto description correct
Ramin Halavati 2017/02/27 10:04:30 Yes, this is what Chrome sends, so is the current
Marc Treib 2017/02/27 10:12:47 The current formulation refers to what Chrome rece
Ramin Halavati 2017/02/27 10:16:54 Done, in case cookies are not required, I can crea
Marc Treib 2017/02/27 10:23:02 The problem is, I'm not sure how we could properly
justincohen 2017/02/27 14:20:10 I see, 'send' is just metadata in this case. What
239 destination: OTHER
240 }
241 policy {
242 cookies_allowed: true
243 cookies_store: "user"
244 setting:
245 "Choosing a non-Google search engine in Chromium settings under "
246 "'Search Engine' will disable this feature."
247 policy_exception_justification:
248 "Not implemented, considered not useful as it does not upload any"
249 "data and just downloads a logo image."
250 })");
251 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this,
252 traffic_annotation);
230 fetcher_->SetRequestContext(request_context_getter_.get()); 253 fetcher_->SetRequestContext(request_context_getter_.get());
231 data_use_measurement::DataUseUserData::AttachToFetcher( 254 data_use_measurement::DataUseUserData::AttachToFetcher(
232 fetcher_.get(), 255 fetcher_.get(),
233 data_use_measurement::DataUseUserData::SEARCH_PROVIDER_LOGOS); 256 data_use_measurement::DataUseUserData::SEARCH_PROVIDER_LOGOS);
234 fetcher_->Start(); 257 fetcher_->Start();
235 logo_download_start_time_ = base::TimeTicks::Now(); 258 logo_download_start_time_ = base::TimeTicks::Now();
236 } 259 }
237 260
238 void LogoTracker::OnFreshLogoParsed(bool* parsing_failed, 261 void LogoTracker::OnFreshLogoParsed(bool* parsing_failed,
239 std::unique_ptr<EncodedLogo> logo) { 262 std::unique_ptr<EncodedLogo> logo) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 int64_t current, 371 int64_t current,
349 int64_t total, 372 int64_t total,
350 int64_t current_network_bytes) { 373 int64_t current_network_bytes) {
351 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) { 374 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) {
352 LOG(WARNING) << "Search provider logo exceeded download size limit"; 375 LOG(WARNING) << "Search provider logo exceeded download size limit";
353 ReturnToIdle(DOWNLOAD_OUTCOME_DOWNLOAD_FAILED); 376 ReturnToIdle(DOWNLOAD_OUTCOME_DOWNLOAD_FAILED);
354 } 377 }
355 } 378 }
356 379
357 } // namespace search_provider_logos 380 } // namespace search_provider_logos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698