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_PERSISTER_H_ | 5 #ifndef NET_REPORTING_REPORTING_PERSISTER_H_ |
6 #define NET_REPORTING_REPORTING_PERSISTER_H_ | 6 #define NET_REPORTING_REPORTING_PERSISTER_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 { | |
13 class Timer; | |
14 } // namespace base | |
15 | |
16 namespace net { | 12 namespace net { |
17 | 13 |
18 class ReportingContext; | 14 class ReportingContext; |
19 | 15 |
20 // Periodically persists the state of the Reporting system to (reasonably) | 16 // Will persist the state of the Reporting system to (reasonably) stable |
21 // stable storage using the methods provided by the ReportingDelegate. | 17 // storage using an as-yet-unwritten persistence mechanism within //net. |
22 class NET_EXPORT ReportingPersister { | 18 class NET_EXPORT ReportingPersister { |
23 public: | 19 public: |
24 // Creates a ReportingPersister. |context| must outlive the persister. | 20 // Creates a ReportingPersister. |context| must outlive the persister. |
25 static std::unique_ptr<ReportingPersister> Create(ReportingContext* context); | 21 static std::unique_ptr<ReportingPersister> Create(ReportingContext* context); |
26 | 22 |
27 virtual ~ReportingPersister(); | 23 virtual ~ReportingPersister(); |
28 | |
29 // Initializes the Persister, which deserializes any previously-persisted data | |
30 // that is available through the Context's Delegate. | |
31 virtual void Initialize() = 0; | |
32 | |
33 // Replaces the internal Timer used for scheduling writes to stable storage | |
34 // with a caller-specified one so that unittests can provide a MockTimer. | |
35 virtual void SetTimerForTesting(std::unique_ptr<base::Timer> timer) = 0; | |
36 }; | 24 }; |
37 | 25 |
38 } // namespace net | 26 } // namespace net |
39 | 27 |
40 #endif // NET_REPORTING_REPORTING_PERSISTER_H_ | 28 #endif // NET_REPORTING_REPORTING_PERSISTER_H_ |
OLD | NEW |