OLD | NEW |
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 | 4 |
5 #include "net/test/remote_test_server.h" | 5 #include "net/test/remote_test_server.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 base::DictionaryValue arguments_dict; | 81 base::DictionaryValue arguments_dict; |
82 if (!GenerateArguments(&arguments_dict)) | 82 if (!GenerateArguments(&arguments_dict)) |
83 return false; | 83 return false; |
84 | 84 |
85 // Append the 'server-type' argument which is used by spawner server to | 85 // Append the 'server-type' argument which is used by spawner server to |
86 // pass right server type to Python test server. | 86 // pass right server type to Python test server. |
87 arguments_dict.SetString("server-type", GetServerTypeString(type())); | 87 arguments_dict.SetString("server-type", GetServerTypeString(type())); |
88 | 88 |
89 // Generate JSON-formatted argument string. | 89 // Generate JSON-formatted argument string. |
90 std::string arguments_string; | 90 std::string arguments_string; |
91 base::JSONWriter::Write(&arguments_dict, false, &arguments_string); | 91 base::JSONWriter::Write(&arguments_dict, &arguments_string); |
92 if (arguments_string.empty()) | 92 if (arguments_string.empty()) |
93 return false; | 93 return false; |
94 | 94 |
95 // Start the Python test server on the remote machine. | 95 // Start the Python test server on the remote machine. |
96 uint16 test_server_port; | 96 uint16 test_server_port; |
97 if (!spawner_communicator_->StartServer(arguments_string, | 97 if (!spawner_communicator_->StartServer(arguments_string, |
98 &test_server_port)) { | 98 &test_server_port)) { |
99 return false; | 99 return false; |
100 } | 100 } |
101 if (0 == test_server_port) | 101 if (0 == test_server_port) |
102 return false; | 102 return false; |
103 | 103 |
104 // Construct server data to initialize BaseTestServer::server_data_. | 104 // Construct server data to initialize BaseTestServer::server_data_. |
105 base::DictionaryValue server_data_dict; | 105 base::DictionaryValue server_data_dict; |
106 // At this point, the test server should be spawned on the host. Update the | 106 // At this point, the test server should be spawned on the host. Update the |
107 // local port to real port of Python test server, which will be forwarded to | 107 // local port to real port of Python test server, which will be forwarded to |
108 // the remote server. | 108 // the remote server. |
109 server_data_dict.SetInteger("port", test_server_port); | 109 server_data_dict.SetInteger("port", test_server_port); |
110 std::string server_data; | 110 std::string server_data; |
111 base::JSONWriter::Write(&server_data_dict, false, &server_data); | 111 base::JSONWriter::Write(&server_data_dict, &server_data); |
112 if (server_data.empty() || !ParseServerData(server_data)) { | 112 if (server_data.empty() || !ParseServerData(server_data)) { |
113 LOG(ERROR) << "Could not parse server_data: " << server_data; | 113 LOG(ERROR) << "Could not parse server_data: " << server_data; |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 return SetupWhenServerStarted(); | 117 return SetupWhenServerStarted(); |
118 } | 118 } |
119 | 119 |
120 bool RemoteTestServer::Stop() { | 120 bool RemoteTestServer::Stop() { |
121 CleanUpWhenStoppingServer(); | 121 CleanUpWhenStoppingServer(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 SetResourcePath(document_root, FilePath().AppendASCII("net") | 160 SetResourcePath(document_root, FilePath().AppendASCII("net") |
161 .AppendASCII("data") | 161 .AppendASCII("data") |
162 .AppendASCII("ssl") | 162 .AppendASCII("ssl") |
163 .AppendASCII("certificates")); | 163 .AppendASCII("certificates")); |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 } // namespace net | 167 } // namespace net |
168 | 168 |
OLD | NEW |