6 #ifndef SecExperiment_h
7 #define SecExperiment_h
9 #include <Security/SecProtocolObject.h>
11 #ifndef SEC_EXP_OBJECT_IMPL
12 SEC_OBJECT_DECL(sec_experiment
);
13 #endif // !SEC_EXP_OBJECT_IMPL
15 SEC_ASSUME_NONNULL_BEGIN
17 extern const char *kSecExperimentTLSMobileAssetConfig
;
18 extern const char *kSecExperimentDefaultsDomain
;
21 * @block sec_experiment_run_block_t
23 * @abstract A block to execute an experiment with a loggable identifier
24 * and configuration. `identifier` will be uniquely associated with
25 * `experiment_config` and should be used when measuring data.
28 * Identifier for the experiment.
30 * @param experiment_config
31 * Configuration of this experiment.
33 * @return True if the experiment ran successfully, and false otherwise.
35 typedef bool (^sec_experiment_run_block_t
)(const char *identifier
, xpc_object_t experiment_config
);
38 * @function sec_experiment_run
41 * Asynchronously run an experiment.
43 * @param experiment_name
44 * Name of the experiment to run.
47 * Queue on which to run the experiment.
50 * A `sec_experiment_run_block_t` block upon which to execute the given experiment.
52 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
54 sec_experiment_run(const char *experiment_name
, dispatch_queue_t queue
, sec_experiment_run_block_t run_block
);
57 * @function sec_experiment_create
60 * Create an ARC-able `sec_experiment_t` instance
62 * @param experiment_name
63 * Name of the experiment.
65 * @return a `sec_experiment_t` instance.
67 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
68 SEC_RETURNS_RETAINED _Nullable sec_experiment_t
69 sec_experiment_create(const char *experiment_name
);
72 * @function sec_experiment_set_sampling_disabled
75 * Set a flag to disable experiment sampling.
76 * This function should only be used for testing purposes.
79 * A `sec_experiment_t` instance.
81 * @param sampling_disabled
82 * A flag indicating if sampling should be disabled.
84 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
86 sec_experiment_set_sampling_disabled(sec_experiment_t experiment
, bool sampling_disabled
);
89 * @function sec_experiment_copy_configuration
92 * Returns the configuration dictionary associated with the given experiment.
95 * A valid `sec_experiment_t` instance.
97 * @return xpc_object_t containing asset bundle, if client is not part of the experiment return NULL
99 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
100 SEC_RETURNS_RETAINED _Nullable xpc_object_t
101 sec_experiment_copy_configuration(sec_experiment_t experiment
);
104 * @function sec_experiment_get_identifier
107 * Returns a loggable identifier for the given experiment.
110 * A valid `sec_experiment_t` instance.
112 * @return A NULL-terminated, loggable experiment identifier.
114 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
115 const char * _Nullable
116 sec_experiment_get_identifier(sec_experiment_t experiment
);
118 SEC_ASSUME_NONNULL_END
120 #endif // SecExperiment_h