Chromium Code Reviews| 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_ |