| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import contextlib | 6 import contextlib |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 sys.path.append(os.path.join(_SRC_DIR, 'build', 'android')) | 25 sys.path.append(os.path.join(_SRC_DIR, 'build', 'android')) |
| 26 from pylib import constants | 26 from pylib import constants |
| 27 from video_recorder import video_recorder | 27 from video_recorder import video_recorder |
| 28 | 28 |
| 29 sys.path.append(os.path.join(_SRC_DIR, 'tools', 'perf')) | 29 sys.path.append(os.path.join(_SRC_DIR, 'tools', 'perf')) |
| 30 from chrome_telemetry_build import chromium_config | 30 from chrome_telemetry_build import chromium_config |
| 31 | 31 |
| 32 sys.path.append(chromium_config.GetTelemetryDir()) | 32 sys.path.append(chromium_config.GetTelemetryDir()) |
| 33 from telemetry.internal.image_processing import video | 33 from telemetry.internal.image_processing import video |
| 34 from telemetry.internal.util import webpagereplay | 34 from telemetry.internal.util import wpr_server |
| 35 | 35 |
| 36 sys.path.append(os.path.join( | 36 sys.path.append(os.path.join( |
| 37 _CATAPULT_DIR, 'telemetry', 'third_party', 'webpagereplay')) | 37 _CATAPULT_DIR, 'telemetry', 'third_party', 'webpagereplay')) |
| 38 import adb_install_cert | 38 import adb_install_cert |
| 39 import certutils | 39 import certutils |
| 40 | 40 |
| 41 import common_util | 41 import common_util |
| 42 import devtools_monitor | 42 import devtools_monitor |
| 43 import emulation | 43 import emulation |
| 44 import options | 44 import options |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 '--https_root_ca_cert_path=' + PathWorkaround(wpr_ca_cert_path)]) | 209 '--https_root_ca_cert_path=' + PathWorkaround(wpr_ca_cert_path)]) |
| 210 if out_log_path: | 210 if out_log_path: |
| 211 # --log_level debug to extract the served URLs requests from the log. | 211 # --log_level debug to extract the served URLs requests from the log. |
| 212 wpr_server_args.extend(['--log_level', 'debug', | 212 wpr_server_args.extend(['--log_level', 'debug', |
| 213 '--log_file', PathWorkaround(out_log_path)]) | 213 '--log_file', PathWorkaround(out_log_path)]) |
| 214 # Don't append to previously existing log. | 214 # Don't append to previously existing log. |
| 215 if os.path.exists(out_log_path): | 215 if os.path.exists(out_log_path): |
| 216 os.remove(out_log_path) | 216 os.remove(out_log_path) |
| 217 | 217 |
| 218 # Set up WPR server and device forwarder. | 218 # Set up WPR server and device forwarder. |
| 219 wpr_server = webpagereplay.ReplayServer(PathWorkaround(wpr_archive_path), | 219 server = wpr_server.ReplayServer(PathWorkaround(wpr_archive_path), |
| 220 '127.0.0.1', 0, 0, None, wpr_server_args) | 220 '127.0.0.1', 0, 0, None, wpr_server_args) |
| 221 http_port, https_port = wpr_server.StartServer()[:-1] | 221 http_port, https_port = server.StartServer()[:-1] |
| 222 | 222 |
| 223 logging.info('WPR server listening on HTTP=%s, HTTPS=%s (options=%s)' % ( | 223 logging.info('WPR server listening on HTTP=%s, HTTPS=%s (options=%s)' % ( |
| 224 http_port, https_port, wpr_server_args)) | 224 http_port, https_port, wpr_server_args)) |
| 225 try: | 225 try: |
| 226 yield http_port, https_port | 226 yield http_port, https_port |
| 227 finally: | 227 finally: |
| 228 wpr_server.StopServer() | 228 server.StopServer() |
| 229 | 229 |
| 230 | 230 |
| 231 def _VerifySilentWprHost(record, network_condition_name): | 231 def _VerifySilentWprHost(record, network_condition_name): |
| 232 assert not record, 'WPR cannot record without a specified archive.' | 232 assert not record, 'WPR cannot record without a specified archive.' |
| 233 assert not network_condition_name, ('WPR cannot emulate network condition' + | 233 assert not network_condition_name, ('WPR cannot emulate network condition' + |
| 234 ' without a specified archive.') | 234 ' without a specified archive.') |
| 235 | 235 |
| 236 | 236 |
| 237 def _FormatWPRRelatedChromeArgumentFor(http_port, https_port, escape): | 237 def _FormatWPRRelatedChromeArgumentFor(http_port, https_port, escape): |
| 238 HOST_RULES='MAP * 127.0.0.1,EXCLUDE localhost' | 238 HOST_RULES='MAP * 127.0.0.1,EXCLUDE localhost' |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 # speed index measurement. | 429 # speed index measurement. |
| 430 connection.ExecuteJavaScript(""" | 430 connection.ExecuteJavaScript(""" |
| 431 (function() { | 431 (function() { |
| 432 requestAnimationFrame(function() { | 432 requestAnimationFrame(function() { |
| 433 var screen = window.__speedindex_screen; | 433 var screen = window.__speedindex_screen; |
| 434 screen.style.background = 'rgb(255, 255, 255)'; | 434 screen.style.background = 'rgb(255, 255, 255)'; |
| 435 }); | 435 }); |
| 436 })(); | 436 })(); |
| 437 """) | 437 """) |
| 438 yield | 438 yield |
| OLD | NEW |