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_GARBAGE_COLLECTOR_H_ 6 #define NET_REPORTING_REPORTING_GARBAGE_COLLECTOR_H_ 7 8 #include <memory> 9 10 #include "net/base/net_export.h" 11 12 namespace base { 13 class OneShotTimer; 14 } // namespace base 15 16 namespace net { 17 18 class ReportingContext; 19 20 // Removes reports that have remained undelivered for too long or that have been 21 // included in too many failed delivery attempts. 22 class NET_EXPORT ReportingGarbageCollector { 23 public: 24 // Creates a ReportingGarbageCollector. |context| must outlive the garbage 25 // collector. 26 static std::unique_ptr<ReportingGarbageCollector> Create( 27 ReportingContext* context); 28 29 virtual ~ReportingGarbageCollector(); 30 31 // Replaces the internal OneShotTimer used for scheduling garbage collection 32 // passes with a caller-specified one so that unittests can provide a 33 // MockOneShotTimer. 34 virtual void SetTimerForTesting( 35 std::unique_ptr<base::OneShotTimer> timer) = 0; 36 }; 37 38 } // namespace net 39 40 #endif // NET_REPORTING_REPORTING_GARBAGE_COLLECTOR_H_ 41