blob: 7b798f4f6e074749a9d97a5927d6a48e0198d7c6 [file] [log] [blame]
<!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">
<script>
'use strict';
tr.exportTo('pi.v', function() {
// This value must stay sync'd with the constant of the same name
// in run_info.py.
var PI_VALUE_RUN_INFO_ID = 'perf_insights.value.RunInfo';
function RunInfo(url, opt_display_name, opt_run_id, opt_metadata) {
if (opt_run_id !== undefined)
this.run_id = opt_run_id;
else
this.run_id = 'pi.v.RunInfo-' + tr.b.GUID.allocate();
this.url = url;
if (opt_display_name !== undefined)
this.display_name = opt_display_name;
else
this.display_name = this.url;
if (opt_metadata !== undefined)
this.metadata = opt_metadata;
else
this.metadata = {};
}
RunInfo.fromDict = function(d) {
if (d.type !== PI_VALUE_RUN_INFO_ID)
throw new Error('Unsupported run_info format: ' + d.type);
if (d.run_id === undefined)
throw new Error('Must contain run_id');
if (d.url === undefined)
throw new Error('Must contain url');
return new RunInfo(d.url, d.display_name, d.run_id, d.metadata);
};
RunInfo.prototype = {
asDict: function() {
return {
type: PI_VALUE_RUN_INFO_ID,
run_id: this.run_id,
url: this.url,
metadata: this.metadata
};
}
};
return {
RunInfo: RunInfo
};
});
</script>