1 // Copyright 2017 The Chromium Authors 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 NET_REPORTING_REPORTING_POLICY_H_ 6 #define NET_REPORTING_REPORTING_POLICY_H_ 7 8 #include <memory> 9 10 #include "base/time/time.h" 11 #include "net/base/backoff_entry.h" 12 #include "net/base/net_export.h" 13 14 namespace net { 15 16 // Various policy knobs for the Reporting system. 17 struct NET_EXPORT ReportingPolicy { 18 // Provides a reasonable default for use in a browser embedder. 19 static std::unique_ptr<ReportingPolicy> Create(); 20 21 // Lets you override the default policy returned by |Create|. Use this in 22 // browser tests, where there isn't any other way to pass in a specific test 23 // policy to use. 24 static void UsePolicyForTesting(const ReportingPolicy& policy); 25 26 ReportingPolicy(); 27 ReportingPolicy(const ReportingPolicy& other); 28 ~ReportingPolicy(); 29 30 // Maximum number of reports to queue before evicting the oldest. 31 size_t max_report_count = 100u; 32 33 // Maximum number of endpoints to remember before evicting 34 size_t max_endpoint_count = 1000u; 35 36 // Maximum number of endpoints for a given origin before evicting 37 // TODO(chlily): This is actually a limit on the endpoints for a given client 38 // (for a NIK, origin pair), so rename this. 39 size_t max_endpoints_per_origin = 40u; 40 41 // Minimum interval at which to attempt delivery of queued reports. 42 base::TimeDelta delivery_interval = base::Minutes(1); 43 44 // Backoff policy for failing endpoints. 45 BackoffEntry::Policy endpoint_backoff_policy; 46 47 // Minimum interval at which Reporting will persist state to (relatively) 48 // stable storage to be restored if the embedder restarts. 49 base::TimeDelta persistence_interval = base::Minutes(1); 50 51 // Whether to persist undelivered reports across embedder restarts. 52 bool persist_reports_across_restarts = false; 53 54 // Whether to persist clients (per-origin endpoint configurations) across 55 // embedder restarts. 56 bool persist_clients_across_restarts = true; 57 58 // Minimum interval at which to garbage-collect the cache. 59 base::TimeDelta garbage_collection_interval = base::Minutes(5); 60 61 // Maximum age a report can be queued for before being discarded as expired. 62 base::TimeDelta max_report_age = base::Minutes(15); 63 64 // Maximum time an endpoint group can go unused before being deleted. 65 base::TimeDelta max_group_staleness = base::Days(7); 66 67 // Maximum number of delivery attempts a report can have before being 68 // discarded as failed. 69 int max_report_attempts = 5; 70 71 // Whether to persist (versus clear) reports when the network changes to avoid 72 // leaking browsing data between networks. 73 bool persist_reports_across_network_changes = false; 74 75 // Whether to persist (versus clear) clients when the network changes to avoid 76 // leaking browsing data between networks. 77 bool persist_clients_across_network_changes = true; 78 }; 79 80 } // namespace net 81 82 #endif // NET_REPORTING_REPORTING_POLICY_H_ 83