| Index: components/domain_reliability/beacon.cc
|
| diff --git a/components/domain_reliability/beacon.cc b/components/domain_reliability/beacon.cc
|
| index 2a85c5384742b2325bdb192a765d5ab5c4f619ed..898c62bd35b41cb6b0e13187075b71f5f38c561f 100644
|
| --- a/components/domain_reliability/beacon.cc
|
| +++ b/components/domain_reliability/beacon.cc
|
| @@ -5,6 +5,7 @@
|
| #include "components/domain_reliability/beacon.h"
|
|
|
| #include "base/values.h"
|
| +#include "components/domain_reliability/util.h"
|
| #include "net/base/net_errors.h"
|
|
|
| namespace domain_reliability {
|
| @@ -12,19 +13,27 @@ namespace domain_reliability {
|
| using base::Value;
|
| using base::DictionaryValue;
|
|
|
| +DomainReliabilityBeacon::ReportParams::ReportParams(
|
| + base::TimeTicks upload_time,
|
| + base::TimeTicks last_network_change_time,
|
| + const GURL& collector_url,
|
| + const ScopedVector<std::string>& path_prefixes)
|
| + : upload_time(upload_time),
|
| + last_network_change_time(last_network_change_time),
|
| + collector_url(collector_url),
|
| + path_prefixes(path_prefixes) {
|
| +}
|
| +
|
| DomainReliabilityBeacon::DomainReliabilityBeacon() {}
|
| DomainReliabilityBeacon::~DomainReliabilityBeacon() {}
|
|
|
| Value* DomainReliabilityBeacon::ToValue(
|
| - base::TimeTicks upload_time,
|
| - base::TimeTicks last_network_change_time) const {
|
| + const ReportParams& report_params) const {
|
| DictionaryValue* beacon_value = new DictionaryValue();
|
| - if (!url.empty())
|
| - beacon_value->SetString("url", url);
|
| - if (!domain.empty())
|
| - beacon_value->SetString("domain", domain);
|
| - if (!resource.empty())
|
| - beacon_value->SetString("resource", resource);
|
| + DCHECK(url.is_valid());
|
| + GURL sanitized_url = SanitizeURLForReport(url, report_params.collector_url,
|
| + report_params.path_prefixes);
|
| + beacon_value->SetString("url", sanitized_url.spec());
|
| beacon_value->SetString("status", status);
|
| if (chrome_error != net::OK) {
|
| DictionaryValue* failure_value = new DictionaryValue();
|
| @@ -37,11 +46,10 @@ Value* DomainReliabilityBeacon::ToValue(
|
| beacon_value->SetString("protocol", protocol);
|
| if (http_response_code >= 0)
|
| beacon_value->SetInteger("http_response_code", http_response_code);
|
| - beacon_value->SetInteger("request_elapsed_ms",
|
| - elapsed.InMilliseconds());
|
| - beacon_value->SetInteger("request_age_ms",
|
| - (upload_time - start_time).InMilliseconds());
|
| - bool network_changed = last_network_change_time > start_time;
|
| + beacon_value->SetInteger("request_elapsed_ms", elapsed.InMilliseconds());
|
| + base::TimeDelta request_age = report_params.upload_time - start_time;
|
| + beacon_value->SetInteger("request_age_ms", request_age.InMilliseconds());
|
| + bool network_changed = report_params.last_network_change_time > start_time;
|
| beacon_value->SetBoolean("network_changed", network_changed);
|
| return beacon_value;
|
| }
|
|
|