blob: 56b39e3ea09c11a4fddd8eea3072d6c23807f7c7 [file] [log] [blame]
# 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.
import uuid
class RunInfo(object):
def __init__(self, url, display_name=None, run_id=None, metadata=None):
if run_id is not None:
self.run_id = run_id
else:
self.run_id = str(uuid.uuid4())
self.url = url
self.display_name = display_name or url
self.metadata = metadata or {}
def AsDict(self):
return {
'run_id': self.run_id,
'type': 'perf_insights.value.RunInfo',
'url': self.url,
'metadata': self.metadata
}
@staticmethod
def FromDict(d):
if d['type'] != 'perf_insights.results.RunInfo':
raise Exception('Unsupported run_info format')
return RunInfo(d['url'],
d['display_name'],
run_id=d['run_id'],
metadata=d.get('metadata', None))