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

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

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_context.h ('k') | net/reporting/reporting_delegate.h » ('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 #include "net/reporting/reporting_context.h"
6
7 #include <memory>
8
9 #include "base/memory/ptr_util.h"
10 #include "base/time/clock.h"
11 #include "base/time/default_clock.h"
12 #include "base/time/default_tick_clock.h"
13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h"
15 #include "net/base/backoff_entry.h"
16 #include "net/reporting/reporting_cache.h"
17 #include "net/reporting/reporting_delegate.h"
18 #include "net/reporting/reporting_delivery_agent.h"
19 #include "net/reporting/reporting_endpoint_manager.h"
20 #include "net/reporting/reporting_policy.h"
21
22 namespace net {
23
24 class URLRequestContext;
25
26 namespace {
27
28 class ReportingContextImpl : public ReportingContext {
29 public:
30 ReportingContextImpl(const ReportingPolicy& policy,
31 std::unique_ptr<ReportingDelegate> delegate,
32 URLRequestContext* request_context)
33 : ReportingContext(policy,
34 std::move(delegate),
35 base::MakeUnique<base::DefaultClock>(),
36 base::MakeUnique<base::DefaultTickClock>(),
37 ReportingUploader::Create(request_context)) {}
38 };
39
40 } // namespace
41
42 // static
43 std::unique_ptr<ReportingContext> ReportingContext::Create(
44 const ReportingPolicy& policy,
45 std::unique_ptr<ReportingDelegate> delegate,
46 URLRequestContext* request_context) {
47 return base::MakeUnique<ReportingContextImpl>(policy, std::move(delegate),
48 request_context);
49 }
50
51 ReportingContext::~ReportingContext() {}
52
53 ReportingContext::ReportingContext(const ReportingPolicy& policy,
54 std::unique_ptr<ReportingDelegate> delegate,
55 std::unique_ptr<base::Clock> clock,
56 std::unique_ptr<base::TickClock> tick_clock,
57 std::unique_ptr<ReportingUploader> uploader)
58 : policy_(policy),
59 delegate_(std::move(delegate)),
60 clock_(std::move(clock)),
61 tick_clock_(std::move(tick_clock)),
62 uploader_(std::move(uploader)),
63 cache_(base::MakeUnique<ReportingCache>(this)),
64 endpoint_manager_(base::MakeUnique<ReportingEndpointManager>(this)),
65 delivery_agent_(base::MakeUnique<ReportingDeliveryAgent>(this)) {}
66
67 } // namespace net
OLDNEW
« no previous file with comments | « net/reporting/reporting_context.h ('k') | net/reporting/reporting_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698