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

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: Comments from dtu. Created 6 years 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
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
« tools/perf/measurements/session_restore.py ('K') | « tools/perf/measurements/tab_switching.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698