2016-08-03 18:00:07 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-08-26 19:34:08 -04:00
|
|
|
import {OpaqueToken} from '@angular/core';
|
2016-08-03 18:00:07 -04:00
|
|
|
|
2015-05-27 17:57:54 -04:00
|
|
|
import {Options} from './common_options';
|
2016-08-03 18:00:07 -04:00
|
|
|
import {Metric} from './metric';
|
|
|
|
import {Validator} from './validator';
|
|
|
|
|
2015-05-27 17:57:54 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SampleDescription merges all available descriptions about a sample
|
|
|
|
*/
|
|
|
|
export class SampleDescription {
|
2016-08-26 19:34:08 -04:00
|
|
|
static PROVIDERS = [{
|
|
|
|
provide: SampleDescription,
|
|
|
|
useFactory:
|
|
|
|
(metric: Metric, id: string, forceGc: boolean, userAgent: string, validator: Validator,
|
|
|
|
defaultDesc: {[key: string]: string}, userDesc: {[key: string]: string}) =>
|
|
|
|
new SampleDescription(
|
|
|
|
id,
|
|
|
|
[
|
|
|
|
{'forceGc': forceGc, 'userAgent': userAgent}, validator.describe(), defaultDesc,
|
|
|
|
userDesc
|
|
|
|
],
|
|
|
|
metric.describe()),
|
|
|
|
deps: [
|
|
|
|
Metric, Options.SAMPLE_ID, Options.FORCE_GC, Options.USER_AGENT, Validator,
|
|
|
|
Options.DEFAULT_DESCRIPTION, Options.SAMPLE_DESCRIPTION
|
|
|
|
]
|
|
|
|
}];
|
2015-10-02 19:47:54 -04:00
|
|
|
description: {[key: string]: any};
|
2015-05-27 17:57:54 -04:00
|
|
|
|
2016-08-03 18:00:07 -04:00
|
|
|
constructor(
|
|
|
|
public id: string, descriptions: Array<{[key: string]: any}>,
|
|
|
|
public metrics: {[key: string]: any}) {
|
2015-05-27 17:57:54 -04:00
|
|
|
this.description = {};
|
2015-10-07 12:09:43 -04:00
|
|
|
descriptions.forEach(description => {
|
2016-10-03 19:46:05 -04:00
|
|
|
Object.keys(description).forEach(prop => { this.description[prop] = description[prop]; });
|
2015-05-27 17:57:54 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
|
|
|
|
}
|