1# Copyright 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5class Metric(object):
6  """Base class for all the metrics that are used by telemetry measurements.
7
8  The Metric class represents a way of measuring something. Metrics are
9  helper classes used by PageMeasurements. Each PageMeasurement may use
10  multiple metrics; each metric should be focussed on collecting data
11  about one thing.
12  """
13
14  def Start(self, page, tab):
15    """Start collecting data for this metric."""
16    raise NotImplementedError()
17
18  def Stop(self, page, tab):
19    """Stop collecting data for this metric (if applicable)."""
20    raise NotImplementedError()
21
22  def AddResults(self, tab, results):
23    """Add the data collected into the results object for a measurement.
24
25    Metrics may implement AddResults to provide a common way to add results
26    to the PageMeasurementResults in PageMeasurement.AddMeasurement --
27    results should be added with results.Add(trace_name, unit, value).
28    """
29    raise NotImplementedError()
30
31