Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: tools/android/loading/device_setup.py

Issue 1707363002: sandwich: Implements network condition on WPR server and browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@i00
Patch Set: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/android/loading/device_setup.py
diff --git a/tools/android/loading/device_setup.py b/tools/android/loading/device_setup.py
index 0fe95fd80d357944dd6ac6ae4c8c5b425a2080c0..62b99b46239b4f2d09d6c8c7e9af8fcc94c139b9 100644
--- a/tools/android/loading/device_setup.py
+++ b/tools/android/loading/device_setup.py
@@ -105,12 +105,15 @@ def _SetUpDevice(device, package_info):
@contextlib.contextmanager
def WprHost(device, wpr_archive_path, record=False,
+ network_condition_name=None,
disable_script_injection=False):
"""Launches web page replay host.
Args:
device: Android device.
wpr_archive_path: host sided WPR archive's path.
+ network_condition_name: Network condition name available in
Benoit L 2016/02/22 14:11:25 tiny nit: the ordering of arguments should match t
+ chrome_setup.NETWORK_CONDITIONS.
record: Enables or disables WPR archive recording.
Returns:
@@ -119,6 +122,9 @@ def WprHost(device, wpr_archive_path, record=False,
"""
assert device
if wpr_archive_path == None:
+ assert not record, 'WPR cannot record without a specified archive.'
+ assert not network_condition_name, ('WPR cannot emulate network condition' +
+ ' without a specified archive.')
yield []
return
@@ -129,6 +135,16 @@ def WprHost(device, wpr_archive_path, record=False,
os.remove(wpr_archive_path)
else:
assert os.path.exists(wpr_archive_path)
+ if network_condition_name:
+ condition = chrome_setup.NETWORK_CONDITIONS[network_condition_name]
+ if record:
+ logging.warning('WPR network condition is ignored when recording.')
+ else:
+ wpr_server_args.extend([
+ '--down', chrome_setup.BandwidthToString(condition['download']),
+ '--up', chrome_setup.BandwidthToString(condition['upload']),
+ '--delay_ms', str(condition['latency']),
+ '--shaping_type', 'proxy'])
if disable_script_injection:
# Remove default WPR injected scripts like deterministic.js which

Powered by Google App Engine
This is Rietveld 408576698