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

Side by Side Diff: chrome/browser/metrics/rappor/sampling.cc

Issue 933853003: Identify localhost/ipaddress in RapporSamples (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 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 "chrome/browser/metrics/rappor/sampling.h" 5 #include "chrome/browser/metrics/rappor/sampling.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "components/rappor/rappor_service.h" 8 #include "components/rappor/rappor_service.h"
9 #include "net/base/net_util.h"
9 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
10 #include "url/gurl.h" 11 #include "url/gurl.h"
11 12
12 namespace rappor { 13 namespace rappor {
13 14
14 std::string GetDomainAndRegistrySampleFromGURL(const GURL& gurl) { 15 std::string GetDomainAndRegistrySampleFromGURL(const GURL& gurl) {
16 if (net::IsLocalhost(gurl.host())) {
Alexei Svitkine (slow) 2015/02/18 21:22:20 Nit: No {}'s. Same below.
Steven Holte 2015/02/19 23:42:19 Done.
17 return "localhost";
Nathan Parker 2015/02/18 21:56:46 I think this should go inside the if IsHTTPorHTTPS
Steven Holte 2015/02/19 23:42:19 Done.
18 }
19 if (gurl.HostIsIPAddress()) {
20 return "ip_address";
21 }
15 if (gurl.SchemeIsHTTPOrHTTPS()) { 22 if (gurl.SchemeIsHTTPOrHTTPS()) {
16 return net::registry_controlled_domains::GetDomainAndRegistry( 23 return net::registry_controlled_domains::GetDomainAndRegistry(
17 gurl, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 24 gurl, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
18 } 25 }
19 if (gurl.SchemeIsFile()) 26 if (gurl.SchemeIsFile())
20 return gurl.scheme() + "://"; 27 return gurl.scheme() + "://";
21 return gurl.scheme() + "://" + gurl.host(); 28 return gurl.scheme() + "://" + gurl.host();
22 } 29 }
23 30
24 void SampleDomainAndRegistryFromGURL(const std::string& metric, 31 void SampleDomainAndRegistryFromGURL(const std::string& metric,
25 const GURL& gurl) { 32 const GURL& gurl) {
26 if (!g_browser_process->rappor_service()) 33 if (!g_browser_process->rappor_service())
27 return; 34 return;
28 g_browser_process->rappor_service()->RecordSample( 35 g_browser_process->rappor_service()->RecordSample(
29 metric, 36 metric,
30 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, 37 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE,
31 GetDomainAndRegistrySampleFromGURL(gurl)); 38 GetDomainAndRegistrySampleFromGURL(gurl));
32 } 39 }
33 40
34 } // namespace rappor 41 } // namespace rappor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698