OLD | NEW |
1 // Copyright 2015 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 #ifndef COMPONENTS_RAPPOR_RAPPOR_UTILS_H_ | 5 #ifndef COMPONENTS_RAPPOR_PUBLIC_RAPPOR_UTILS_H_ |
6 #define COMPONENTS_RAPPOR_RAPPOR_UTILS_H_ | 6 #define COMPONENTS_RAPPOR_PUBLIC_RAPPOR_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "components/rappor/rappor_service.h" | 10 #include "components/rappor/public/rappor_service.h" |
11 | 11 |
12 class GURL; | 12 class GURL; |
13 | 13 |
14 namespace rappor { | 14 namespace rappor { |
15 | 15 |
16 class RapporService; | |
17 | |
18 // Records a string to a Rappor metric. | 16 // Records a string to a Rappor metric. |
19 // If |rappor_service| is NULL, this call does nothing. | 17 // If |rappor_service| is NULL, this call does nothing. |
20 void SampleString(RapporService* rappor_service, | 18 void SampleString(RapporService* rappor_service, |
21 const std::string& metric, | 19 const std::string& metric, |
22 RapporType type, | 20 RapporType type, |
23 const std::string& sample); | 21 const std::string& sample); |
24 | 22 |
25 // Extract the domain and registry for a sample from a GURL. | 23 // Extract the domain and registry for a sample from a GURL. |
26 // For file:// urls this will just return "file://" and for other special | 24 // For file:// urls this will just return "file://" and for other special |
27 // schemes like chrome-extension will return the scheme and host. | 25 // schemes like chrome-extension will return the scheme and host. |
28 std::string GetDomainAndRegistrySampleFromGURL(const GURL& gurl); | 26 std::string GetDomainAndRegistrySampleFromGURL(const GURL& gurl); |
29 | 27 |
30 // Records the domain and registry of a url to a Rappor metric. | 28 // Records the domain and registry of a url to a Rappor metric. |
31 // If |rappor_service| is NULL, this call does nothing. | 29 // If |rappor_service| is NULL, this call does nothing. |
32 void SampleDomainAndRegistryFromGURL(RapporService* rappor_service, | 30 void SampleDomainAndRegistryFromGURL(RapporService* rappor_service, |
33 const std::string& metric, | 31 const std::string& metric, |
34 const GURL& gurl); | 32 const GURL& gurl); |
35 | 33 |
36 // Returns NULL if there is no default service. | 34 // Returns NULL if there is no default service. |
37 RapporService* GetDefaultService(); | 35 RapporService* GetDefaultService(); |
38 | 36 |
39 void SetDefaultServiceAccessor(RapporService* (*getDefaultService)()); | 37 void SetDefaultServiceAccessor(RapporService* (*getDefaultService)()); |
40 | 38 |
41 } // namespace rappor | 39 } // namespace rappor |
42 | 40 |
43 #endif // COMPONENTS_RAPPOR_RAPPOR_UTILS_H_ | 41 #endif // COMPONENTS_RAPPOR_PUBLIC_RAPPOR_UTILS_H_ |
OLD | NEW |