| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 | 1595 |
| 1596 def __init__(self, request, client_address, sync_http_server): | 1596 def __init__(self, request, client_address, sync_http_server): |
| 1597 get_handlers = [self.ChromiumSyncMigrationOpHandler, | 1597 get_handlers = [self.ChromiumSyncMigrationOpHandler, |
| 1598 self.ChromiumSyncTimeHandler, | 1598 self.ChromiumSyncTimeHandler, |
| 1599 self.ChromiumSyncDisableNotificationsOpHandler, | 1599 self.ChromiumSyncDisableNotificationsOpHandler, |
| 1600 self.ChromiumSyncEnableNotificationsOpHandler, | 1600 self.ChromiumSyncEnableNotificationsOpHandler, |
| 1601 self.ChromiumSyncSendNotificationOpHandler, | 1601 self.ChromiumSyncSendNotificationOpHandler, |
| 1602 self.ChromiumSyncBirthdayErrorOpHandler, | 1602 self.ChromiumSyncBirthdayErrorOpHandler, |
| 1603 self.ChromiumSyncTransientErrorOpHandler, | 1603 self.ChromiumSyncTransientErrorOpHandler, |
| 1604 self.ChromiumSyncSyncTabsOpHandler, | 1604 self.ChromiumSyncSyncTabsOpHandler, |
| 1605 self.ChromiumSyncCreateSyncedBookmarksOpHandler, |
| 1605 self.ChromiumSyncErrorOpHandler, | 1606 self.ChromiumSyncErrorOpHandler, |
| 1606 self.ChromiumSyncCredHandler] | 1607 self.ChromiumSyncCredHandler] |
| 1607 | 1608 |
| 1608 post_handlers = [self.ChromiumSyncCommandHandler, | 1609 post_handlers = [self.ChromiumSyncCommandHandler, |
| 1609 self.ChromiumSyncTimeHandler] | 1610 self.ChromiumSyncTimeHandler] |
| 1610 BasePageHandler.__init__(self, request, client_address, | 1611 BasePageHandler.__init__(self, request, client_address, |
| 1611 sync_http_server, [], get_handlers, [], | 1612 sync_http_server, [], get_handlers, [], |
| 1612 post_handlers, []) | 1613 post_handlers, []) |
| 1613 | 1614 |
| 1614 | 1615 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 if not self._ShouldHandleRequest(test_name): | 1797 if not self._ShouldHandleRequest(test_name): |
| 1797 return False | 1798 return False |
| 1798 result, raw_reply = self.server._sync_handler.HandleSetSyncTabs() | 1799 result, raw_reply = self.server._sync_handler.HandleSetSyncTabs() |
| 1799 self.send_response(result) | 1800 self.send_response(result) |
| 1800 self.send_header('Content-Type', 'text/html') | 1801 self.send_header('Content-Type', 'text/html') |
| 1801 self.send_header('Content-Length', len(raw_reply)) | 1802 self.send_header('Content-Length', len(raw_reply)) |
| 1802 self.end_headers() | 1803 self.end_headers() |
| 1803 self.wfile.write(raw_reply) | 1804 self.wfile.write(raw_reply) |
| 1804 return True; | 1805 return True; |
| 1805 | 1806 |
| 1807 def ChromiumSyncCreateSyncedBookmarksOpHandler(self): |
| 1808 test_name = "/chromiumsync/createsyncedbookmarks" |
| 1809 if not self._ShouldHandleRequest(test_name): |
| 1810 return False |
| 1811 result, raw_reply = self.server._sync_handler.HandleCreateSyncedBookmarks() |
| 1812 self.send_response(result) |
| 1813 self.send_header('Content-Type', 'text/html') |
| 1814 self.send_header('Content-Length', len(raw_reply)) |
| 1815 self.end_headers() |
| 1816 self.wfile.write(raw_reply) |
| 1817 return True; |
| 1818 |
| 1806 | 1819 |
| 1807 def MakeDataDir(): | 1820 def MakeDataDir(): |
| 1808 if options.data_dir: | 1821 if options.data_dir: |
| 1809 if not os.path.isdir(options.data_dir): | 1822 if not os.path.isdir(options.data_dir): |
| 1810 print 'specified data dir not found: ' + options.data_dir + ' exiting...' | 1823 print 'specified data dir not found: ' + options.data_dir + ' exiting...' |
| 1811 return None | 1824 return None |
| 1812 my_data_dir = options.data_dir | 1825 my_data_dir = options.data_dir |
| 1813 else: | 1826 else: |
| 1814 # Create the default path to our data dir, relative to the exe dir. | 1827 # Create the default path to our data dir, relative to the exe dir. |
| 1815 my_data_dir = os.path.dirname(sys.argv[0]) | 1828 my_data_dir = os.path.dirname(sys.argv[0]) |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 'report back to the client as the user owning the ' | 2085 'report back to the client as the user owning the ' |
| 2073 'token used for making the policy request.') | 2086 'token used for making the policy request.') |
| 2074 option_parser.add_option('', '--host', default='127.0.0.1', | 2087 option_parser.add_option('', '--host', default='127.0.0.1', |
| 2075 dest='host', | 2088 dest='host', |
| 2076 help='Hostname or IP upon which the server will ' | 2089 help='Hostname or IP upon which the server will ' |
| 2077 'listen. Client connections will also only be ' | 2090 'listen. Client connections will also only be ' |
| 2078 'allowed from this address.') | 2091 'allowed from this address.') |
| 2079 options, args = option_parser.parse_args() | 2092 options, args = option_parser.parse_args() |
| 2080 | 2093 |
| 2081 sys.exit(main(options, args)) | 2094 sys.exit(main(options, args)) |
| OLD | NEW |