mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 838072 - Part 2: Add collectDailyData API to providers; r=rnewman
This commit is contained in:
parent
23ab086600
commit
2e58450766
@ -167,6 +167,14 @@ Collector.prototype = Object.freeze({
|
||||
onCollect);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls collectDailyData on all providers.
|
||||
*/
|
||||
collectDailyData: function () {
|
||||
return this._callCollectOnProviders(this._providers.values(),
|
||||
"collectDailyData");
|
||||
},
|
||||
|
||||
_callCollectOnProviders: function (entries, fnProperty, onCollect=null) {
|
||||
let promises = [];
|
||||
|
||||
|
@ -523,11 +523,29 @@ Provider.prototype = Object.freeze({
|
||||
*
|
||||
* Implementations should return a promise that resolves when all data has
|
||||
* been collected and storage operations have been finished.
|
||||
*
|
||||
* @return Promise<>
|
||||
*/
|
||||
collectConstantData: function () {
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
* Collects data approximately every day.
|
||||
*
|
||||
* For long-running applications, this is called approximately every day.
|
||||
* It may or may not be called every time the application is run. It also may
|
||||
* be called more than once per day.
|
||||
*
|
||||
* Implementations should return a promise that resolves when all data has
|
||||
* been collected and storage operations have completed.
|
||||
*
|
||||
* @return Promise<>
|
||||
*/
|
||||
collectDailyData: function () {
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
* Queue a deferred storage operation.
|
||||
*
|
||||
|
@ -54,6 +54,8 @@ this.DummyProvider = function DummyProvider(name="DummyProvider") {
|
||||
this.throwDuringCollectConstantData = null;
|
||||
this.throwDuringConstantPopulate = null;
|
||||
|
||||
this.collectDailyCount = 0;
|
||||
|
||||
this.havePushedMeasurements = true;
|
||||
}
|
||||
|
||||
@ -86,6 +88,11 @@ DummyProvider.prototype = {
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
collectDailyData: function () {
|
||||
this.collectDailyCount++;
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
@ -128,3 +128,24 @@ add_task(function test_collect_multiple() {
|
||||
yield storage.close();
|
||||
});
|
||||
|
||||
add_task(function test_collect_daily() {
|
||||
let storage = yield Metrics.Storage("collect_daily");
|
||||
let collector = new Metrics.Collector(storage);
|
||||
|
||||
let provider1 = new DummyProvider("DP1");
|
||||
let provider2 = new DummyProvider("DP2");
|
||||
|
||||
yield collector.registerProvider(provider1);
|
||||
yield collector.registerProvider(provider2);
|
||||
|
||||
yield collector.collectDailyData();
|
||||
do_check_eq(provider1.collectDailyCount, 1);
|
||||
do_check_eq(provider2.collectDailyCount, 1);
|
||||
|
||||
yield collector.collectDailyData();
|
||||
do_check_eq(provider1.collectDailyCount, 2);
|
||||
do_check_eq(provider2.collectDailyCount, 2);
|
||||
|
||||
yield storage.close();
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user