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
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_DOMAIN_RELIABILITY_BEACON_H_
6#define COMPONENTS_DOMAIN_RELIABILITY_BEACON_H_
7
8#include <string>
9
10#include "base/time/time.h"
11#include "components/domain_reliability/domain_reliability_export.h"
12
13namespace base {
14class Value;
15}  // namespace base
16
17namespace domain_reliability {
18
19// The per-request data that is uploaded to the Domain Reliability collector.
20struct DOMAIN_RELIABILITY_EXPORT DomainReliabilityBeacon {
21 public:
22  DomainReliabilityBeacon();
23  ~DomainReliabilityBeacon();
24
25  // Converts the Beacon to JSON format for uploading. Calculates the age
26  // relative to an upload time of |upload_time|.
27  base::Value* ToValue(base::TimeTicks upload_time) const;
28
29  // The URL that the beacon is reporting on, if included.
30  std::string url;
31  // The domain that the beacon is reporting on, if included.
32  std::string domain;
33  // The resource name that the beacon is reporting on, if included.
34  std::string resource;
35  // Status string (e.g. "ok", "dns.nxdomain", "http.403").
36  std::string status;
37  // Net error code.  Encoded as a string in the final JSON.
38  int chrome_error;
39  // IP address of the server the request went to.
40  std::string server_ip;
41  // Protocol used to make the request.
42  std::string protocol;
43  // HTTP response code returned by the server, or -1 if none was received.
44  int http_response_code;
45  // Elapsed time between starting and completing the request.
46  base::TimeDelta elapsed;
47  // Start time of the request.  Encoded as the request age in the final JSON.
48  base::TimeTicks start_time;
49
50  // Okay to copy and assign.
51};
52
53}  // namespace domain_reliability
54
55#endif  // COMPONENTS_DOMAIN_RELIABILITY_BEACON_H_
56