Exemplo n.º 1
0
 def _GetBrowserMainEntryTime(self, tab):
     """Returns the main entry time (in ms) of the browser."""
     histogram_type = histogram_util.BROWSER_HISTOGRAM
     high_bytes = histogram_util.GetHistogramSum(
         histogram_type, 'Startup.BrowserMainEntryTimeAbsoluteHighWord',
         tab)
     low_bytes = histogram_util.GetHistogramSum(
         histogram_type, 'Startup.BrowserMainEntryTimeAbsoluteLowWord', tab)
     if high_bytes == 0 and low_bytes == 0:
         return None
     return (int(high_bytes) << 32) | (int(low_bytes) << 1)
Exemplo n.º 2
0
  def AddResultsForPingback(self, tab, results):
    # Force the pingback by loading a new page.
    tab.Navigate('http://check.googlezip.net/test.html')
    histogram_type = histogram_util.BROWSER_HISTOGRAM
    # This histogram should be synchronously created when the Navigate occurs.
    attempted = histogram_util.GetHistogramSum(
        histogram_type,
        'DataReductionProxy.Pingback.Attempted',
        tab)
    # Verify that a pingback URLFetcher was created.
    if attempted != 1:
      raise ChromeProxyMetricException, (
          'Expected one pingback attempt, but '
          'received %d.' % attempted)
    count = 0
    seconds_slept = 0
    # This test relies on the proxy server responding to the pingback after
    # receiving it. This should very likely take under 10 seconds for the
    # integration test.
    max_seconds_to_sleep = 10
    while count < 1 and seconds_slept < max_seconds_to_sleep:
      # This histogram will be created when the URLRequest either fails or
      # succeeds.
      count = histogram_util.GetHistogramCount(
        histogram_type,
        'DataReductionProxy.Pingback.Succeeded',
        tab)
      if count < 1:
        time.sleep(1)
        seconds_slept += 1

    # The pingback should always succeed. Successful pingbacks contribute to the
    # sum of samples in the histogram, whereas failures only contribute to the
    # count of samples. Since DataReductionProxy.Pingback.Succeeded is a boolean
    # histogram, the sum of all samples in that histogram is equal to the
    # number of successful pingbacks.
    succeeded = histogram_util.GetHistogramSum(
      histogram_type,
      'DataReductionProxy.Pingback.Succeeded',
      tab)
    if succeeded != 1 or count != 1:
      raise ChromeProxyMetricException, (
          'Expected 1 pingback success and no failures, but '
          'there were %d succesful pingbacks and %d failed pingback attempts'
          % (succeeded, count - succeeded))
    results.AddValue(scalar.ScalarValue(
        results.current_page, 'attempted', 'count', attempted))
    results.AddValue(scalar.ScalarValue(
        results.current_page, 'succeeded_count', 'count', count))
    results.AddValue(scalar.ScalarValue(
        results.current_page, 'succeeded_sum', 'count', succeeded))
Exemplo n.º 3
0
  def AddResults(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))
Exemplo n.º 4
0
  def AddResultsForQuicTransaction(self, tab, results):
    histogram_type = histogram_util.BROWSER_HISTOGRAM
    # This histogram should be synchronously created when the Navigate occurs.
    # Verify that histogram DataReductionProxy.Quic.ProxyStatus has no samples
    # in bucket >=1.
    fail_counts_proxy_status = histogram_util.GetHistogramSum(
        histogram_type,
        'DataReductionProxy.Quic.ProxyStatus',
        tab)
    if fail_counts_proxy_status != 0:
      raise ChromeProxyMetricException, (
          'fail_counts_proxy_status is %d.' % fail_counts_proxy_status)

    # Verify that histogram DataReductionProxy.Quic.ProxyStatus has at least 1
    # sample. This sample must be in bucket 0 (QUIC_PROXY_STATUS_AVAILABLE).
    success_counts_proxy_status = histogram_util.GetHistogramCount(
        histogram_type,
        'DataReductionProxy.Quic.ProxyStatus',
        tab)
    if success_counts_proxy_status <= 0:
      raise ChromeProxyMetricException, (
          'success_counts_proxy_status is %d.' % success_counts_proxy_status)

    # Navigate to one more page to ensure that established QUIC connection
    # is used for the next request. Give 1 second extra headroom for the QUIC
    # connection to be established.
    time.sleep(1)
    tab.Navigate('http://check.googlezip.net/test.html')

    proxy_usage_histogram_json = histogram_util.GetHistogram(histogram_type,
        'Net.QuicAlternativeProxy.Usage',
        tab)
    proxy_usage_histogram = json.loads(proxy_usage_histogram_json)

    # Bucket ALTERNATIVE_PROXY_USAGE_NO_RACE should have at least one sample.
    if proxy_usage_histogram['buckets'][0]['count'] <= 0:
      raise ChromeProxyMetricException, (
          'Number of samples in ALTERNATIVE_PROXY_USAGE_NO_RACE bucket is %d.'
             % proxy_usage_histogram['buckets'][0]['count'])

    results.AddValue(scalar.ScalarValue(
        results.current_page, 'fail_counts_proxy_status', 'count',
        fail_counts_proxy_status))
    results.AddValue(scalar.ScalarValue(
        results.current_page, 'success_counts_proxy_status', 'count',
        success_counts_proxy_status))