1# Copyright 2023 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from __future__ import annotations 6 7import contextlib 8from typing import TYPE_CHECKING, Iterator 9 10from crossbench.network.base import Network 11 12if TYPE_CHECKING: 13 from crossbench.runner.groups.session import BrowserSessionRunGroup 14 15 16 17class LiveNetwork(Network): 18 19 @property 20 def is_live(self) -> bool: 21 return True 22 23 @contextlib.contextmanager 24 def open(self, session: BrowserSessionRunGroup) -> Iterator[Network]: 25 with super().open(session): 26 with self._traffic_shaper.open(self, session): 27 # TODO: implement 28 yield self 29 30 def __str__(self) -> str: 31 return f"LIVE(speed={self.traffic_shaper})" 32