6 #ifndef SecExperiment_h
7 #define SecExperiment_h
9 #include <Security/SecProtocolObject.h>
12 #ifndef SEC_EXP_OBJECT_IMPL
13 SEC_OBJECT_DECL(sec_experiment
);
14 #endif // !SEC_EXP_OBJECT_IMPL
16 SEC_ASSUME_NONNULL_BEGIN
18 extern const char *kSecExperimentTLSProbe
;
19 extern const char *kSecExperimentDefaultsDomain
;
22 * @block sec_experiment_run_block_t
24 * @abstract A block to execute an experiment with a loggable identifier
25 * and configuration. `identifier` will be uniquely associated with
26 * `experiment_config` and should be used when measuring data.
29 * Identifier for the experiment.
31 * @param experiment_config
32 * Configuration of this experiment.
34 * @return True if the experiment ran successfully, and false otherwise.
36 typedef bool (^sec_experiment_run_block_t
)(const char *identifier
, xpc_object_t experiment_config
);
39 * @block sec_experiment_skip_block_t
41 * @abstract A block to execute when an experiment run is skipped.
44 * Identifier for the experiment.
46 typedef void (^sec_experiment_skip_block_t
)(const char *identifier
);
49 * @function sec_experiment_run
52 * Asynchronously run an experiment.
54 * @param experiment_name
55 * Name of the experiment to run.
58 * A `sec_experiment_run_block_t` block upon which to execute the given experiment.
61 * An optional `sec_experiment_skip_block_t` block that is invoked when the chosen experiment is skipped.
63 * @return True if the experiment was started, and false otherwise.
65 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
67 sec_experiment_run(const char *experiment_name
,
68 sec_experiment_run_block_t run_block
,
69 sec_experiment_skip_block_t _Nullable skip_block
);
71 #define SEC_EXPERIMENT_HAS_ASYNC_WITH_SAMPLING_DISABLED 1
74 * @function sec_experiment_run_with_sampling_disabled
77 * Synchronously run an experiment and optionally disable sampling. Passing `true` to the `sampling_disabled` parameter
78 * will cause the experiment to always run. Clients typically SHOULD NOT do this unless running as part of test tools and utilities.
80 * @param experiment_name
81 * Name of the experiment to run.
84 * A `sec_experiment_run_block_t` block upon which to execute the given experiment.
87 * An optional `sec_experiment_skip_block_t` block that is invoked when the chosen experiment is skipped.
89 * @param sampling_disabled
90 * A boolean indicating if sampling should be disabled for the given asynchronous experiment run.
92 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
94 sec_experiment_run_with_sampling_disabled(const char *experiment_name
,
95 sec_experiment_run_block_t run_block
,
96 sec_experiment_skip_block_t _Nullable skip_block
,
97 bool sampling_disabled
);
100 * @function sec_experiment_run_async
103 * Asynchronously run an experiment.
105 * @param experiment_name
106 * Name of the experiment to run.
109 * Queue on which to run the experiment.
112 * A `sec_experiment_run_block_t` block upon which to execute the given experiment.
115 * An optional `sec_experiment_skip_block_t` block that is invoked when the chosen experiment is skipped.
117 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
119 sec_experiment_run_async(const char *experiment_name
,
120 dispatch_queue_t queue
,
121 sec_experiment_run_block_t run_block
,
122 sec_experiment_skip_block_t _Nullable skip_block
);
125 * @function sec_experiment_run_async
128 * Asynchronously run an experiment and optionally disable sampling. Passing `true` to the `sampling_disabled` parameter
129 * will cause the experiment to always run. Clients typically SHOULD NOT do this unless running as part of test tools and utilities.
131 * @param experiment_name
132 * Name of the experiment to run.
135 * Queue on which to run the experiment.
138 * A `sec_experiment_run_block_t` block upon which to execute the given experiment.
141 * An optional `sec_experiment_skip_block_t` block that is invoked when the chosen experiment is skipped.
143 * @param sampling_disabled
144 * A boolean indicating if sampling should be disabled for the given asynchronous experiment run.
146 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
148 sec_experiment_run_async_with_sampling_disabled(const char *experiment_name
,
149 dispatch_queue_t queue
,
150 sec_experiment_run_block_t run_block
,
151 sec_experiment_skip_block_t _Nullable skip_block
,
152 bool sampling_disabled
);
155 * @function sec_experiment_create
158 * Create an ARC-able `sec_experiment_t` instance
160 * @param experiment_name
161 * Name of the experiment.
163 * @return a `sec_experiment_t` instance.
165 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
166 SEC_RETURNS_RETAINED _Nullable sec_experiment_t
167 sec_experiment_create(const char *experiment_name
);
170 * @function sec_experiment_set_sampling_disabled
173 * Set a flag to disable experiment sampling.
174 * This function should only be used for testing purposes.
177 * A `sec_experiment_t` instance.
179 * @param sampling_disabled
180 * A flag indicating if sampling should be disabled.
182 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
184 sec_experiment_set_sampling_disabled(sec_experiment_t experiment
,
185 bool sampling_disabled
);
188 * @function sec_experiment_copy_configuration
191 * Returns the configuration dictionary associated with the given experiment.
194 * A valid `sec_experiment_t` instance.
196 * @return xpc_object_t containing asset bundle, if client is not part of the experiment return NULL
198 API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
199 SEC_RETURNS_RETAINED _Nullable xpc_object_t
200 sec_experiment_copy_configuration(sec_experiment_t experiment
);
202 SEC_ASSUME_NONNULL_END
204 #endif // SecExperiment_h