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): |
jeremy
2014/12/09 14:57:17
I'd remove Mac from this and the other method name
dtu
2014/12/09 22:05:20
Either way is fine to me.
erikchen
2014/12/13 02:39:58
I intentionally changed the names to include the s
|
+ """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']) |
jeremy
2014/12/09 14:57:17
I guess nothing bad will happen if this is appende
dtu
2014/12/09 22:05:20
I think the AppendExtraBrowserArgs method removes
jeremy
2014/12/10 05:35:18
Good to know, please ignore my comment then :)
|
+ |
+ def AddResultsMac(self, tab, results): |
+ """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 |