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

Unified Diff: components/reporting/core/browser/reporting_cache.h

Issue 2249213002: [OBSOLETE] Reporting: Initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ProfileImplIOData Created 4 years, 2 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
Index: components/reporting/core/browser/reporting_cache.h
diff --git a/components/reporting/core/browser/reporting_cache.h b/components/reporting/core/browser/reporting_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..fb3422e1adb97362821412d714bcacb8fca2e3bd
--- /dev/null
+++ b/components/reporting/core/browser/reporting_cache.h
@@ -0,0 +1,49 @@
+// Copyright 2016 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 COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_CACHE_H_
+#define COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_CACHE_H_
+
+#include <map>
+#include <unordered_set>
+
+#include "components/reporting/core/browser/reporting_endpoint.h"
+#include "components/reporting/core/browser/reporting_report.h"
+#include "components/reporting/core/common/reporting_export.h"
+#include "url/gurl.h"
+
+namespace reporting {
+
+// Section 2.4
Randy Smith (Not in Mondays) 2016/10/21 20:15:11 I presume this is a reference into the spec, but I
Julia Tuttle 2016/11/02 20:44:39 Done.
+class REPORTING_EXPORT ReportingCache {
Randy Smith (Not in Mondays) 2016/10/21 20:15:11 Not actionable: From a purely code analysis POV, t
Julia Tuttle 2016/11/02 20:44:39 I will end up making the cache able to serialize a
+ public:
+ // EndpointMap would be an unordered_map, but there's no hash for GURL.
+ using EndpointMap = std::map<GURL, std::unique_ptr<ReportingEndpoint>>;
+ using ReportSet = std::unordered_set<std::unique_ptr<ReportingReport>>;
+
+ ReportingCache();
+ ~ReportingCache();
+
+ void InsertEndpoint(std::unique_ptr<ReportingEndpoint> endpoints);
+ const std::unique_ptr<ReportingEndpoint>* GetEndpoint(const GURL& url) const;
Randy Smith (Not in Mondays) 2016/10/21 20:15:11 Why return a const pointer to a std::unique_ptr<>?
Julia Tuttle 2016/11/02 20:44:39 I can't find a good way to erase from a vector<uni
+ const EndpointMap& GetEndpoints() const;
+ void RemoveEndpoint(const std::unique_ptr<ReportingEndpoint>& endpoint);
+
+ void EnqueueReport(std::unique_ptr<ReportingReport> report);
+ const ReportSet& GetReports() const;
+ void DequeueReport(const std::unique_ptr<ReportingReport>& report);
+
+ void Clear();
+
+ private:
+ // Map from endpoint.url to endpoint.
+ EndpointMap endpoints_;
+ ReportSet reports_;
+
+ DISALLOW_COPY_AND_ASSIGN(ReportingCache);
+};
+
+} // namespace reporting
+
+#endif // COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698