| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <stdint.h> | 5 #include <stdint.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (!base::LaunchProcess(python_command, base::LaunchOptions()).IsValid()) { | 50 if (!base::LaunchProcess(python_command, base::LaunchOptions()).IsValid()) { |
| 51 LOG(ERROR) << "Failed to launch test script " << sync_test_script_name; | 51 LOG(ERROR) << "Failed to launch test script " << sync_test_script_name; |
| 52 return false; | 52 return false; |
| 53 } | 53 } |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Gets a port value from the switch with name |switch_name| and writes it to | 57 // Gets a port value from the switch with name |switch_name| and writes it to |
| 58 // |port|. Returns true if a port was provided and false otherwise. | 58 // |port|. Returns true if a port was provided and false otherwise. |
| 59 static bool GetPortFromSwitch(const std::string& switch_name, uint16_t* port) { | 59 static bool GetPortFromSwitch(const std::string& switch_name, uint16_t* port) { |
| 60 DCHECK(port != NULL) << "|port| is NULL"; | 60 DCHECK(port != nullptr) << "|port| is null"; |
| 61 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 61 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 62 int port_int = 0; | 62 int port_int = 0; |
| 63 if (command_line->HasSwitch(switch_name)) { | 63 if (command_line->HasSwitch(switch_name)) { |
| 64 std::string port_str = command_line->GetSwitchValueASCII(switch_name); | 64 std::string port_str = command_line->GetSwitchValueASCII(switch_name); |
| 65 if (!base::StringToInt(port_str, &port_int)) { | 65 if (!base::StringToInt(port_str, &port_int)) { |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 *port = static_cast<uint16_t>(port_int); | 69 *port = static_cast<uint16_t>(port_int); |
| 70 return true; | 70 return true; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 printf("Error: failed to start python sync test server. Exiting.\n"); | 113 printf("Error: failed to start python sync test server. Exiting.\n"); |
| 114 return -1; | 114 return -1; |
| 115 } | 115 } |
| 116 | 116 |
| 117 printf("Python sync test server running at %s (type ctrl+c to exit)\n", | 117 printf("Python sync test server running at %s (type ctrl+c to exit)\n", |
| 118 test_server->host_port_pair().ToString().c_str()); | 118 test_server->host_port_pair().ToString().c_str()); |
| 119 | 119 |
| 120 base::RunLoop().Run(); | 120 base::RunLoop().Run(); |
| 121 return 0; | 121 return 0; |
| 122 } | 122 } |
| OLD | NEW |