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 #include "components/reporting/core/browser/reporting_cache.h" |
| 6 |
| 7 namespace reporting { |
| 8 |
| 9 ReportingCache::ReportingCache() {} |
| 10 ReportingCache::~ReportingCache() {} |
| 11 |
| 12 void ReportingCache::InsertEndpoint( |
| 13 std::unique_ptr<ReportingEndpoint> endpoint) { |
| 14 DCHECK(endpoint); |
| 15 endpoints_[endpoint->url] = std::move(endpoint); |
| 16 } |
| 17 |
| 18 const std::unique_ptr<ReportingEndpoint>* ReportingCache::GetEndpoint( |
| 19 const GURL& url) const { |
| 20 EndpointMap::const_iterator it = endpoints_.find(url); |
| 21 if (it == endpoints_.cend()) |
| 22 return nullptr; |
| 23 return &it->second; |
| 24 } |
| 25 |
| 26 const ReportingCache::EndpointMap& ReportingCache::GetEndpoints() const { |
| 27 return endpoints_; |
| 28 } |
| 29 |
| 30 void ReportingCache::RemoveEndpoint( |
| 31 const std::unique_ptr<ReportingEndpoint>& endpoint) { |
| 32 endpoints_.erase(endpoint->url); |
| 33 } |
| 34 |
| 35 void ReportingCache::EnqueueReport(std::unique_ptr<ReportingReport> report) { |
| 36 DCHECK(report); |
| 37 reports_.insert(std::move(report)); |
| 38 } |
| 39 |
| 40 const ReportingCache::ReportSet& ReportingCache::GetReports() const { |
| 41 return reports_; |
| 42 } |
| 43 |
| 44 void ReportingCache::DequeueReport( |
| 45 const std::unique_ptr<ReportingReport>& report) { |
| 46 DCHECK(report); |
| 47 reports_.erase(report); |
| 48 } |
| 49 |
| 50 void ReportingCache::Clear() { |
| 51 endpoints_.clear(); |
| 52 reports_.clear(); |
| 53 } |
| 54 |
| 55 } // namespace reporting |
OLD | NEW |