blob: c3fcfb9ee1b9dd3ab4216921baef102d0682894e [file] [log] [blame]
Patricia Alfonso3b296e9f2023-09-14 15:18:141// Copyright 2023 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 CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_
6#define CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_
7
Nan Lin03748b42023-09-22 19:21:038#include "base/no_destructor.h"
Anton Maliev6ddb3c42023-09-26 21:08:309#include "third_party/abseil-cpp/absl/types/optional.h"
Nan Lin03748b42023-09-22 19:21:0310
Patricia Alfonso3b296e9f2023-09-14 15:18:1411namespace tpcd::experiment {
12
13class ExperimentManager {
14 public:
Nan Lin03748b42023-09-22 19:21:0315 static ExperimentManager* GetInstance();
Patricia Alfonso3b296e9f2023-09-14 15:18:1416
17 // Called by EligibilityService to tell the manager whether a profile is
18 // eligible. Mode B also needs to know whether the profile has been onboarded
19 // to the 3PCD UX, but Mode A does not.
20 void SetClientEligibility(bool is_eligible, bool is_onboarded = false);
21
Anton Maliev6ddb3c42023-09-26 21:08:3022 // Returns the final decision for client eligiblity, if completed.
23 // absl::nullopt will be returned if the final decision has not been made yet.
24 absl::optional<bool> IsClientEligible() const;
25
Nan Lin03748b42023-09-22 19:21:0326 protected:
27 ExperimentManager();
28 ~ExperimentManager() = default;
29
Patricia Alfonso3b296e9f2023-09-14 15:18:1430 private:
Nan Lin03748b42023-09-22 19:21:0331 friend base::NoDestructor<ExperimentManager>;
32
Patricia Alfonso3b296e9f2023-09-14 15:18:1433 // Mode B experiment will need to register the client for the synthetic trial
34 // IFF the client is eligible and onboarded (TCPDExperimentState ==
35 // kOnboardedEligible). Register the client for the correct arm of the
36 // synthetic trial based on Finch feature params.
37 void RegisterSyntheticTrial();
38
39 // If a previously registered client becomes ineligible, unregister it from
40 // the synthetic trial by registering it to a "invalidated" experiment arm.
41 void UnregisterSyntheticTrial();
42
43 // Check the client is eligible for 3PCD Experiments. Returns false when: the
44 // client is <30 days old or Android users with a PWA installed.
45 bool isClientEligible();
46};
47
48} // namespace tpcd::experiment
49
50#endif // CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_