Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 #ifndef COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_CACHE_H_ | |
| 6 #define COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_CACHE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <unordered_set> | |
| 10 | |
| 11 #include "components/reporting/core/browser/reporting_endpoint.h" | |
| 12 #include "components/reporting/core/browser/reporting_report.h" | |
| 13 #include "components/reporting/core/common/reporting_export.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace reporting { | |
| 17 | |
| 18 // 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.
| |
| 19 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
| |
| 20 public: | |
| 21 // EndpointMap would be an unordered_map, but there's no hash for GURL. | |
| 22 using EndpointMap = std::map<GURL, std::unique_ptr<ReportingEndpoint>>; | |
| 23 using ReportSet = std::unordered_set<std::unique_ptr<ReportingReport>>; | |
| 24 | |
| 25 ReportingCache(); | |
| 26 ~ReportingCache(); | |
| 27 | |
| 28 void InsertEndpoint(std::unique_ptr<ReportingEndpoint> endpoints); | |
| 29 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
| |
| 30 const EndpointMap& GetEndpoints() const; | |
| 31 void RemoveEndpoint(const std::unique_ptr<ReportingEndpoint>& endpoint); | |
| 32 | |
| 33 void EnqueueReport(std::unique_ptr<ReportingReport> report); | |
| 34 const ReportSet& GetReports() const; | |
| 35 void DequeueReport(const std::unique_ptr<ReportingReport>& report); | |
| 36 | |
| 37 void Clear(); | |
| 38 | |
| 39 private: | |
| 40 // Map from endpoint.url to endpoint. | |
| 41 EndpointMap endpoints_; | |
| 42 ReportSet reports_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(ReportingCache); | |
| 45 }; | |
| 46 | |
| 47 } // namespace reporting | |
| 48 | |
| 49 #endif // COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_CACHE_H_ | |
| OLD | NEW |