Commit d8082f18 authored by nednguyen@google.com's avatar nednguyen@google.com

Remove results.Add and value_backcompat.

BUG=346958

Review URL: https://codereview.chromium.org/402663002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283826 0039d316-1c4b-4281-b951-d872f2087c98
parent 84a6d6ce
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# found in the LICENSE file. # found in the LICENSE file.
from telemetry.results import page_test_results from telemetry.results import page_test_results
from telemetry.value import value_backcompat
class PageMeasurementResults(page_test_results.PageTestResults): class PageMeasurementResults(page_test_results.PageTestResults):
def __init__(self, output_stream=None, trace_tag=''): def __init__(self, output_stream=None, trace_tag=''):
...@@ -27,15 +26,6 @@ class PageMeasurementResults(page_test_results.PageTestResults): ...@@ -27,15 +26,6 @@ class PageMeasurementResults(page_test_results.PageTestResults):
self._current_page = page self._current_page = page
self._page_specific_values_for_current_page = [] self._page_specific_values_for_current_page = []
# TODO(nednguyen): Ned has a patch to kill this.
def Add(self, trace_name, units, value, chart_name=None, data_type='default'):
assert self._current_page
# TODO(isherman): Remove this as well.
value = value_backcompat.ConvertOldCallingConventionToValue(
self._current_page,
trace_name, units, value, chart_name, data_type)
self.AddValue(value)
def AddValue(self, value): def AddValue(self, value):
super(PageMeasurementResults, self).AddValue(value) super(PageMeasurementResults, self).AddValue(value)
self._page_specific_values_for_current_page.append(value) self._page_specific_values_for_current_page.append(value)
......
# Copyright 2013 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.
"""Backward compatibility for old results API.
This module helps convert the old PageMeasurementResults API into the new
style one. This exists as a bridging solution so we can change the underlying
implementation and update the PageMeasurementResults API once we know the
underlying implementation is solid.
"""
from telemetry import value as value_module
from telemetry.value import histogram
from telemetry.value import list_of_scalar_values
from telemetry.value import scalar
def ConvertOldCallingConventionToValue(page, trace_name, units,
value, chart_name, data_type):
value_name = value_module.ValueNameFromTraceAndChartName(
trace_name, chart_name)
if data_type == 'default':
if isinstance(value, list):
return list_of_scalar_values.ListOfScalarValues(
page, value_name, units, value, important=True)
else:
return scalar.ScalarValue(page, value_name, units,
value, important=True)
elif data_type == 'unimportant':
if isinstance(value, list):
return list_of_scalar_values.ListOfScalarValues(
page, value_name, units, value, important=False)
else:
return scalar.ScalarValue(page, value_name, units,
value, important=False)
elif data_type == 'histogram':
assert isinstance(value, basestring)
return histogram.HistogramValue(
page, value_name, units, raw_value_json=value, important=True)
elif data_type == 'unimportant-histogram':
assert isinstance(value, basestring)
return histogram.HistogramValue(
page, value_name, units, raw_value_json=value, important=False)
elif data_type == 'informational':
raise NotImplementedError()
else:
raise ValueError('Unrecognized data type %s', data_type)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment