| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_REPORTING_REPORTING_REPORT_H_ | 5 #ifndef NET_REPORTING_REPORTING_REPORT_H_ |
| 6 #define NET_REPORTING_REPORTING_REPORT_H_ | 6 #define NET_REPORTING_REPORTING_REPORT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class Value; | 16 class Value; |
| 17 } // namespace base | 17 } // namespace base |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 | 20 |
| 21 // An undelivered report. | 21 // An undelivered report. |
| 22 struct NET_EXPORT ReportingReport { | 22 struct NET_EXPORT ReportingReport { |
| 23 public: | 23 public: |
| 24 // Used in histograms; please add new items at end and do not reorder. |
| 25 enum class Outcome { |
| 26 UNKNOWN = 0, |
| 27 DISCARDED_INVALID_TYPE_FROM_RENDERER = 1, |
| 28 DISCARDED_NO_URL_REQUEST_CONTEXT = 2, |
| 29 DISCARDED_NO_REPORTING_SERVICE = 3, |
| 30 ERASED_FAILED = 4, |
| 31 ERASED_EXPIRED = 5, |
| 32 ERASED_EVICTED = 6, |
| 33 ERASED_NETWORK_CHANGED = 7, |
| 34 ERASED_BROWSING_DATA_REMOVED = 8, |
| 35 ERASED_REPORTING_SHUT_DOWN = 9, |
| 36 DELIVERED = 10, |
| 37 |
| 38 MAX |
| 39 }; |
| 40 |
| 24 ReportingReport(const GURL& url, | 41 ReportingReport(const GURL& url, |
| 25 const std::string& group, | 42 const std::string& group, |
| 26 const std::string& type, | 43 const std::string& type, |
| 27 std::unique_ptr<const base::Value> body, | 44 std::unique_ptr<const base::Value> body, |
| 28 base::TimeTicks queued, | 45 base::TimeTicks queued, |
| 29 int attempts); | 46 int attempts); |
| 30 ~ReportingReport(); | 47 ~ReportingReport(); |
| 31 | 48 |
| 49 static void RecordReportDiscardedForInvalidTypeFromRenderer(); |
| 50 static void RecordReportDiscardedForNoURLRequestContext(); |
| 51 static void RecordReportDiscardedForNoReportingService(); |
| 52 |
| 53 void RecordOutcome(base::TimeTicks now); |
| 54 |
| 32 // The URL of the document that triggered the report. (Included in the | 55 // The URL of the document that triggered the report. (Included in the |
| 33 // delivered report.) | 56 // delivered report.) |
| 34 GURL url; | 57 GURL url; |
| 35 | 58 |
| 36 // The endpoint group that should be used to deliver the report. (Not included | 59 // The endpoint group that should be used to deliver the report. (Not included |
| 37 // in the delivered report.) | 60 // in the delivered report.) |
| 38 std::string group; | 61 std::string group; |
| 39 | 62 |
| 40 // The type of the report. (Included in the delivered report.) | 63 // The type of the report. (Included in the delivered report.) |
| 41 std::string type; | 64 std::string type; |
| 42 | 65 |
| 43 // The body of the report. (Included in the delivered report.) | 66 // The body of the report. (Included in the delivered report.) |
| 44 std::unique_ptr<const base::Value> body; | 67 std::unique_ptr<const base::Value> body; |
| 45 | 68 |
| 46 // When the report was queued. (Included in the delivered report as an age | 69 // When the report was queued. (Included in the delivered report as an age |
| 47 // relative to the time of the delivery attempt.) | 70 // relative to the time of the delivery attempt.) |
| 48 base::TimeTicks queued; | 71 base::TimeTicks queued; |
| 49 | 72 |
| 50 // The number of delivery attempts made so far, not including an active | 73 // The number of delivery attempts made so far, not including an active |
| 51 // attempt. (Not included in the delivered report.) | 74 // attempt. (Not included in the delivered report.) |
| 52 int attempts = 0; | 75 int attempts = 0; |
| 53 | 76 |
| 77 Outcome outcome; |
| 78 |
| 54 private: | 79 private: |
| 80 bool recorded_outcome; |
| 81 |
| 55 DISALLOW_COPY_AND_ASSIGN(ReportingReport); | 82 DISALLOW_COPY_AND_ASSIGN(ReportingReport); |
| 56 }; | 83 }; |
| 57 | 84 |
| 58 } // namespace net | 85 } // namespace net |
| 59 | 86 |
| 60 #endif // NET_REPORTING_REPORTING_REPORT_H_ | 87 #endif // NET_REPORTING_REPORTING_REPORT_H_ |
| OLD | NEW |