Commit 1e1d803b authored by ttuttle's avatar ttuttle Committed by Commit bot

Domain Reliablity: Add "domain" field to reports.

Add a "domain" field that returns the hostname of the original request.
This lets sites with wildcard contexts tell which subdomain triggered the
beacons they receive.

BUG=

Review URL: https://codereview.chromium.org/605473002

Cr-Commit-Position: refs/heads/master@{#296947}
parent 3fe4ee45
......@@ -19,6 +19,8 @@ Value* DomainReliabilityBeacon::ToValue(base::TimeTicks upload_time) 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);
beacon_value->SetString("status", status);
......
......@@ -28,6 +28,8 @@ struct DOMAIN_RELIABILITY_EXPORT DomainReliabilityBeacon {
// The URL that the beacon is reporting on, if included.
std::string url;
// The domain that the beacon is reporting on, if included.
std::string domain;
// The resource name that the beacon is reporting on, if included.
std::string resource;
// Status string (e.g. "ok", "dns.nxdomain", "http.403").
......
......@@ -25,6 +25,7 @@ typedef std::vector<DomainReliabilityBeacon> BeaconVector;
DomainReliabilityBeacon MakeBeacon(MockableTime* time) {
DomainReliabilityBeacon beacon;
beacon.domain = "localhost";
beacon.status = "ok";
beacon.chrome_error = net::OK;
beacon.server_ip = "127.0.0.1";
......@@ -165,7 +166,8 @@ TEST_F(DomainReliabilityContextTest, ReportUpload) {
// N.B.: Assumes max_delay is 5 minutes.
const char* kExpectedReport = "{"
"\"config_version\":\"1\","
"\"entries\":[{\"http_response_code\":200,\"protocol\":\"HTTP\","
"\"entries\":[{\"domain\":\"localhost\","
"\"http_response_code\":200,\"protocol\":\"HTTP\","
"\"request_age_ms\":300250,\"request_elapsed_ms\":250,"
"\"resource\":\"always_report\",\"server_ip\":\"127.0.0.1\","
"\"status\":\"ok\"}],"
......
......@@ -282,6 +282,7 @@ void DomainReliabilityMonitor::OnRequestLegComplete(
beacon.http_response_code = response_code;
beacon.start_time = request.load_timing_info.request_start;
beacon.elapsed = time_->NowTicks() - beacon.start_time;
beacon.domain = request.url.host();
context->OnBeacon(request.url, beacon);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment