summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html')
-rw-r--r--chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html74
1 files changed, 29 insertions, 45 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html
index 4af13e22d54..e0afe91d668 100644
--- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html
+++ b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html
@@ -11,85 +11,69 @@ found in the LICENSE file.
Diagnostic registry.
-->
-<link rel="import" href="/tracing/value/diagnostics/composition.html">
+<link rel="import" href="/tracing/value/diagnostics/breakdown.html">
<link rel="import" href="/tracing/value/diagnostics/generic.html">
<link rel="import" href="/tracing/value/diagnostics/iteration_info.html">
<link rel="import" href="/tracing/value/diagnostics/related_event_set.html">
+<link rel="import" href="/tracing/value/diagnostics/related_histogram_breakdown.html">
<link rel="import" href="/tracing/value/diagnostics/related_value_map.html">
<link rel="import" href="/tracing/value/diagnostics/related_value_set.html">
+<link rel="import" href="/tracing/value/diagnostics/scalar.html">
<script>
'use strict';
tr.exportTo('tr.v.d', function() {
- /** @constructor */
- function DiagnosticMap() {
- this.diagnosticsByName_ = {};
- }
-
- DiagnosticMap.prototype = {
+ class DiagnosticMap extends Map {
/**
* Add a new Diagnostic to this map.
*
* @param {string} name
* @param {!tr.v.d.Diagnostic} diagnostic
*/
- add: function(name, diagnostic) {
- if (!(diagnostic instanceof tr.v.d.Diagnostic))
- throw new Error('Must be instanceof Diagnostic: ' + diagnostic);
-
+ set(name, diagnostic) {
if (typeof(name) !== 'string')
throw new Error('name must be string, not ' + name);
- if (this.diagnosticsByName_[name])
- throw new Error('Attempt to add duplicate diagnostic ' + name);
+ if (!(diagnostic instanceof tr.v.d.Diagnostic))
+ throw new Error('Must be instanceof Diagnostic: ' + diagnostic);
- this.diagnosticsByName_[name] = diagnostic;
- },
+ Map.prototype.set.call(this, name, diagnostic);
+ }
/**
* Add Diagnostics from a dictionary of dictionaries.
*
* @param {Object} dict
*/
- addDicts: function(dict) {
+ addDicts(dict) {
tr.b.iterItems(dict, function(name, diagnosticDict) {
- this.add(name, tr.v.d.Diagnostic.fromDict(diagnosticDict));
+ this.set(name, tr.v.d.Diagnostic.fromDict(diagnosticDict));
}, this);
- },
-
- /**
- * @param {string} name
- * @return {tr.v.d.Diagnostic}
- */
- get: function(name) {
- return this.diagnosticsByName_[name];
- },
-
- /**
- * Iterate over this map's key-value-pairs.
- *
- * @param {function(string, tr.v.d.Diagnostic)} callback
- * @param {Object=} opt_this
- */
- forEach: function(callback, opt_this) {
- tr.b.iterItems(this.diagnosticsByName_, callback, opt_this || this);
- },
+ }
- asDict: function() {
+ asDict() {
var dict = {};
- this.forEach(function(name, diagnostic) {
+ for (var [name, diagnostic] of this) {
dict[name] = diagnostic.asDict();
- });
+ }
return dict;
}
- };
- DiagnosticMap.fromDict = function(d) {
- var diagnostics = new DiagnosticMap();
- diagnostics.addDicts(d);
- return diagnostics;
- };
+ static fromDict(d) {
+ var diagnostics = new DiagnosticMap();
+ diagnostics.addDicts(d);
+ return diagnostics;
+ }
+
+ static fromObject(obj) {
+ var diagnostics = new DiagnosticMap();
+ tr.b.iterItems(obj, function(name, diagnostic) {
+ diagnostics.set(name, diagnostic);
+ });
+ return diagnostics;
+ }
+ }
return {
DiagnosticMap: DiagnosticMap