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

Unified Diff: tools/telemetry/telemetry/value/value_backcompat.py

Issue 27486002: Cleanup of page_measurement_results object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: keep on trying Created 7 years, 1 month 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
Index: tools/telemetry/telemetry/value/value_backcompat.py
diff --git a/tools/telemetry/telemetry/value/value_backcompat.py b/tools/telemetry/telemetry/value/value_backcompat.py
new file mode 100644
index 0000000000000000000000000000000000000000..b7318bcaa2108e36d945a654a1a74f234bf59982
--- /dev/null
+++ b/tools/telemetry/telemetry/value/value_backcompat.py
@@ -0,0 +1,46 @@
+# Copyright (c) 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.histogram import HistogramValue
+from telemetry.value.list_of_scalar_values import ListOfScalarValues
+from telemetry.value.scalar import ScalarValue
+
+
+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 ListOfScalarValues(page, value_name, units,
+ value, important=True)
+ else:
+ return ScalarValue(page, value_name, units,
+ value, important=True)
+ elif data_type == 'unimportant':
+ if isinstance(value, list):
+ return ListOfScalarValues(page, value_name, units,
+ value, important=False)
+ else:
+ return ScalarValue(page, value_name, units,
+ value, important=False)
+ elif data_type == 'histogram':
+ assert isinstance(value, basestring)
+ return HistogramValue(page, value_name, units,
+ raw_value_json=value, important=True)
+ elif data_type == 'unimportant-histogram':
+ assert isinstance(value, basestring)
+ return 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)
« no previous file with comments | « tools/telemetry/telemetry/value/scalar_unittest.py ('k') | tools/telemetry/telemetry/value/value_unittest_.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698