| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """This is a simple HTTP/FTP/SYNC/TCP/UDP/ server used for testing Chrome. | 6 """This is a simple HTTP/FTP/SYNC/TCP/UDP/ server used for testing Chrome. |
| 7 | 7 |
| 8 It supports several test URLs, as specified by the handlers in TestPageHandler. | 8 It supports several test URLs, as specified by the handlers in TestPageHandler. |
| 9 By default, it listens on an ephemeral port and sends the port number back to | 9 By default, it listens on an ephemeral port and sends the port number back to |
| 10 the originating process over a pipe. The originating process can specify an | 10 the originating process over a pipe. The originating process can specify an |
| (...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 self.wfile.write('\r\n') | 1400 self.wfile.write('\r\n') |
| 1401 | 1401 |
| 1402 | 1402 |
| 1403 class SyncPageHandler(BasePageHandler): | 1403 class SyncPageHandler(BasePageHandler): |
| 1404 """Handler for the main HTTP sync server.""" | 1404 """Handler for the main HTTP sync server.""" |
| 1405 | 1405 |
| 1406 def __init__(self, request, client_address, sync_http_server): | 1406 def __init__(self, request, client_address, sync_http_server): |
| 1407 get_handlers = [self.ChromiumSyncMigrationOpHandler, | 1407 get_handlers = [self.ChromiumSyncMigrationOpHandler, |
| 1408 self.ChromiumSyncTimeHandler, | 1408 self.ChromiumSyncTimeHandler, |
| 1409 self.ChromiumSyncBirthdayErrorOpHandler, | 1409 self.ChromiumSyncBirthdayErrorOpHandler, |
| 1410 self.ChromiumSyncTransientErrorOpHandler] | 1410 self.ChromiumSyncTransientErrorOpHandler, |
| 1411 self.ChromiumSyncSyncTabsOpHandler] |
| 1411 | 1412 |
| 1412 post_handlers = [self.ChromiumSyncCommandHandler, | 1413 post_handlers = [self.ChromiumSyncCommandHandler, |
| 1413 self.ChromiumSyncTimeHandler] | 1414 self.ChromiumSyncTimeHandler] |
| 1414 BasePageHandler.__init__(self, request, client_address, | 1415 BasePageHandler.__init__(self, request, client_address, |
| 1415 sync_http_server, [], get_handlers, | 1416 sync_http_server, [], get_handlers, |
| 1416 post_handlers, []) | 1417 post_handlers, []) |
| 1417 | 1418 |
| 1418 def ChromiumSyncTimeHandler(self): | 1419 def ChromiumSyncTimeHandler(self): |
| 1419 """Handle Chromium sync .../time requests. | 1420 """Handle Chromium sync .../time requests. |
| 1420 | 1421 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 if not self._ShouldHandleRequest(test_name): | 1489 if not self._ShouldHandleRequest(test_name): |
| 1489 return False | 1490 return False |
| 1490 result, raw_reply = self.server._sync_handler.HandleSetTransientError() | 1491 result, raw_reply = self.server._sync_handler.HandleSetTransientError() |
| 1491 self.send_response(result) | 1492 self.send_response(result) |
| 1492 self.send_header('Content-Type', 'text/html') | 1493 self.send_header('Content-Type', 'text/html') |
| 1493 self.send_header('Content-Length', len(raw_reply)) | 1494 self.send_header('Content-Length', len(raw_reply)) |
| 1494 self.end_headers() | 1495 self.end_headers() |
| 1495 self.wfile.write(raw_reply) | 1496 self.wfile.write(raw_reply) |
| 1496 return True; | 1497 return True; |
| 1497 | 1498 |
| 1499 def ChromiumSyncSyncTabsOpHandler(self): |
| 1500 test_name = "/chromiumsync/synctabs" |
| 1501 if not self._ShouldHandleRequest(test_name): |
| 1502 return False |
| 1503 result, raw_reply = self.server._sync_handler.HandleSetSyncTabs() |
| 1504 self.send_response(result) |
| 1505 self.send_header('Content-Type', 'text/html') |
| 1506 self.send_header('Content-Length', len(raw_reply)) |
| 1507 self.end_headers() |
| 1508 self.wfile.write(raw_reply) |
| 1509 return True; |
| 1510 |
| 1498 | 1511 |
| 1499 def MakeDataDir(): | 1512 def MakeDataDir(): |
| 1500 if options.data_dir: | 1513 if options.data_dir: |
| 1501 if not os.path.isdir(options.data_dir): | 1514 if not os.path.isdir(options.data_dir): |
| 1502 print 'specified data dir not found: ' + options.data_dir + ' exiting...' | 1515 print 'specified data dir not found: ' + options.data_dir + ' exiting...' |
| 1503 return None | 1516 return None |
| 1504 my_data_dir = options.data_dir | 1517 my_data_dir = options.data_dir |
| 1505 else: | 1518 else: |
| 1506 # Create the default path to our data dir, relative to the exe dir. | 1519 # Create the default path to our data dir, relative to the exe dir. |
| 1507 my_data_dir = os.path.dirname(sys.argv[0]) | 1520 my_data_dir = os.path.dirname(sys.argv[0]) |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1753 'random key if none is specified on the command ' | 1766 'random key if none is specified on the command ' |
| 1754 'line.') | 1767 'line.') |
| 1755 option_parser.add_option('', '--policy-user', default='user@example.com', | 1768 option_parser.add_option('', '--policy-user', default='user@example.com', |
| 1756 dest='policy_user', | 1769 dest='policy_user', |
| 1757 help='Specify the user name the server should ' | 1770 help='Specify the user name the server should ' |
| 1758 'report back to the client as the user owning the ' | 1771 'report back to the client as the user owning the ' |
| 1759 'token used for making the policy request.') | 1772 'token used for making the policy request.') |
| 1760 options, args = option_parser.parse_args() | 1773 options, args = option_parser.parse_args() |
| 1761 | 1774 |
| 1762 sys.exit(main(options, args)) | 1775 sys.exit(main(options, args)) |
| OLD | NEW |