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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_context.h
diff --git a/net/reporting/reporting_context.h b/net/reporting/reporting_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..609813a5ad5d2944b9cc03dacc72d5856296848b
--- /dev/null
+++ b/net/reporting/reporting_context.h
@@ -0,0 +1,82 @@
+// 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.
+
+#ifndef NET_REPORTING_REPORTING_CONTEXT_H_
+#define NET_REPORTING_REPORTING_CONTEXT_H_
+
+#include <memory>
+
+#include "base/time/time.h"
+#include "net/base/backoff_entry.h"
+#include "net/base/net_export.h"
+#include "net/reporting/reporting_policy.h"
+
+namespace base {
+class Clock;
+class TickClock;
+} // namespace base
+
+namespace net {
+
+class ReportingCache;
+class ReportingDelegate;
+class ReportingDeliveryAgent;
+class ReportingEndpointManager;
+class ReportingUploader;
+class URLRequestContext;
+
+// Contains the various internal classes that make up the Reporting system.
+// Wrapped by ReportingService, which provides the external interface.
+class NET_EXPORT ReportingContext {
+ public:
+ static std::unique_ptr<ReportingContext> Create(
+ const ReportingPolicy& policy,
+ std::unique_ptr<ReportingDelegate> delegate,
+ URLRequestContext* request_context);
+
+ ~ReportingContext();
+
+ const ReportingPolicy& policy() { return policy_; }
+ ReportingDelegate* delegate() { return delegate_.get(); }
+
+ base::Clock* clock() { return clock_.get(); }
+ base::TickClock* tick_clock() { return tick_clock_.get(); }
+ ReportingUploader* uploader() { return uploader_.get(); }
+
+ ReportingCache* cache() { return cache_.get(); }
+ ReportingEndpointManager* endpoint_manager() {
+ return endpoint_manager_.get();
+ }
+ ReportingDeliveryAgent* delivery_agent() { return delivery_agent_.get(); }
+
+ protected:
+ 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);
+
+ private:
+ 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_;
+
+ std::unique_ptr<ReportingCache> cache_;
+
+ // |endpoint_manager_| must come after |tick_clock_| and |cache_|.
+ std::unique_ptr<ReportingEndpointManager> endpoint_manager_;
+
+ // |delivery_agent_| must come after |tick_clock_|, |uploader_|, |cache_|,
+ // and |endpoint_manager_|.
+ std::unique_ptr<ReportingDeliveryAgent> delivery_agent_;
+
+ DISALLOW_COPY_AND_ASSIGN(ReportingContext);
+};
+
+} // namespace net
+
+#endif // NET_REPORTING_REPORTING_CONTEXT_H_
« 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