• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3# found in the LICENSE file.
4
5import logging
6import socket
7
8from telemetry.core import forwarders
9from telemetry.core import util
10
11
12class DoNothingForwarderFactory(forwarders.ForwarderFactory):
13
14  def Create(self, port_pairs):
15    return DoNothingForwarder(port_pairs)
16
17
18class DoNothingForwarder(forwarders.Forwarder):
19
20  def __init__(self, port_pairs):
21    super(DoNothingForwarder, self).__init__(port_pairs)
22
23    for port_pair in port_pairs:
24      if not port_pair:
25        continue
26      local_port, remote_port = port_pair
27      assert local_port == remote_port, 'Local port forwarding is not supported'
28      def IsStarted():
29        return not socket.socket().connect_ex((self.host_ip, self.host_port))
30      util.WaitFor(IsStarted, 10)
31      logging.debug('Server started on %s:%d' % (self.host_ip, self.host_port))
32