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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/reporting/reporting_context.h ('k') | net/reporting/reporting_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_context.cc
diff --git a/net/reporting/reporting_context.cc b/net/reporting/reporting_context.cc
new file mode 100644
index 0000000000000000000000000000000000000000..79235e63747aa46267fe2848d0194cf9381af841
--- /dev/null
+++ b/net/reporting/reporting_context.cc
@@ -0,0 +1,67 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/reporting/reporting_context.h"
+
+#include <memory>
+
+#include "base/memory/ptr_util.h"
+#include "base/time/clock.h"
+#include "base/time/default_clock.h"
+#include "base/time/default_tick_clock.h"
+#include "base/time/tick_clock.h"
+#include "base/time/time.h"
+#include "net/base/backoff_entry.h"
+#include "net/reporting/reporting_cache.h"
+#include "net/reporting/reporting_delegate.h"
+#include "net/reporting/reporting_delivery_agent.h"
+#include "net/reporting/reporting_endpoint_manager.h"
+#include "net/reporting/reporting_policy.h"
+
+namespace net {
+
+class URLRequestContext;
+
+namespace {
+
+class ReportingContextImpl : public ReportingContext {
+ public:
+ ReportingContextImpl(const ReportingPolicy& policy,
+ std::unique_ptr<ReportingDelegate> delegate,
+ URLRequestContext* request_context)
+ : ReportingContext(policy,
+ std::move(delegate),
+ base::MakeUnique<base::DefaultClock>(),
+ base::MakeUnique<base::DefaultTickClock>(),
+ ReportingUploader::Create(request_context)) {}
+};
+
+} // namespace
+
+// static
+std::unique_ptr<ReportingContext> ReportingContext::Create(
+ const ReportingPolicy& policy,
+ std::unique_ptr<ReportingDelegate> delegate,
+ URLRequestContext* request_context) {
+ return base::MakeUnique<ReportingContextImpl>(policy, std::move(delegate),
+ request_context);
+}
+
+ReportingContext::~ReportingContext() {}
+
+ReportingContext::ReportingContext(const ReportingPolicy& policy,
+ std::unique_ptr<ReportingDelegate> delegate,
+ std::unique_ptr<base::Clock> clock,
+ std::unique_ptr<base::TickClock> tick_clock,
+ std::unique_ptr<ReportingUploader> uploader)
+ : policy_(policy),
+ delegate_(std::move(delegate)),
+ clock_(std::move(clock)),
+ tick_clock_(std::move(tick_clock)),
+ uploader_(std::move(uploader)),
+ cache_(base::MakeUnique<ReportingCache>(this)),
+ endpoint_manager_(base::MakeUnique<ReportingEndpointManager>(this)),
+ delivery_agent_(base::MakeUnique<ReportingDeliveryAgent>(this)) {}
+
+} // namespace net
« 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