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 #include "net/reporting/reporting_delivery_agent.h" | 5 #include "net/reporting/reporting_delivery_agent.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 : context_(context), | 55 : context_(context), |
56 timer_(base::MakeUnique<base::OneShotTimer>()), | 56 timer_(base::MakeUnique<base::OneShotTimer>()), |
57 weak_factory_(this) { | 57 weak_factory_(this) { |
58 context_->AddObserver(this); | 58 context_->AddObserver(this); |
59 } | 59 } |
60 | 60 |
61 // ReportingDeliveryAgent implementation: | 61 // ReportingDeliveryAgent implementation: |
62 | 62 |
63 ~ReportingDeliveryAgentImpl() override { context_->RemoveObserver(this); } | 63 ~ReportingDeliveryAgentImpl() override { context_->RemoveObserver(this); } |
64 | 64 |
65 void Initialize() override { | |
66 if (CacheHasReports()) | |
67 StartTimer(); | |
68 } | |
69 | |
70 void SetTimerForTesting(std::unique_ptr<base::Timer> timer) override { | 65 void SetTimerForTesting(std::unique_ptr<base::Timer> timer) override { |
71 DCHECK(!timer_->IsRunning()); | 66 DCHECK(!timer_->IsRunning()); |
72 timer_ = std::move(timer); | 67 timer_ = std::move(timer); |
73 } | 68 } |
74 | 69 |
75 // ReportingObserver implementation: | 70 // ReportingObserver implementation: |
76 void OnCacheUpdated() override { | 71 void OnCacheUpdated() override { |
77 if (CacheHasReports()) | 72 if (CacheHasReports()) |
78 StartTimer(); | 73 StartTimer(); |
79 } | 74 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 207 |
213 // static | 208 // static |
214 std::unique_ptr<ReportingDeliveryAgent> ReportingDeliveryAgent::Create( | 209 std::unique_ptr<ReportingDeliveryAgent> ReportingDeliveryAgent::Create( |
215 ReportingContext* context) { | 210 ReportingContext* context) { |
216 return base::MakeUnique<ReportingDeliveryAgentImpl>(context); | 211 return base::MakeUnique<ReportingDeliveryAgentImpl>(context); |
217 } | 212 } |
218 | 213 |
219 ReportingDeliveryAgent::~ReportingDeliveryAgent() {} | 214 ReportingDeliveryAgent::~ReportingDeliveryAgent() {} |
220 | 215 |
221 } // namespace net | 216 } // namespace net |
OLD | NEW |