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

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

Issue 2751103002: Reporting: Wrap existing classes in context. (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 | « net/reporting/reporting_cache_unittest.cc ('k') | net/reporting/reporting_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 std::unique_ptr<ReportingDelegate> delegate,
56 std::unique_ptr<base::Clock> clock,
57 std::unique_ptr<base::TickClock> tick_clock,
58 std::unique_ptr<ReportingUploader> uploader);
59
60 private:
61 ReportingPolicy policy_;
62 std::unique_ptr<ReportingDelegate> delegate_;
63
64 std::unique_ptr<base::Clock> clock_;
65 std::unique_ptr<base::TickClock> tick_clock_;
66 std::unique_ptr<ReportingUploader> uploader_;
67
68 std::unique_ptr<ReportingCache> cache_;
69
70 // |endpoint_manager_| must come after |tick_clock_| and |cache_|.
71 std::unique_ptr<ReportingEndpointManager> endpoint_manager_;
72
73 // |delivery_agent_| must come after |tick_clock_|, |uploader_|, |cache_|,
74 // and |endpoint_manager_|.
75 std::unique_ptr<ReportingDeliveryAgent> delivery_agent_;
76
77 DISALLOW_COPY_AND_ASSIGN(ReportingContext);
78 };
79
80 } // namespace net
81
82 #endif // NET_REPORTING_REPORTING_CONTEXT_H_
OLDNEW
« no previous file with comments | « net/reporting/reporting_cache_unittest.cc ('k') | net/reporting/reporting_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698