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..e2ad874ff1f5657b60694299271b23a7a43a6059 |
--- /dev/null |
+++ b/tools/perf/metrics/keychain_metric.py |
@@ -0,0 +1,31 @@ |
+# 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 json |
+ |
+from metrics import Metric |
+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' |
+ |
+ def AddResults(self, tab, results): |
+ """Adds the number of times that the keychain was accessed to |results|.""" |
+ get_histogram_js = 'statsCollectionController.getBrowserHistogram("%s")' |
+ |
+ result = tab.EvaluateJavaScript(get_histogram_js % self.HISTOGRAM_NAME) |
+ result = json.loads(result) |
+ |
+ access_count = 0 |
+ if result: |
jeremy
2014/11/13 11:31:30
Do you think we should fail if there are no entrie
erikchen
2014/11/13 22:52:59
If the keychain is never accessed, then there are
|
+ access_count = result['sum'] |
+ results.AddValue(scalar.ScalarValue( |
+ results.current_page, self.DISPLAY_NAME, 'count', access_count)) |