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

Side by Side Diff: net/reporting/reporting_context.cc

Issue 2785293003: Reporting: Make DeliveryAgent self-scheduling. (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 unified diff | Download patch
« no previous file with comments | « no previous file | net/reporting/reporting_delivery_agent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_context.h" 5 #include "net/reporting/reporting_context.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/time/clock.h" 11 #include "base/time/clock.h"
12 #include "base/time/default_clock.h" 12 #include "base/time/default_clock.h"
13 #include "base/time/default_tick_clock.h" 13 #include "base/time/default_tick_clock.h"
14 #include "base/time/tick_clock.h" 14 #include "base/time/tick_clock.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h"
17 #include "net/base/backoff_entry.h" 16 #include "net/base/backoff_entry.h"
18 #include "net/reporting/reporting_cache.h" 17 #include "net/reporting/reporting_cache.h"
19 #include "net/reporting/reporting_delegate.h" 18 #include "net/reporting/reporting_delegate.h"
20 #include "net/reporting/reporting_delivery_agent.h" 19 #include "net/reporting/reporting_delivery_agent.h"
21 #include "net/reporting/reporting_endpoint_manager.h" 20 #include "net/reporting/reporting_endpoint_manager.h"
22 #include "net/reporting/reporting_garbage_collector.h" 21 #include "net/reporting/reporting_garbage_collector.h"
23 #include "net/reporting/reporting_observer.h" 22 #include "net/reporting/reporting_observer.h"
24 #include "net/reporting/reporting_persister.h" 23 #include "net/reporting/reporting_persister.h"
25 #include "net/reporting/reporting_policy.h" 24 #include "net/reporting/reporting_policy.h"
25 #include "net/reporting/reporting_uploader.h"
26 26
27 namespace net { 27 namespace net {
28 28
29 class URLRequestContext; 29 class URLRequestContext;
30 30
31 namespace { 31 namespace {
32 32
33 class ReportingContextImpl : public ReportingContext { 33 class ReportingContextImpl : public ReportingContext {
34 public: 34 public:
35 ReportingContextImpl(const ReportingPolicy& policy, 35 ReportingContextImpl(const ReportingPolicy& policy,
(...skipping 15 matching lines...) Expand all
51 URLRequestContext* request_context) { 51 URLRequestContext* request_context) {
52 return base::MakeUnique<ReportingContextImpl>(policy, std::move(delegate), 52 return base::MakeUnique<ReportingContextImpl>(policy, std::move(delegate),
53 request_context); 53 request_context);
54 } 54 }
55 55
56 ReportingContext::~ReportingContext() {} 56 ReportingContext::~ReportingContext() {}
57 57
58 void ReportingContext::Initialize() { 58 void ReportingContext::Initialize() {
59 DCHECK(!initialized_); 59 DCHECK(!initialized_);
60 60
61 // This order isn't *critical*, but things will work better with it in this
62 // order: with the DeliveryAgent after the Persister, it can schedule delivery
63 // of persisted reports instead of waiting for a new one to be generated, and
64 // with the GarbageCollector in between, it won't bother scheduling delivery
65 // of reports that should be discarded instead.
61 persister_->Initialize(); 66 persister_->Initialize();
62 garbage_collector_->Initialize(); 67 garbage_collector_->Initialize();
68 delivery_agent_->Initialize();
63 69
64 initialized_ = true; 70 initialized_ = true;
65 } 71 }
66 72
67 void ReportingContext::AddObserver(ReportingObserver* observer) { 73 void ReportingContext::AddObserver(ReportingObserver* observer) {
68 DCHECK(!observers_.HasObserver(observer)); 74 DCHECK(!observers_.HasObserver(observer));
69 observers_.AddObserver(observer); 75 observers_.AddObserver(observer);
70 } 76 }
71 77
72 void ReportingContext::RemoveObserver(ReportingObserver* observer) { 78 void ReportingContext::RemoveObserver(ReportingObserver* observer) {
(...skipping 15 matching lines...) Expand all
88 std::unique_ptr<base::TickClock> tick_clock, 94 std::unique_ptr<base::TickClock> tick_clock,
89 std::unique_ptr<ReportingUploader> uploader) 95 std::unique_ptr<ReportingUploader> uploader)
90 : policy_(policy), 96 : policy_(policy),
91 delegate_(std::move(delegate)), 97 delegate_(std::move(delegate)),
92 clock_(std::move(clock)), 98 clock_(std::move(clock)),
93 tick_clock_(std::move(tick_clock)), 99 tick_clock_(std::move(tick_clock)),
94 uploader_(std::move(uploader)), 100 uploader_(std::move(uploader)),
95 initialized_(false), 101 initialized_(false),
96 cache_(base::MakeUnique<ReportingCache>(this)), 102 cache_(base::MakeUnique<ReportingCache>(this)),
97 endpoint_manager_(base::MakeUnique<ReportingEndpointManager>(this)), 103 endpoint_manager_(base::MakeUnique<ReportingEndpointManager>(this)),
98 delivery_agent_(base::MakeUnique<ReportingDeliveryAgent>(this)), 104 delivery_agent_(ReportingDeliveryAgent::Create(this)),
99 persister_(ReportingPersister::Create(this)), 105 persister_(ReportingPersister::Create(this)),
100 garbage_collector_(ReportingGarbageCollector::Create(this)) {} 106 garbage_collector_(ReportingGarbageCollector::Create(this)) {}
101 107
102 } // namespace net 108 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/reporting/reporting_delivery_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698