| 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_NO_URL_REQUEST_CONTEXT = 1, |
| 28 DISCARDED_NO_REPORTING_SERVICE = 2, |
| 29 ERASED_FAILED = 3, |
| 30 ERASED_EXPIRED = 4, |
| 31 ERASED_EVICTED = 5, |
| 32 ERASED_NETWORK_CHANGED = 6, |
| 33 ERASED_BROWSING_DATA_REMOVED = 7, |
| 34 ERASED_REPORTING_SHUT_DOWN = 8, |
| 35 DELIVERED = 9, |
| 36 |
| 37 MAX |
| 38 }; |
| 39 |
| 24 ReportingReport(const GURL& url, | 40 ReportingReport(const GURL& url, |
| 25 const std::string& group, | 41 const std::string& group, |
| 26 const std::string& type, | 42 const std::string& type, |
| 27 std::unique_ptr<const base::Value> body, | 43 std::unique_ptr<const base::Value> body, |
| 28 base::TimeTicks queued, | 44 base::TimeTicks queued, |
| 29 int attempts); | 45 int attempts); |
| 30 ~ReportingReport(); | 46 ~ReportingReport(); |
| 31 | 47 |
| 48 static void RecordReportDiscardedForNoURLRequestContext(); |
| 49 static void RecordReportDiscardedForNoReportingService(); |
| 50 |
| 51 void RecordOutcome(base::TimeTicks now); |
| 52 |
| 32 // The URL of the document that triggered the report. (Included in the | 53 // The URL of the document that triggered the report. (Included in the |
| 33 // delivered report.) | 54 // delivered report.) |
| 34 GURL url; | 55 GURL url; |
| 35 | 56 |
| 36 // The endpoint group that should be used to deliver the report. (Not included | 57 // The endpoint group that should be used to deliver the report. (Not included |
| 37 // in the delivered report.) | 58 // in the delivered report.) |
| 38 std::string group; | 59 std::string group; |
| 39 | 60 |
| 40 // The type of the report. (Included in the delivered report.) | 61 // The type of the report. (Included in the delivered report.) |
| 41 std::string type; | 62 std::string type; |
| 42 | 63 |
| 43 // The body of the report. (Included in the delivered report.) | 64 // The body of the report. (Included in the delivered report.) |
| 44 std::unique_ptr<const base::Value> body; | 65 std::unique_ptr<const base::Value> body; |
| 45 | 66 |
| 46 // When the report was queued. (Included in the delivered report as an age | 67 // When the report was queued. (Included in the delivered report as an age |
| 47 // relative to the time of the delivery attempt.) | 68 // relative to the time of the delivery attempt.) |
| 48 base::TimeTicks queued; | 69 base::TimeTicks queued; |
| 49 | 70 |
| 50 // The number of delivery attempts made so far, not including an active | 71 // The number of delivery attempts made so far, not including an active |
| 51 // attempt. (Not included in the delivered report.) | 72 // attempt. (Not included in the delivered report.) |
| 52 int attempts = 0; | 73 int attempts = 0; |
| 53 | 74 |
| 75 Outcome outcome; |
| 76 |
| 54 private: | 77 private: |
| 78 bool recorded_outcome; |
| 79 |
| 55 DISALLOW_COPY_AND_ASSIGN(ReportingReport); | 80 DISALLOW_COPY_AND_ASSIGN(ReportingReport); |
| 56 }; | 81 }; |
| 57 | 82 |
| 58 } // namespace net | 83 } // namespace net |
| 59 | 84 |
| 60 #endif // NET_REPORTING_REPORTING_REPORT_H_ | 85 #endif // NET_REPORTING_REPORTING_REPORT_H_ |
| OLD | NEW |