reporting_delegate.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef NET_REPORTING_REPORTING_DELEGATE_H_
  5. #define NET_REPORTING_REPORTING_DELEGATE_H_
  6. #include <memory>
  7. #include <set>
  8. #include "base/callback.h"
  9. #include "net/base/net_export.h"
  10. class GURL;
  11. namespace url {
  12. class Origin;
  13. } // namespace url
  14. namespace net {
  15. class URLRequestContext;
  16. class NET_EXPORT ReportingDelegate {
  17. public:
  18. virtual ~ReportingDelegate();
  19. // Checks whether |origin| is allowed to queue reports for future delivery.
  20. virtual bool CanQueueReport(const url::Origin& origin) const = 0;
  21. // Checks whether |origins| are allowed to receive reports, either in real
  22. // time or that were queued earlier, removing any that aren't.
  23. virtual void CanSendReports(std::set<url::Origin> origins,
  24. base::OnceCallback<void(std::set<url::Origin>)>
  25. result_callback) const = 0;
  26. // Checks whether |origin| can set |endpoint| to be used for future report
  27. // deliveries.
  28. virtual bool CanSetClient(const url::Origin& origin,
  29. const GURL& endpoint) const = 0;
  30. // Checks whether |origin| can use |endpoint| for a report delivery right now.
  31. virtual bool CanUseClient(const url::Origin& origin,
  32. const GURL& endpoint) const = 0;
  33. static std::unique_ptr<ReportingDelegate> Create(
  34. URLRequestContext* request_context);
  35. };
  36. } // namespace net
  37. #endif // NET_REPORTING_REPORTING_DELEGATE_H_