Reporting: Process Report-To headers in HTTPNetworkTransaction

Piece by piece, we are moving the Reporting and NEL processing code from
URLRequest and friends into HTTPNetworkTransaction, to make sure that we
produce reports for network requests as defined by the spec (e.g., for
redirects and cached responses).

This patch moves the processing of the Report-To configuration header.

Bug: 895823
Change-Id: Id6f51eefdb9afc43ad3841fb3c3f6d6b39fd2943
Reviewed-on: https://chromium-review.googlesource.com/c/1293555
Commit-Queue: Douglas Creager <[email protected]>
Reviewed-by: Misha Efimov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#606896}
diff --git a/net/reporting/reporting_header_parser.h b/net/reporting/reporting_header_parser.h
index 7613add..4b069a8 100644
--- a/net/reporting/reporting_header_parser.h
+++ b/net/reporting/reporting_header_parser.h
@@ -22,6 +22,55 @@
 
 class NET_EXPORT ReportingHeaderParser {
  public:
+  // Histograms.  These are mainly used in test cases to verify that interesting
+  // events occurred.
+
+  static const char kHeaderOutcomeHistogram[];
+  static const char kHeaderEndpointGroupOutcomeHistogram[];
+  static const char kHeaderEndpointOutcomeHistogram[];
+
+  enum class HeaderOutcome {
+    DISCARDED_NO_REPORTING_SERVICE = 0,
+    DISCARDED_INVALID_SSL_INFO = 1,
+    DISCARDED_CERT_STATUS_ERROR = 2,
+    DISCARDED_JSON_TOO_BIG = 3,
+    DISCARDED_JSON_INVALID = 4,
+    PARSED = 5,
+
+    MAX
+  };
+
+  enum class HeaderEndpointGroupOutcome {
+    DISCARDED_NOT_DICTIONARY = 0,
+    DISCARDED_GROUP_NOT_STRING = 1,
+    DISCARDED_TTL_MISSING = 2,
+    DISCARDED_TTL_NOT_INTEGER = 3,
+    DISCARDED_TTL_NEGATIVE = 4,
+    DISCARDED_ENDPOINTS_MISSING = 5,
+    DISCARDED_ENDPOINTS_NOT_LIST = 6,
+
+    PARSED = 7,
+
+    MAX
+  };
+
+  enum class HeaderEndpointOutcome {
+    DISCARDED_NOT_DICTIONARY = 0,
+    DISCARDED_URL_MISSING = 1,
+    DISCARDED_URL_NOT_STRING = 2,
+    DISCARDED_URL_INVALID = 3,
+    DISCARDED_URL_INSECURE = 4,
+    DISCARDED_PRIORITY_NOT_INTEGER = 5,
+    DISCARDED_WEIGHT_NOT_INTEGER = 6,
+    DISCARDED_WEIGHT_NOT_POSITIVE = 7,
+
+    REMOVED = 8,
+    SET_REJECTED_BY_DELEGATE = 9,
+    SET = 10,
+
+    MAX
+  };
+
   static void RecordHeaderDiscardedForNoReportingService();
   static void RecordHeaderDiscardedForInvalidSSLInfo();
   static void RecordHeaderDiscardedForCertStatusError();