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

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/cros_browser_backend.py

Issue 10984018: [chrome_remote_control] Add pylint to PRESUMMIT and fix lint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for landing Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 import json
5 import logging 4 import logging
6 import shutil
7 import socket 5 import socket
8 import subprocess 6 import subprocess
9 import tempfile
10 import time 7 import time
11 import urllib2
12 8
13 import adb_commands 9 from chrome_remote_control import browser_backend
14 import browser_backend 10 from chrome_remote_control import cros_interface
15 import browser_finder
16 import cros_interface
17 import inspector_backend
18
19 def ConstructDefaultArgsFromTheSessionManager(self, cri):
20 # TODO(nduca): Fill this in with something
21 pass
22 11
23 class CrOSBrowserBackend(browser_backend.BrowserBackend): 12 class CrOSBrowserBackend(browser_backend.BrowserBackend):
24 """The backend for controlling a browser instance running on CrOS. 13 """The backend for controlling a browser instance running on CrOS.
25 """ 14 """
26 def __init__(self, browser_type, options, is_content_shell, cri): 15 def __init__(self, browser_type, options, is_content_shell, cri):
27 super(CrOSBrowserBackend, self).__init__(is_content_shell) 16 super(CrOSBrowserBackend, self).__init__(is_content_shell)
28 # Initialize fields so that an explosion during init doesn't break in Close. 17 # Initialize fields so that an explosion during init doesn't break in Close.
29 self._options = options 18 self._options = options
30 assert not is_content_shell 19 assert not is_content_shell
31 self._cri = cri 20 self._cri = cri
21 self._browser_type = browser_type
32 22
33 tmp = socket.socket() 23 tmp = socket.socket()
34 tmp.bind(('', 0)) 24 tmp.bind(('', 0))
35 self._port = tmp.getsockname()[1] 25 self._port = tmp.getsockname()[1]
36 tmp.close() 26 tmp.close()
37 27
38 self._tmpdir = None 28 self._tmpdir = None
39 29
40 self._X = None 30 self._X = None
41 self._proc = None 31 self._proc = None
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return SSHReverseForwarder(self._cri, host_port) 132 return SSHReverseForwarder(self._cri, host_port)
143 133
144 class SSHReverseForwarder(object): 134 class SSHReverseForwarder(object):
145 def __init__(self, cri, host_port): 135 def __init__(self, cri, host_port):
146 self._proc = None 136 self._proc = None
147 137
148 # TODO(nduca): Try to pick a remote port that is free in a smater way. This 138 # TODO(nduca): Try to pick a remote port that is free in a smater way. This
149 # is idiotic. 139 # is idiotic.
150 self._remote_port = cri.GetRemotePort() 140 self._remote_port = cri.GetRemotePort()
151 self._proc = subprocess.Popen( 141 self._proc = subprocess.Popen(
152 cri._FormSSHCommandLine(['sleep', '99999999999'], 142 cri.FormSSHCommandLine(['sleep', '99999999999'],
153 ['-R%i:localhost:%i' % 143 ['-R%i:localhost:%i' %
154 (self._remote_port, host_port)]), 144 (self._remote_port, host_port)]),
155 stdout=subprocess.PIPE, 145 stdout=subprocess.PIPE,
156 stderr=subprocess.PIPE, 146 stderr=subprocess.PIPE,
157 stdin=subprocess.PIPE, 147 stdin=subprocess.PIPE,
158 shell=False) 148 shell=False)
159 149
160 # TODO(nduca): How do we wait for the server to come up in a 150 # TODO(nduca): How do we wait for the server to come up in a
161 # robust way? 151 # robust way?
162 time.sleep(1.5) 152 time.sleep(1.5)
163 153
164 @property 154 @property
165 def url(self): 155 def url(self):
166 assert self._proc 156 assert self._proc
167 return 'http://localhost:%i' % self._remote_port 157 return 'http://localhost:%i' % self._remote_port
168 158
169 def Close(self): 159 def Close(self):
170 if self._proc: 160 if self._proc:
171 self._proc.kill() 161 self._proc.kill()
172 self._proc = None 162 self._proc = None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698