mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 828540 - Part 2: APIs to retrieve a registered provider; r=rnewman
--HG-- extra : rebase_source : 0b91c4da3adc153ff102872ce88245bab2c7cf7c
This commit is contained in:
parent
b38fb3ce82
commit
d23ad1c3e9
@ -508,6 +508,17 @@ HealthReporter.prototype = Object.freeze({
|
||||
// Provider Management
|
||||
//--------------------
|
||||
|
||||
/**
|
||||
* Obtain a provider from its name.
|
||||
*
|
||||
* This will only return providers that are currently initialized. If
|
||||
* a provider is lazy initialized (like constant-only providers) this
|
||||
* will likely not return anything.
|
||||
*/
|
||||
getProvider: function (name) {
|
||||
return this._collector.getProvider(name);
|
||||
},
|
||||
|
||||
/**
|
||||
* Register a `Metrics.Provider` with this instance.
|
||||
*
|
||||
|
@ -191,6 +191,8 @@ add_task(function test_constant_only_providers() {
|
||||
do_check_eq(reporter._collector._providers.size, 1);
|
||||
do_check_true(reporter._storage.hasProvider("DummyProvider"));
|
||||
do_check_false(reporter._storage.hasProvider("DummyConstantProvider"));
|
||||
do_check_neq(reporter.getProvider("DummyProvider"), null);
|
||||
do_check_null(reporter.getProvider("DummyConstantProvider"));
|
||||
|
||||
yield reporter.ensureConstantOnlyProvidersRegistered();
|
||||
yield reporter.collectMeasurements();
|
||||
|
@ -45,6 +45,19 @@ Collector.prototype = Object.freeze({
|
||||
return providers;
|
||||
},
|
||||
|
||||
/**
|
||||
* Obtain a provider from its name.
|
||||
*/
|
||||
getProvider: function (name) {
|
||||
let provider = this._providers.get(name);
|
||||
|
||||
if (!provider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return provider.provider;
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers a `MetricsProvider` with this collector.
|
||||
*
|
||||
|
@ -30,6 +30,7 @@ add_task(function test_register_provider() {
|
||||
yield collector.registerProvider(dummy);
|
||||
do_check_eq(collector._providers.size, 1);
|
||||
do_check_eq(collector.providerErrors.size, 1);
|
||||
do_check_eq(collector.getProvider(dummy.name), dummy);
|
||||
|
||||
let failed = false;
|
||||
try {
|
||||
@ -44,6 +45,7 @@ add_task(function test_register_provider() {
|
||||
|
||||
collector.unregisterProvider(dummy.name);
|
||||
do_check_eq(collector._providers.size, 0);
|
||||
do_check_null(collector.getProvider(dummy.name));
|
||||
|
||||
yield storage.close();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user