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 json | |
6 | |
7 from metrics import Metric | |
8 from telemetry.value import scalar | |
9 | |
10 | |
11 class KeychainMetric(Metric): | |
12 """KeychainMetric gathers keychain statistics from the browser object. | |
13 | |
14 This includes the number of times that the keychain was accessed. | |
15 """ | |
16 | |
17 DISPLAY_NAME = 'OSX_Keychain_Access' | |
18 HISTOGRAM_NAME = 'OSX.Keychain.Access' | |
19 | |
20 def AddResults(self, tab, results): | |
21 """Adds the number of times that the keychain was accessed to |results|.""" | |
22 get_histogram_js = 'statsCollectionController.getBrowserHistogram("%s")' | |
23 | |
24 result = tab.EvaluateJavaScript(get_histogram_js % self.HISTOGRAM_NAME) | |
25 result = json.loads(result) | |
26 | |
27 access_count = 0 | |
28 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
| |
29 access_count = result['sum'] | |
30 results.AddValue(scalar.ScalarValue( | |
31 results.current_page, self.DISPLAY_NAME, 'count', access_count)) | |
OLD | NEW |