Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Unified Diff: tracing/tracing/value/value.html

Issue 2334233003: Merge NumericValue into Histogram (Closed)
Patch Set: fix rail_power_metric Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/value/ui/value_set_view_test.html ('k') | tracing/tracing/value/value_set.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/value/value.html
diff --git a/tracing/tracing/value/value.html b/tracing/tracing/value/value.html
deleted file mode 100644
index 3bcfe9adac77d94e038fcb7c9ef4525bfd1b1411..0000000000000000000000000000000000000000
--- a/tracing/tracing/value/value.html
+++ /dev/null
@@ -1,143 +0,0 @@
-<!DOCTYPE html>
-<!--
-Copyright (c) 2015 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be
-found in the LICENSE file.
--->
-
-<link rel="import" href="/tracing/base/guid.html">
-<link rel="import" href="/tracing/base/iteration_helpers.html">
-<link rel="import" href="/tracing/base/utils.html">
-<link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html">
-
-<script>
-'use strict';
-
-tr.exportTo('tr.v', function() {
- /** @constructor */
- function Value(name, opt_options) {
- if (typeof(name) !== 'string')
- throw new Error('name must be a string');
-
- this.name_ = name;
- this.shortName = undefined;
-
- // If this Value is being deserialized, then its guid will be set by
- // fromDict().
- // If this Value is being computed by a metric, then its guid will be
- // allocated the first time the guid is gotten by asDict().
- this.guid_ = undefined;
-
- this.diagnostics = new tr.v.d.DiagnosticMap();
-
- var options = opt_options || {};
- this.description = options.description;
- this.important = options.important !== undefined ?
- options.important : false;
- }
-
- Value.fromDict = function(d) {
- var value = undefined;
- switch (d.type) {
- case 'numeric':
- value = NumericValue.fromDict(d);
- break;
-
- default:
- throw new Error('Not implemented');
- }
-
- value.guid = d.guid;
- value.shortName = d.shortName;
- value.diagnostics.addDicts(d.diagnostics);
- return value;
- };
-
- Value.prototype = {
- get guid() {
- if (this.guid_ === undefined)
- this.guid_ = tr.b.GUID.allocateUUID4();
-
- return this.guid_;
- },
-
- set guid(guid) {
- if (this.guid_ !== undefined)
- throw new Error('Cannot reset guid');
-
- this.guid_ = guid;
- },
-
- get name() {
- return this.name_;
- },
-
- asDict: function() {
- return this.asJSON();
- },
-
- asJSON: function() {
- var d = {
- guid: this.guid,
- name: this.name_,
- description: this.description,
- important: this.important,
- diagnostics: this.diagnostics.asDict()
- };
-
- if (this.shortName)
- d.shortName = this.shortName;
-
- this.asDictInto_(d);
- if (d.type === undefined)
- throw new Error('asDictInto_ must set type field');
- return d;
- },
-
- asDictInto_: function(d) {
- throw new Error('Not implemented');
- }
- };
-
- /** @constructor */
- function NumericValue(name, numeric, opt_options) {
- if (!(numeric instanceof tr.v.Histogram))
- throw new Error('Expected numeric to be instance of tr.v.Histogram');
-
- Value.call(this, name, opt_options);
- this.numeric = numeric;
- }
-
- NumericValue.fromDict = function(d) {
- if (d.numeric === undefined)
- throw new Error('Expected numeric to be provided');
- var numeric = tr.v.Histogram.fromDict(d.numeric);
- var value = new NumericValue(d.name, numeric, d);
- return value;
- };
-
- NumericValue.prototype = {
- __proto__: Value.prototype,
-
- merge: function(other) {
- if (!(other instanceof NumericValue))
- throw new Error('Merging non-NumericValues is not supported');
-
- var numeric = this.numeric.merge(other.numeric);
- var result = new NumericValue(this.name, numeric);
- // TODO(eakuefner): merge diagnostics?
- return result;
- },
-
- asDictInto_: function(d) {
- d.type = 'numeric';
- d.numeric = this.numeric.asDict();
- }
- };
-
- return {
- Value: Value,
- NumericValue: NumericValue,
- };
-});
-</script>
« no previous file with comments | « tracing/tracing/value/ui/value_set_view_test.html ('k') | tracing/tracing/value/value_set.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698