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

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

Issue 2751103002: Reporting: Wrap existing classes in context. (Closed)
Patch Set: Move before BrowsingDataRemover, GarbageCollector, and Serializer CLs. 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_REPORTING_REPORTING_CONTEXT_H_
6 #define NET_REPORTING_REPORTING_CONTEXT_H_
7
8 #include <memory>
9
10 #include "base/time/time.h"
11 #include "net/base/backoff_entry.h"
12 #include "net/base/net_export.h"
13 #include "net/reporting/reporting_policy.h"
14
15 namespace base {
16 class Clock;
17 class TickClock;
18 } // namespace base
19
20 namespace net {
21
22 class ReportingCache;
23 class ReportingDelegate;
24 class ReportingDeliveryAgent;
25 class ReportingEndpointManager;
26 class ReportingUploader;
27 class URLRequestContext;
28
29 // Contains the various internal classes that make up the Reporting system.
30 // Wrapped by ReportingService, which provides the external interface.
31 class NET_EXPORT ReportingContext {
32 public:
33 static std::unique_ptr<ReportingContext> Create(
34 const ReportingPolicy& policy,
35 std::unique_ptr<ReportingDelegate> delegate,
36 URLRequestContext* request_context);
37
38 ~ReportingContext();
39
40 const ReportingPolicy& policy() { return policy_; }
41 ReportingDelegate* delegate() { return delegate_.get(); }
42
43 base::Clock* clock() { return clock_.get(); }
44 base::TickClock* tick_clock() { return tick_clock_.get(); }
45 ReportingUploader* uploader() { return uploader_.get(); }
46
47 ReportingCache* cache() { return cache_.get(); }
48 ReportingEndpointManager* endpoint_manager() {
49 return endpoint_manager_.get();
50 }
51 ReportingDeliveryAgent* delivery_agent() { return delivery_agent_.get(); }
52
53 protected:
54 ReportingContext(const ReportingPolicy& policy);
55
56 void Init(std::unique_ptr<ReportingDelegate> delegate,
57 std::unique_ptr<base::Clock> clock,
58 std::unique_ptr<base::TickClock> tick_clock,
59 std::unique_ptr<ReportingUploader> uploader);
60
61 private:
62 ReportingPolicy policy_;
63 std::unique_ptr<ReportingDelegate> delegate_;
64
65 std::unique_ptr<base::Clock> clock_;
66 std::unique_ptr<base::TickClock> tick_clock_;
67 std::unique_ptr<ReportingUploader> uploader_;
68
69 std::unique_ptr<ReportingCache> cache_;
70 // |endpoint_manager_| must come after |tick_clock_| and |cache_|.
71 std::unique_ptr<ReportingEndpointManager> endpoint_manager_;
72 // |delivery_agent_| must come after |tick_clock_|, |uploader_|, |cache_|,
73 // and |endpoint_manager_|.
74 std::unique_ptr<ReportingDeliveryAgent> delivery_agent_;
75
76 private:
shivanisha 2017/04/03 15:39:05 nit: Can remove the extra private qualifier here.
Julia Tuttle 2017/04/04 18:28:02 Oops!
77 DISALLOW_COPY_AND_ASSIGN(ReportingContext);
78 };
79
80 } // namespace net
81
82 #endif // NET_REPORTING_REPORTING_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698