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): | 23 def Open(self, wpr_mode, extra_wpr_args): |
24 self._network_controller_backend.Open(wpr_mode, extra_wpr_args) | 24 self._network_controller_backend.Open(wpr_mode, extra_wpr_args) |
25 | 25 |
26 def UpdateTrafficSettings(self, round_trip_latency_ms=None, | 26 def UpdateTrafficSettings(self, round_trip_latency_ms=None, \ |
27 download_bandwidth_kbps=None, upload_bandwidth_kbps=None): | 27 download_bandwidth_kbps=None, upload_bandwidth_kbps=None): |
28 self._network_controller_backend.ts_proxy_server.UpdateTrafficSettings( | 28 self._network_controller_backend.ts_proxy_server.UpdateTrafficSettings(\ |
29 round_trip_latency_ms, download_bandwidth_kbps, upload_bandwidth_kbps) | 29 round_trip_latency_ms, download_bandwidth_kbps, upload_bandwidth_kbps) |
30 | 30 |
31 @property | 31 @property |
32 def is_open(self): | 32 def is_open(self): |
33 return self._network_controller_backend.is_open | 33 return self._network_controller_backend.is_open |
34 | 34 |
35 def Close(self): | 35 def Close(self): |
36 self._network_controller_backend.Close() | 36 self._network_controller_backend.Close() |
37 | 37 |
38 def StartReplay(self, archive_path, make_javascript_deterministic=False): | 38 def StartReplay(self, archive_path, make_javascript_deterministic=False): |
39 self._network_controller_backend.StartReplay( | 39 self._network_controller_backend.StartReplay( |
40 archive_path, make_javascript_deterministic) | 40 archive_path, make_javascript_deterministic) |
41 | 41 |
42 def StopReplay(self): | 42 def StopReplay(self): |
43 self._network_controller_backend.StopReplay() | 43 self._network_controller_backend.StopReplay() |
OLD | NEW |