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 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
| |
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']) | |
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 :)
| |
29 | |
30 def AddResultsMac(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)) | |
41 | |
42 def AddResults(self, tab, results): | |
43 """This method should never be called.""" | |
44 assert False | |
OLD | NEW |