blob: 183fd89a626f31888e1aaab8d4cdc565902842b3 [file] [log] [blame]
juliatuttle587548912017-05-23 14:17:211// 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 Creager7b07ea42018-02-27 21:08:089#include <set>
juliatuttle587548912017-05-23 14:17:2110
Julia Tuttleec467a5f2018-02-22 20:22:4511#include "base/callback.h"
juliatuttle587548912017-05-23 14:17:2112#include "base/macros.h"
13#include "net/base/net_export.h"
14
15class GURL;
16
17namespace url {
18class Origin;
19} // namespace url
20
21namespace net {
22
juliatuttlefcf47202017-05-23 15:53:0223class URLRequestContext;
24
juliatuttle587548912017-05-23 14:17:2125class 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 Creager7b07ea42018-02-27 21:08:0832 // 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;
juliatuttle587548912017-05-23 14:17:2137
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
juliatuttlefcf47202017-05-23 15:53:0247 static std::unique_ptr<ReportingDelegate> Create(
48 URLRequestContext* request_context);
juliatuttle587548912017-05-23 14:17:2149};
50
51} // namespace net
52
53#endif // NET_REPORTING_REPORTING_DELEGATE_H_