Allow offsets in blobs larger than 2GB on 32 bit Chromium builds.
[chromium-blink-merge.git] / tools / perf / metrics / keychain_metric.py
bloba2c89fa92ef80851a0a223c54f7d47f78b8caed0
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.
5 import logging
6 import sys
8 from metrics import Metric
9 from telemetry.util.mac import keychain_helper
10 from telemetry.value import histogram_util
11 from telemetry.value import scalar
14 class KeychainMetric(Metric):
15 """KeychainMetric gathers keychain statistics from the browser object.
17 This includes the number of times that the keychain was accessed.
18 """
20 DISPLAY_NAME = 'OSX_Keychain_Access'
21 HISTOGRAM_NAME = 'OSX.Keychain.Access'
23 @staticmethod
24 def _CheckKeychainConfiguration():
25 """
26 On OSX, it is possible for a misconfigured keychain to cause the
27 Telemetry tests to stall. This method confirms that the keychain is in a
28 sane state that will not cause this behavior. Three conditions are checked:
29 - The keychain is unlocked.
30 - The keychain will not auto-lock after a period of time.
31 - The ACLs are correctly configured on the relevant keychain items.
32 """
33 warning_suffix = ('which will cause some Telemetry tests to stall when run'
34 ' on a headless machine (e.g. perf bot).')
35 if keychain_helper.IsKeychainLocked():
36 logging.warning('The default keychain is locked, %s', warning_suffix)
38 if keychain_helper.DoesKeychainHaveTimeout():
39 logging.warning('The default keychain is configured to automatically'
40 ' lock itself have a period of time, %s', warning_suffix)
42 chrome_acl_configured = (keychain_helper.
43 IsKeychainConfiguredForBotsWithChrome())
44 chromium_acl_configured = (keychain_helper.
45 IsKeychainConfiguredForBotsWithChromium())
46 acl_warning = ('A commonly used %s key stored in the default keychain does'
47 ' not give decryption access to all applications, %s')
48 if not chrome_acl_configured:
49 logging.warning(acl_warning, 'Chrome', warning_suffix)
50 if not chromium_acl_configured:
51 logging.warning(acl_warning, 'Chromium', warning_suffix)
53 @classmethod
54 def CustomizeBrowserOptions(cls, options):
55 """Adds a browser argument that allows for the collection of keychain
56 metrics. Has no effect on non-Mac platforms."""
57 if sys.platform != 'darwin':
58 return
60 KeychainMetric._CheckKeychainConfiguration()
62 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings'])
64 def AddResults(self, tab, results):
65 """Adds the number of times that the keychain was accessed to |results|.
66 Has no effect on non-Mac platforms."""
67 if sys.platform != 'darwin':
68 return
70 access_count = histogram_util.GetHistogramSum(
71 histogram_util.BROWSER_HISTOGRAM, KeychainMetric.HISTOGRAM_NAME, tab)
72 results.AddValue(scalar.ScalarValue(
73 results.current_page, KeychainMetric.DISPLAY_NAME, 'count',
74 access_count))