Chromium Code Reviews| Index: tools/perf/metrics/keychain_metric.py |
| diff --git a/tools/perf/metrics/keychain_metric.py b/tools/perf/metrics/keychain_metric.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..710d542e622f3089e69250aef4755529d3a90080 |
| --- /dev/null |
| +++ b/tools/perf/metrics/keychain_metric.py |
| @@ -0,0 +1,44 @@ |
| +# Copyright 2014 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 sys |
| + |
| +from metrics import Metric |
| +from telemetry.value import histogram_util |
| +from telemetry.value import scalar |
| + |
| + |
| +class KeychainMetric(Metric): |
| + """KeychainMetric gathers keychain statistics from the browser object. |
| + |
| + This includes the number of times that the keychain was accessed. |
| + """ |
| + |
| + DISPLAY_NAME = 'OSX_Keychain_Access' |
| + HISTOGRAM_NAME = 'OSX.Keychain.Access' |
| + |
| + @classmethod |
| + def CustomizeBrowserOptionsMac(cls, options): |
| + """Adds a browser argument that allows for the collection of keychain |
| + metrics. Has no effect on non-Mac platforms.""" |
| + if sys.platform != 'darwin': |
| + return |
| + |
| + options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
| + |
| + def AddResultsMac(self, tab, results): |
|
jeremy
2014/12/14 08:55:50
I feel quite strongly that these should just be ca
|
| + """Adds the number of times that the keychain was accessed to |results|. |
| + Has no effect on non-Mac platforms.""" |
| + if sys.platform != 'darwin': |
| + return |
| + |
| + access_count = histogram_util.GetHistogramSum( |
| + histogram_util.BROWSER_HISTOGRAM, KeychainMetric.HISTOGRAM_NAME, tab) |
| + results.AddValue(scalar.ScalarValue( |
| + results.current_page, KeychainMetric.DISPLAY_NAME, 'count', |
| + access_count)) |
| + |
| + def AddResults(self, tab, results): |
| + """This method should never be called.""" |
| + assert False |