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..d4d7284f076f53f6ef4f6bb1c1b03c9364deb45c |
--- /dev/null |
+++ b/net/reporting/reporting_context.cc |
@@ -0,0 +1,69 @@ |
+// 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) { |
+ Init(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) |
+ : policy_(policy), |
+ cache_(base::MakeUnique<ReportingCache>(this)), |
+ endpoint_manager_(base::MakeUnique<ReportingEndpointManager>(this)), |
+ delivery_agent_(base::MakeUnique<ReportingDeliveryAgent>(this)) {} |
+ |
+void ReportingContext::Init(std::unique_ptr<ReportingDelegate> delegate, |
+ std::unique_ptr<base::Clock> clock, |
+ std::unique_ptr<base::TickClock> tick_clock, |
+ std::unique_ptr<ReportingUploader> uploader) { |
+ delegate_ = std::move(delegate); |
+ clock_ = std::move(clock); |
+ tick_clock_ = std::move(tick_clock); |
+ uploader_ = std::move(uploader); |
+} |
+ |
+} // namespace net |