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

Unified Diff: tools/telemetry/telemetry/internal/forwarders/__init__.py

Issue 1491183003: [Telemetry] Move WPR life cycle from browser to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: work in progress Created 4 years, 11 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/telemetry/telemetry/internal/forwarders/__init__.py
diff --git a/tools/telemetry/telemetry/internal/forwarders/__init__.py b/tools/telemetry/telemetry/internal/forwarders/__init__.py
index e05fb3b558b10e38be479bc4d25c90933a8df000..ecaa4a5410e87b9ed88fb8a67716d649f9119d82 100644
--- a/tools/telemetry/telemetry/internal/forwarders/__init__.py
+++ b/tools/telemetry/telemetry/internal/forwarders/__init__.py
@@ -6,7 +6,27 @@ import collections
PortPair = collections.namedtuple('PortPair', ['local_port', 'remote_port'])
-PortPairs = collections.namedtuple('PortPairs', ['http', 'https', 'dns'])
+PortSet = collections.namedtuple('PortSet', ['http', 'https', 'dns'])
+
+
+class PortPairs(collections.namedtuple('PortPairs', ['http', 'https', 'dns'])):
+ __slots__ = ()
+
+ @classmethod
+ def Make(cls, http, https, dns=None):
+ """Allow to easily create a PortPairs object from regular tuple pairs."""
+ return cls(http=PortPair(*http), https=PortPair(*https),
+ dns=PortPair(*dns) if dns else None)
+
+ @property
+ def local_ports(self):
+ ports = [pair.local_port if pair is not None else None for pair in self]
+ return PortSet(*ports)
+
+ @property
+ def remote_ports(self):
+ ports = [pair.remote_port if pair is not None else None for pair in self]
+ return PortSet(*ports)
class ForwarderFactory(object):

Powered by Google App Engine
This is Rietveld 408576698