Reporting: Check upload permissions asynchronously

This changes the signature of the CanSendReport method so that it works
asynchronously.  We need this to able to check the background sync
permission, since that can only be checked from the UI thread; we need
the async logic to pass control between the IO and UI threads in the
right way.

To reduce the number of async calls, the method has also been updated to
check several origins all at once, instead of having a single method
call for each origin.  You pass in a set of origins that you'd like to
upload reports for, and the method passes back the set of origins that
you're allowed to.

Bug: 704259
Change-Id: I431b2fe1c1eb4e65cea91a86fd213e3204b852a1
Reviewed-on: https://chromium-review.googlesource.com/937566
Reviewed-by: Julia Tuttle <[email protected]>
Commit-Queue: Douglas Creager <[email protected]>
Cr-Commit-Position: refs/heads/master@{#539546}
diff --git a/net/reporting/reporting_test_util.cc b/net/reporting/reporting_test_util.cc
index 4dfc21d6..a718f5e5 100644
--- a/net/reporting/reporting_test_util.cc
+++ b/net/reporting/reporting_test_util.cc
@@ -118,8 +118,12 @@
   return true;
 }
 
-bool TestReportingDelegate::CanSendReport(const url::Origin& origin) const {
-  return true;
+void TestReportingDelegate::CanSendReports(
+    std::set<url::Origin> origins,
+    base::OnceCallback<void(std::set<url::Origin>)> result_callback) const {
+  if (disallow_report_uploads_)
+    origins.clear();
+  std::move(result_callback).Run(std::move(origins));
 }
 
 bool TestReportingDelegate::CanSetClient(const url::Origin& origin,