Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Unified Diff: net/reporting/reporting_garbage_collector.cc

Issue 2751883003: Reporting: Implement serializer. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/reporting/reporting_garbage_collector.h ('k') | net/reporting/reporting_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_garbage_collector.cc
diff --git a/net/reporting/reporting_garbage_collector.cc b/net/reporting/reporting_garbage_collector.cc
index 2af4b803f4fbc4198d55689eadc85d7be7ade75e..76dbf3ad0e4401c5d7db7747db4c2b54012065af 100644
--- a/net/reporting/reporting_garbage_collector.cc
+++ b/net/reporting/reporting_garbage_collector.cc
@@ -24,21 +24,28 @@ class ReportingGarbageCollectorImpl : public ReportingGarbageCollector,
public ReportingObserver {
public:
ReportingGarbageCollectorImpl(ReportingContext* context)
- : context_(context), timer_(base::MakeUnique<base::OneShotTimer>()) {
- context_->AddObserver(this);
- }
+ : context_(context), timer_(base::MakeUnique<base::OneShotTimer>()) {}
// ReportingGarbageCollector implementation:
- //
- ~ReportingGarbageCollectorImpl() override { context_->RemoveObserver(this); }
+
+ ~ReportingGarbageCollectorImpl() override {
+ DCHECK(context_->initialized());
+ context_->RemoveObserver(this);
+ }
+
+ void Initialize() override {
+ context_->AddObserver(this);
+ CollectGarbage();
+ }
void SetTimerForTesting(std::unique_ptr<base::Timer> timer) override {
- DCHECK(!timer_->IsRunning());
+ DCHECK(!context_->initialized());
timer_ = std::move(timer);
}
// ReportingObserver implementation:
void OnCacheUpdated() override {
+ DCHECK(context_->initialized());
if (!timer_->IsRunning())
StartTimer();
}
« no previous file with comments | « net/reporting/reporting_garbage_collector.h ('k') | net/reporting/reporting_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698