juliatuttle | 58754891 | 2017-05-23 14:17:21 | [diff] [blame] | 1 | // Copyright 2017 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 NET_REPORTING_REPORTING_DELEGATE_H_ |
| 6 | #define NET_REPORTING_REPORTING_DELEGATE_H_ |
| 7 | |
| 8 | #include <memory> |
Douglas Creager | 7b07ea4 | 2018-02-27 21:08:08 | [diff] [blame] | 9 | #include <set> |
juliatuttle | 58754891 | 2017-05-23 14:17:21 | [diff] [blame] | 10 | |
Julia Tuttle | ec467a5f | 2018-02-22 20:22:45 | [diff] [blame] | 11 | #include "base/callback.h" |
juliatuttle | 58754891 | 2017-05-23 14:17:21 | [diff] [blame] | 12 | #include "base/macros.h" |
| 13 | #include "net/base/net_export.h" |
| 14 | |
| 15 | class GURL; |
| 16 | |
| 17 | namespace url { |
| 18 | class Origin; |
| 19 | } // namespace url |
| 20 | |
| 21 | namespace net { |
| 22 | |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 23 | class URLRequestContext; |
| 24 | |
juliatuttle | 58754891 | 2017-05-23 14:17:21 | [diff] [blame] | 25 | class NET_EXPORT ReportingDelegate { |
| 26 | public: |
| 27 | virtual ~ReportingDelegate(); |
| 28 | |
| 29 | // Checks whether |origin| is allowed to queue reports for future delivery. |
| 30 | virtual bool CanQueueReport(const url::Origin& origin) const = 0; |
| 31 | |
Douglas Creager | 7b07ea4 | 2018-02-27 21:08:08 | [diff] [blame] | 32 | // Checks whether |origins| are allowed to receive reports, either in real |
| 33 | // time or that were queued earlier, removing any that aren't. |
| 34 | virtual void CanSendReports(std::set<url::Origin> origins, |
| 35 | base::OnceCallback<void(std::set<url::Origin>)> |
| 36 | result_callback) const = 0; |
juliatuttle | 58754891 | 2017-05-23 14:17:21 | [diff] [blame] | 37 | |
| 38 | // Checks whether |origin| can set |endpoint| to be used for future report |
| 39 | // deliveries. |
| 40 | virtual bool CanSetClient(const url::Origin& origin, |
| 41 | const GURL& endpoint) const = 0; |
| 42 | |
| 43 | // Checks whether |origin| can use |endpoint| for a report delivery right now. |
| 44 | virtual bool CanUseClient(const url::Origin& origin, |
| 45 | const GURL& endpoint) const = 0; |
| 46 | |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 47 | static std::unique_ptr<ReportingDelegate> Create( |
| 48 | URLRequestContext* request_context); |
juliatuttle | 58754891 | 2017-05-23 14:17:21 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace net |
| 52 | |
| 53 | #endif // NET_REPORTING_REPORTING_DELEGATE_H_ |