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

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) {
15 if (gurl.SchemeIsHTTPOrHTTPS()) { 16 if (gurl.SchemeIsHTTPOrHTTPS()) {
17 if (net::IsLocalhost(gurl.host()))
18 return "localhost";
19 if (gurl.HostIsIPAddress())
20 return "ip_address";
Nathan Parker 2015/02/20 18:47:04 Will the Rappor backend match against these string
Steven Holte 2015/02/20 19:47:11 Yes, I'll just add these to the list of strings we
16 return net::registry_controlled_domains::GetDomainAndRegistry( 21 return net::registry_controlled_domains::GetDomainAndRegistry(
17 gurl, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 22 gurl, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
18 } 23 }
19 if (gurl.SchemeIsFile()) 24 if (gurl.SchemeIsFile())
20 return gurl.scheme() + "://"; 25 return gurl.scheme() + "://";
21 return gurl.scheme() + "://" + gurl.host(); 26 return gurl.scheme() + "://" + gurl.host();
22 } 27 }
23 28
24 void SampleDomainAndRegistryFromGURL(const std::string& metric, 29 void SampleDomainAndRegistryFromGURL(const std::string& metric,
25 const GURL& gurl) { 30 const GURL& gurl) {
26 if (!g_browser_process->rappor_service()) 31 if (!g_browser_process->rappor_service())
27 return; 32 return;
28 g_browser_process->rappor_service()->RecordSample( 33 g_browser_process->rappor_service()->RecordSample(
29 metric, 34 metric,
30 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, 35 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE,
31 GetDomainAndRegistrySampleFromGURL(gurl)); 36 GetDomainAndRegistrySampleFromGURL(gurl));
32 } 37 }
33 38
34 } // namespace rappor 39 } // namespace rappor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698