Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_ | 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_ |
| 6 #define COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_ | 6 #define COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 // A particular resource named in the config -- includes a set of URL | 26 // A particular resource named in the config -- includes a set of URL |
| 27 // patterns that the resource will match, along with sample rates for | 27 // patterns that the resource will match, along with sample rates for |
| 28 // successful and unsuccessful requests. | 28 // successful and unsuccessful requests. |
| 29 class DOMAIN_RELIABILITY_EXPORT Resource { | 29 class DOMAIN_RELIABILITY_EXPORT Resource { |
| 30 public: | 30 public: |
| 31 Resource(); | 31 Resource(); |
| 32 ~Resource(); | 32 ~Resource(); |
| 33 | 33 |
| 34 // Returns whether |url_string| matches at least one of the |url_patterns| | 34 // Returns whether |url_string| matches at least one of the |url_patterns| |
| 35 // in this Resource. | 35 // in this Resource. |
| 36 bool MatchesUrlString(const std::string& url_string) const; | 36 bool MatchesUrlString(const std::string& url_string) const; |
|
Ryan Sleevi
2014/04/25 01:00:02
Why do you pass this as "url_string", rather than
Deprecated (see juliatuttle)
2014/04/28 22:01:13
The config is only consulted once we've checked mo
Deprecated (see juliatuttle)
2014/04/28 22:01:13
Hmm. I was going to say I don't want to repeatedl
| |
| 37 | 37 |
| 38 // Returns whether a request (that was successful if |success| is true) | 38 // Returns whether a request (that was successful if |success| is true) |
| 39 // should be reported (with a full beacon). (The output is random; it | 39 // should be reported (with a full beacon). (The output is random; it |
| 40 // compares a random number to |success_sample_rate| or | 40 // compares a random number to |success_sample_rate| or |
| 41 // |failure_sample_rate|.) | 41 // |failure_sample_rate|.) |
| 42 bool DecideIfShouldReportRequest(bool success) const; | 42 bool DecideIfShouldReportRequest(bool success) const; |
| 43 | 43 |
| 44 // Registers with the JSONValueConverter so it will know how to convert the | 44 // Registers with the JSONValueConverter so it will know how to convert the |
| 45 // JSON for a named resource into the struct. | 45 // JSON for a named resource into the struct. |
| 46 static void RegisterJSONConverter( | 46 static void RegisterJSONConverter( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 | 86 |
| 87 DomainReliabilityConfig(); | 87 DomainReliabilityConfig(); |
| 88 ~DomainReliabilityConfig(); | 88 ~DomainReliabilityConfig(); |
| 89 | 89 |
| 90 // Uses the JSONValueConverter to parse the JSON for a config into a struct. | 90 // Uses the JSONValueConverter to parse the JSON for a config into a struct. |
| 91 static scoped_ptr<const DomainReliabilityConfig> FromJSON( | 91 static scoped_ptr<const DomainReliabilityConfig> FromJSON( |
| 92 const base::StringPiece& json); | 92 const base::StringPiece& json); |
| 93 | 93 |
| 94 bool IsValid() const; | 94 bool IsValid() const; |
| 95 | 95 |
| 96 // Checks whether |now| is past the expiration time provided in the config. | |
| 96 bool IsExpired(base::Time now) const; | 97 bool IsExpired(base::Time now) const; |
| 97 | 98 |
| 98 // Finds the index (in resources) of the first Resource that matches a | 99 // Finds the index (in resources) of the first Resource that matches a |
| 99 // particular URL. Returns -1 if the URL is not matched by any Resources. | 100 // particular URL. Returns -1 if the URL is not matched by any Resources. |
| 100 int GetResourceIndexForUrl(const GURL& url) const; | 101 int GetResourceIndexForUrl(const GURL& url) const; |
| 101 | 102 |
| 102 // Registers with the JSONValueConverter so it will know how to convert the | 103 // Registers with the JSONValueConverter so it will know how to convert the |
| 103 // JSON for a config into the struct. | 104 // JSON for a config into the struct. |
| 104 static void RegisterJSONConverter( | 105 static void RegisterJSONConverter( |
| 105 base::JSONValueConverter<DomainReliabilityConfig>* converter); | 106 base::JSONValueConverter<DomainReliabilityConfig>* converter); |
| 106 | 107 |
| 107 std::string version; | 108 std::string version; |
| 108 double valid_until; | 109 double valid_until; |
| 109 std::string domain; | 110 std::string domain; |
| 110 ScopedVector<Resource> resources; | 111 ScopedVector<Resource> resources; |
| 111 ScopedVector<Collector> collectors; | 112 ScopedVector<Collector> collectors; |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityConfig); | 115 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityConfig); |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 } // namespace domain_reliability | 118 } // namespace domain_reliability |
| 118 | 119 |
| 119 #endif // COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_ | 120 #endif // COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_ |
| OLD | NEW |