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

Side by Side Diff: rlz/lib/financial_ping.cc

Issue 2730263003: Network traffic annotation added to rlz/lib. (Closed)
Patch Set: Comments addressed. 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Library functions related to the Financial Server ping. 5 // Library functions related to the Financial Server ping.
6 6
7 #include "rlz/lib/financial_ping.h" 7 #include "rlz/lib/financial_ping.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 } // namespace 52 } // namespace
53 53
54 #else 54 #else
55 55
56 #include "base/bind.h" 56 #include "base/bind.h"
57 #include "base/message_loop/message_loop.h" 57 #include "base/message_loop/message_loop.h"
58 #include "base/run_loop.h" 58 #include "base/run_loop.h"
59 #include "base/time/time.h" 59 #include "base/time/time.h"
60 #include "net/base/load_flags.h" 60 #include "net/base/load_flags.h"
61 #include "net/traffic_annotation/network_traffic_annotation.h"
61 #include "net/url_request/url_fetcher.h" 62 #include "net/url_request/url_fetcher.h"
62 #include "net/url_request/url_fetcher_delegate.h" 63 #include "net/url_request/url_fetcher_delegate.h"
63 #include "net/url_request/url_request_context.h" 64 #include "net/url_request/url_request_context.h"
64 #include "net/url_request/url_request_context_getter.h" 65 #include "net/url_request/url_request_context_getter.h"
65 #include "url/gurl.h" 66 #include "url/gurl.h"
66 67
67 #endif 68 #endif
68 69
69 namespace { 70 namespace {
70 71
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // Ensure that we have a MessageLoop. 312 // Ensure that we have a MessageLoop.
312 if (!base::MessageLoop::current()) 313 if (!base::MessageLoop::current())
313 message_loop.reset(new base::MessageLoop); 314 message_loop.reset(new base::MessageLoop);
314 base::RunLoop loop; 315 base::RunLoop loop;
315 FinancialPingUrlFetcherDelegate delegate(loop.QuitClosure()); 316 FinancialPingUrlFetcherDelegate delegate(loop.QuitClosure());
316 317
317 std::string url = base::StringPrintf("http://%s:%d%s", 318 std::string url = base::StringPrintf("http://%s:%d%s",
318 kFinancialServer, kFinancialPort, 319 kFinancialServer, kFinancialPort,
319 request); 320 request);
320 321
321 std::unique_ptr<net::URLFetcher> fetcher = 322 net::NetworkTrafficAnnotationTag traffic_annotation =
322 net::URLFetcher::Create(GURL(url), net::URLFetcher::GET, &delegate); 323 net::DefineNetworkTrafficAnnotation("rlz_ping", R"(
324 semantics {
325 sender: "RLZ Ping"
326 description:
327 "Used for measuring the effectiveness of a promotion. See the "
328 "Chrome Privacy Whitepaper for complete details."
329 trigger:
330 "1- At Chromium first run\.n"
331 "2- When Chromium is re-activated by a new promotion.\n"
332 "3- Once a week thereafter as long as Chromium is used.\n"
333 data:
334 "1- Non-unique cohort tag of when Chromium was installed.\n"
335 "2- Unique machine id on desktop platforms.\n"
336 "3- Whether Google is the default omnibox search.\n"
337 "4- Whether google.com is the default home page."
338 destination: GOOGLE_OWNED_SERVICE
339 }
340 policy {
341 cookies_allowed: false
342 setting: "This feature cannot be disabled in settings."
343 policy_exception_justification: "Not implemented."
344 })");
345 std::unique_ptr<net::URLFetcher> fetcher = net::URLFetcher::Create(
346 GURL(url), net::URLFetcher::GET, &delegate, traffic_annotation);
323 347
324 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | 348 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE |
325 net::LOAD_DO_NOT_SEND_AUTH_DATA | 349 net::LOAD_DO_NOT_SEND_AUTH_DATA |
326 net::LOAD_DO_NOT_SEND_COOKIES | 350 net::LOAD_DO_NOT_SEND_COOKIES |
327 net::LOAD_DO_NOT_SAVE_COOKIES); 351 net::LOAD_DO_NOT_SAVE_COOKIES);
328 352
329 // Ensure rlz_lib::SetURLRequestContext() has been called before sending 353 // Ensure rlz_lib::SetURLRequestContext() has been called before sending
330 // pings. 354 // pings.
331 fetcher->SetRequestContext(context); 355 fetcher->SetRequestContext(context);
332 356
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 431 }
408 432
409 bool WasSendFinancialPingInterrupted() { 433 bool WasSendFinancialPingInterrupted() {
410 return send_financial_ping_interrupted_for_test; 434 return send_financial_ping_interrupted_for_test;
411 } 435 }
412 436
413 } // namespace test 437 } // namespace test
414 #endif 438 #endif
415 439
416 } // namespace rlz_lib 440 } // namespace rlz_lib
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