| Index: components/reporting/core/browser/reporting_cache.cc
|
| diff --git a/components/reporting/core/browser/reporting_cache.cc b/components/reporting/core/browser/reporting_cache.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5719ee68ed5a50eed74f0b43c1931699314406a8
|
| --- /dev/null
|
| +++ b/components/reporting/core/browser/reporting_cache.cc
|
| @@ -0,0 +1,55 @@
|
| +// 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.
|
| +
|
| +#include "components/reporting/core/browser/reporting_cache.h"
|
| +
|
| +namespace reporting {
|
| +
|
| +ReportingCache::ReportingCache() {}
|
| +ReportingCache::~ReportingCache() {}
|
| +
|
| +void ReportingCache::InsertEndpoint(
|
| + std::unique_ptr<ReportingEndpoint> endpoint) {
|
| + DCHECK(endpoint);
|
| + endpoints_[endpoint->url] = std::move(endpoint);
|
| +}
|
| +
|
| +const std::unique_ptr<ReportingEndpoint>* ReportingCache::GetEndpoint(
|
| + const GURL& url) const {
|
| + EndpointMap::const_iterator it = endpoints_.find(url);
|
| + if (it == endpoints_.cend())
|
| + return nullptr;
|
| + return &it->second;
|
| +}
|
| +
|
| +const ReportingCache::EndpointMap& ReportingCache::GetEndpoints() const {
|
| + return endpoints_;
|
| +}
|
| +
|
| +void ReportingCache::RemoveEndpoint(
|
| + const std::unique_ptr<ReportingEndpoint>& endpoint) {
|
| + endpoints_.erase(endpoint->url);
|
| +}
|
| +
|
| +void ReportingCache::EnqueueReport(std::unique_ptr<ReportingReport> report) {
|
| + DCHECK(report);
|
| + reports_.insert(std::move(report));
|
| +}
|
| +
|
| +const ReportingCache::ReportSet& ReportingCache::GetReports() const {
|
| + return reports_;
|
| +}
|
| +
|
| +void ReportingCache::DequeueReport(
|
| + const std::unique_ptr<ReportingReport>& report) {
|
| + DCHECK(report);
|
| + reports_.erase(report);
|
| +}
|
| +
|
| +void ReportingCache::Clear() {
|
| + endpoints_.clear();
|
| + reports_.clear();
|
| +}
|
| +
|
| +} // namespace reporting
|
|
|