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

Unified Diff: tools/perf/metrics/keychain_metric.py

Issue 714273004: mac: Expose keychain access frequency to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock_keychain_sleep
Patch Set: Add a common subclass to measurements. Created 6 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
« tools/perf/measurements/__init__.py ('K') | « tools/perf/measurements/webrtc.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
« tools/perf/measurements/__init__.py ('K') | « tools/perf/measurements/webrtc.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698