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