[go: nahoru, domu]

Implement aggregation service external interface and integrate with the
browser

This CL implements the external interface for the aggregation service
which is created per StoragePartitionImpl instance.

The internal interface for storage (AggregationServiceStorageContext) is
separated from the external interface (AggregationService) to keep a
clean division between internal and external functionalities.

This CL also introduces a feature flag for aggregation service.

from the fact that aggregation_service/ was not being compiled outside
of tests prior. There is dependency on new library which is only 9KB.

Binary-Size: Size increase is unavoidable. Most of binary size comes
Bug: 1264073
Change-Id: Ia68cd6e06d47608c0841c0cfbf998145c4488a63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3248082
Commit-Queue: Nan Lin <linnan@chromium.org>
Reviewed-by: John Delaney <johnidel@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Alex Turner <alexmt@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#941329}
diff --git a/content/browser/aggregation_service/aggregatable_report_assembler.h b/content/browser/aggregation_service/aggregatable_report_assembler.h
index 15060c35..02bdfa1 100644
--- a/content/browser/aggregation_service/aggregatable_report_assembler.h
+++ b/content/browser/aggregation_service/aggregatable_report_assembler.h
@@ -30,7 +30,7 @@
 
 namespace content {
 
-class AggregatableReportManager;
+class AggregationServiceStorageContext;
 class StoragePartition;
 
 // This class provides an interface for assembling an aggregatable report. It is
@@ -60,7 +60,7 @@
   // the possibility of unbounded memory growth
   static constexpr size_t kMaxSimultaneousRequests = 1000;
 
-  AggregatableReportAssembler(AggregatableReportManager* manager,
+  AggregatableReportAssembler(AggregationServiceStorageContext* storage_context,
                               StoragePartition* storage_partition);
   // Not copyable or movable.
   AggregatableReportAssembler(const AggregatableReportAssembler& other) =
@@ -76,14 +76,20 @@
   // Used by the aggregation service tool to inject a `url_loader_factory` to
   // AggregationServiceNetworkFetcherImpl if one is provided.
   static std::unique_ptr<AggregatableReportAssembler> CreateForTesting(
-      AggregatableReportManager* manager,
+      AggregationServiceStorageContext* storage_context,
       scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
 
   // Fetches the necessary public keys and uses it to construct an
   // AggregatableReport from the information in `report_request`. See the
   // AggregatableReport documentation for more detail on the returned report.
-  void AssembleReport(AggregatableReportRequest report_request,
-                      AssemblyCallback callback);
+  virtual void AssembleReport(AggregatableReportRequest report_request,
+                              AssemblyCallback callback);
+
+ protected:
+  // For testing only.
+  AggregatableReportAssembler(
+      AggregationServiceStorageContext* storage_context,
+      scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
 
  private:
   // Represents a request to assemble a report that has not completed.
@@ -113,11 +119,6 @@
       std::unique_ptr<AggregationServiceKeyFetcher> fetcher,
       std::unique_ptr<AggregatableReport::Provider> report_provider);
 
-  // For testing only.
-  AggregatableReportAssembler(
-      AggregatableReportManager* manager,
-      scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
-
   // Called when a result is returned from the key fetcher. Handles throwing
   // errors on a failed fetch, waiting for both results to return and calling
   // into `OnBothPublicKeysFetched()` when appropriate.