OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 from py_trace_event import trace_event | 5 from py_trace_event import trace_event |
6 | 6 |
7 | 7 |
8 class NetworkController(object): | 8 class NetworkController(object): |
9 """Control network settings and servers to simulate the Web. | 9 """Control network settings and servers to simulate the Web. |
10 | 10 |
11 Network changes include forwarding device ports to host platform ports. | 11 Network changes include forwarding device ports to host platform ports. |
12 Web Page Replay is used to record and replay HTTP/HTTPS responses. | 12 Web Page Replay is used to record and replay HTTP/HTTPS responses. |
13 """ | 13 """ |
14 | 14 |
15 __metaclass__ = trace_event.TracedMetaClass | 15 __metaclass__ = trace_event.TracedMetaClass |
16 | 16 |
17 def __init__(self, network_controller_backend): | 17 def __init__(self, network_controller_backend): |
18 self._network_controller_backend = network_controller_backend | 18 self._network_controller_backend = network_controller_backend |
19 | 19 |
20 def InitializeIfNeeded(self, use_live_traffic=False): | 20 def InitializeIfNeeded(self, use_live_traffic=False): |
21 self._network_controller_backend.InitializeIfNeeded(use_live_traffic) | 21 self._network_controller_backend.InitializeIfNeeded(use_live_traffic) |
22 | 22 |
23 def Open(self, wpr_mode, extra_wpr_args, use_wpr_go=False): | 23 def Open(self, wpr_mode, extra_wpr_args): |
24 self._network_controller_backend.Open(wpr_mode, extra_wpr_args, use_wpr_go) | 24 self._network_controller_backend.Open(wpr_mode, extra_wpr_args) |
25 | 25 |
26 def UpdateTrafficSettings(self, | 26 def UpdateTrafficSettings(self, |
27 round_trip_latency_ms=None, | 27 round_trip_latency_ms=None, |
28 download_bandwidth_kbps=None, | 28 download_bandwidth_kbps=None, |
29 upload_bandwidth_kbps=None): | 29 upload_bandwidth_kbps=None): |
30 self._network_controller_backend.ts_proxy_server.UpdateTrafficSettings( | 30 self._network_controller_backend.ts_proxy_server.UpdateTrafficSettings( |
31 round_trip_latency_ms, download_bandwidth_kbps, upload_bandwidth_kbps) | 31 round_trip_latency_ms, download_bandwidth_kbps, upload_bandwidth_kbps) |
32 | 32 |
33 @property | 33 @property |
34 def is_open(self): | 34 def is_open(self): |
35 return self._network_controller_backend.is_open | 35 return self._network_controller_backend.is_open |
36 | 36 |
37 def Close(self): | 37 def Close(self): |
38 self._network_controller_backend.Close() | 38 self._network_controller_backend.Close() |
39 | 39 |
40 def StartReplay(self, archive_path, make_javascript_deterministic=False): | 40 def StartReplay(self, archive_path, make_javascript_deterministic=False): |
41 self._network_controller_backend.StartReplay(archive_path, | 41 self._network_controller_backend.StartReplay(archive_path, |
42 make_javascript_deterministic) | 42 make_javascript_deterministic) |
43 | 43 |
44 def StopReplay(self): | 44 def StopReplay(self): |
45 self._network_controller_backend.StopReplay() | 45 self._network_controller_backend.StopReplay() |
OLD | NEW |