[3PCD] Check profile eligible in Eligiblity Service constructor
When the eligibility service is created, if the client eligibility is
unknown yet, consult the privacy sandbox settings for the profile
eligibility and broadcast to the experiment manager.
Bug: b/300490678
Change-Id: Ia46550051feabf1d3441200d6adc222b47f67dea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4885227
Reviewed-by: Anton Maliev <[email protected]>
Commit-Queue: Nan Lin <[email protected]>
Reviewed-by: Ryan Tarpine <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1202224}
diff --git a/chrome/browser/tpcd/experiment/experiment_manager.h b/chrome/browser/tpcd/experiment/experiment_manager.h
index 16d88bf2..9d82a123 100644
--- a/chrome/browser/tpcd/experiment/experiment_manager.h
+++ b/chrome/browser/tpcd/experiment/experiment_manager.h
@@ -5,49 +5,29 @@
#ifndef CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_
#define CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_
-#include <vector>
-
#include "base/functional/callback_forward.h"
-#include "base/no_destructor.h"
-#include "base/sequence_checker.h"
-#include "base/thread_annotations.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace tpcd::experiment {
-// Can only be used on the main thread.
class ExperimentManager {
public:
using EligibilityDecisionCallback = base::OnceCallback<void(bool)>;
- static ExperimentManager* GetInstance();
+ ExperimentManager() = default;
+ virtual ~ExperimentManager() = default;
// Called by `EligibilityService` to tell the manager whether a profile is
// eligible, with a callback to complete the profile-level work required once
- // the final decision is made. The final decision is recorded in a local state
- // pref. If this is called after the final decision is made, the local state
- // pref value takes precedence and the callbacks are still performed.
- void SetClientEligibility(
+ // the final decision is made.
+ virtual void SetClientEligibility(
bool is_eligible,
- EligibilityDecisionCallback on_eligibility_decision_callback);
+ EligibilityDecisionCallback on_eligibility_decision_callback) = 0;
// Returns the final decision for client eligibility, if completed.
// `absl::nullopt` will be returned if the final decision has not been made
// yet.
- absl::optional<bool> IsClientEligible() const;
-
- protected:
- ExperimentManager();
- ~ExperimentManager();
-
- private:
- friend base::NoDestructor<ExperimentManager>;
- bool client_is_eligible_ GUARDED_BY_CONTEXT(sequence_checker_) = true;
- std::vector<EligibilityDecisionCallback> callbacks_
- GUARDED_BY_CONTEXT(sequence_checker_);
- SEQUENCE_CHECKER(sequence_checker_);
-
- void CaptureEligibilityInLocalStatePref();
+ virtual absl::optional<bool> IsClientEligible() const = 0;
};
} // namespace tpcd::experiment