123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// found in the LICENSE file.
423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#ifndef COMPONENTS_DOMAIN_RELIABILITY_BEACON_H_
623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#define COMPONENTS_DOMAIN_RELIABILITY_BEACON_H_
723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include <string>
923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
1023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "base/time/time.h"
1123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "components/domain_reliability/domain_reliability_export.h"
1223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
1323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)namespace base {
1423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)class Value;
1523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}  // namespace base
1623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
1723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)namespace domain_reliability {
1823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
1923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// The per-request data that is uploaded to the Domain Reliability collector.
200de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)struct DOMAIN_RELIABILITY_EXPORT DomainReliabilityBeacon {
2123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) public:
2223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  DomainReliabilityBeacon();
2323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  ~DomainReliabilityBeacon();
2423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
2523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Converts the Beacon to JSON format for uploading. Calculates the age
2623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // relative to an upload time of |upload_time|.
2723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  base::Value* ToValue(base::TimeTicks upload_time) const;
2823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // The URL that the beacon is reporting on, if included.
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  std::string url;
311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // The domain that the beacon is reporting on, if included.
321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  std::string domain;
335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // The resource name that the beacon is reporting on, if included.
345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  std::string resource;
3523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Status string (e.g. "ok", "dns.nxdomain", "http.403").
3623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  std::string status;
3723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Net error code.  Encoded as a string in the final JSON.
3823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  int chrome_error;
3923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // IP address of the server the request went to.
4023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  std::string server_ip;
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Protocol used to make the request.
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  std::string protocol;
4323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // HTTP response code returned by the server, or -1 if none was received.
4423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  int http_response_code;
4523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Elapsed time between starting and completing the request.
4623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  base::TimeDelta elapsed;
4723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Start time of the request.  Encoded as the request age in the final JSON.
4823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  base::TimeTicks start_time;
4923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
500de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)  // Okay to copy and assign.
5123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)};
5223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
5323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}  // namespace domain_reliability
5423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
5523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#endif  // COMPONENTS_DOMAIN_RELIABILITY_BEACON_H_
56