OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import sys |
| 6 |
| 7 from metrics import Metric |
| 8 from telemetry.value import histogram_util |
| 9 from telemetry.value import scalar |
| 10 |
| 11 |
| 12 class KeychainMetric(Metric): |
| 13 """KeychainMetric gathers keychain statistics from the browser object. |
| 14 |
| 15 This includes the number of times that the keychain was accessed. |
| 16 """ |
| 17 |
| 18 DISPLAY_NAME = 'OSX_Keychain_Access' |
| 19 HISTOGRAM_NAME = 'OSX.Keychain.Access' |
| 20 |
| 21 @classmethod |
| 22 def CustomizeBrowserOptions(cls, options): |
| 23 """Adds a browser argument that allows for the collection of keychain |
| 24 metrics. Has no effect on non-Mac platforms.""" |
| 25 if sys.platform != 'darwin': |
| 26 return |
| 27 |
| 28 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
| 29 |
| 30 def AddResults(self, tab, results): |
| 31 """Adds the number of times that the keychain was accessed to |results|. |
| 32 Has no effect on non-Mac platforms.""" |
| 33 if sys.platform != 'darwin': |
| 34 return |
| 35 |
| 36 access_count = histogram_util.GetHistogramSum( |
| 37 histogram_util.BROWSER_HISTOGRAM, KeychainMetric.HISTOGRAM_NAME, tab) |
| 38 results.AddValue(scalar.ScalarValue( |
| 39 results.current_page, KeychainMetric.DISPLAY_NAME, 'count', |
| 40 access_count)) |
OLD | NEW |