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