OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 | 4 |
5 import os | 5 import os |
6 | 6 |
7 from telemetry import decorators | 7 from telemetry import decorators |
8 from telemetry.core import app | 8 from telemetry.core import app |
9 from telemetry.core import browser_credentials | 9 from telemetry.core import browser_credentials |
10 from telemetry.core import exceptions | 10 from telemetry.core import exceptions |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 """Closes this browser.""" | 215 """Closes this browser.""" |
216 if self._browser_backend.IsBrowserRunning(): | 216 if self._browser_backend.IsBrowserRunning(): |
217 self._platform_backend.WillCloseBrowser(self, self._browser_backend) | 217 self._platform_backend.WillCloseBrowser(self, self._browser_backend) |
218 | 218 |
219 self._local_server_controller.Close() | 219 self._local_server_controller.Close() |
220 self._browser_backend.Close() | 220 self._browser_backend.Close() |
221 self.credentials = None | 221 self.credentials = None |
222 | 222 |
223 @property | 223 @property |
224 def http_server(self): | 224 def http_server(self): |
225 return self._local_server_controller.GetRunningServer( | 225 return self.GetRunningLocalServer( |
226 memory_cache_http_server.MemoryCacheHTTPServer, None) | 226 memory_cache_http_server.MemoryCacheHTTPServer, None) |
227 | 227 |
228 def SetHTTPServerDirectories(self, paths): | 228 def SetHTTPServerDirectories(self, paths): |
229 """Returns True if the HTTP server was started, False otherwise.""" | 229 """Returns True if the HTTP server was started, False otherwise.""" |
230 if isinstance(paths, basestring): | 230 if isinstance(paths, basestring): |
231 paths = set([paths]) | 231 paths = set([paths]) |
232 paths = set(os.path.realpath(p) for p in paths) | 232 paths = set(os.path.realpath(p) for p in paths) |
233 | 233 |
234 # If any path is in a subdirectory of another, remove the subdirectory. | 234 # If any path is in a subdirectory of another, remove the subdirectory. |
235 duplicates = set() | 235 duplicates = set() |
(...skipping 11 matching lines...) Expand all Loading... |
247 | 247 |
248 self.http_server.Close() | 248 self.http_server.Close() |
249 | 249 |
250 if not paths: | 250 if not paths: |
251 return False | 251 return False |
252 | 252 |
253 server = memory_cache_http_server.MemoryCacheHTTPServer(paths) | 253 server = memory_cache_http_server.MemoryCacheHTTPServer(paths) |
254 self.StartLocalServer(server) | 254 self.StartLocalServer(server) |
255 return True | 255 return True |
256 | 256 |
| 257 def GetRunningLocalServer(self, server_class, default_value): |
| 258 """Get a LocalServer of class |server_class| already running.""" |
| 259 return self._local_server_controller.GetRunningServer( |
| 260 server_class, default_value) |
| 261 |
257 def StartLocalServer(self, server): | 262 def StartLocalServer(self, server): |
258 """Starts a LocalServer and associates it with this browser. | 263 """Starts a LocalServer and associates it with this browser. |
259 | 264 |
260 It will be closed when the browser closes. | 265 It will be closed when the browser closes. |
261 """ | 266 """ |
262 self._local_server_controller.StartServer(server) | 267 self._local_server_controller.StartServer(server) |
263 | 268 |
264 @property | 269 @property |
265 def local_servers(self): | 270 def local_servers(self): |
266 """Returns the currently running local servers.""" | 271 """Returns the currently running local servers.""" |
267 return self._local_server_controller.local_servers | 272 return self._local_server_controller.local_servers |
268 | 273 |
269 def GetStandardOutput(self): | 274 def GetStandardOutput(self): |
270 return self._browser_backend.GetStandardOutput() | 275 return self._browser_backend.GetStandardOutput() |
271 | 276 |
272 def GetStackTrace(self): | 277 def GetStackTrace(self): |
273 return self._browser_backend.GetStackTrace() | 278 return self._browser_backend.GetStackTrace() |
274 | 279 |
275 @property | 280 @property |
276 def supports_system_info(self): | 281 def supports_system_info(self): |
277 return self._browser_backend.supports_system_info | 282 return self._browser_backend.supports_system_info |
278 | 283 |
279 def GetSystemInfo(self): | 284 def GetSystemInfo(self): |
280 """Returns low-level information about the system, if available. | 285 """Returns low-level information about the system, if available. |
281 | 286 |
282 See the documentation of the SystemInfo class for more details.""" | 287 See the documentation of the SystemInfo class for more details.""" |
283 return self._browser_backend.GetSystemInfo() | 288 return self._browser_backend.GetSystemInfo() |
OLD | NEW |