Chromium Code Reviews| Index: net/test/test_server.cc |
| diff --git a/net/test/test_server.cc b/net/test/test_server.cc |
| index 0e8c4611e4e0a3c4e16924abf0b4f0b9a9f5ff4f..245be232c739905c05f4b7adbf306d1323078efe 100644 |
| --- a/net/test/test_server.cc |
| +++ b/net/test/test_server.cc |
| @@ -17,11 +17,14 @@ |
| #include "base/base64.h" |
| #include "base/command_line.h" |
| #include "base/debug/leak_annotations.h" |
| +#include "base/json/json_reader.h" |
| #include "base/file_util.h" |
| #include "base/logging.h" |
| #include "base/path_service.h" |
| +#include "base/scoped_ptr.h" |
| #include "base/string_number_conversions.h" |
| #include "base/utf_string_conversions.h" |
| +#include "base/values.h" |
| #include "googleurl/src/gurl.h" |
| #include "net/base/cert_test_util.h" |
| #include "net/base/host_port_pair.h" |
| @@ -278,6 +281,9 @@ bool TestServer::SetPythonPath() { |
| } |
| third_party_dir = third_party_dir.Append(FILE_PATH_LITERAL("third_party")); |
| + // For simplejson. |
| + AppendToPythonPath(third_party_dir); |
|
cbentzel
2010/11/17 22:32:50
This should be third_party_dir.Append(FILE_PATH_LI
akalin
2010/11/17 23:21:35
It should not -- the 'simplejson' directory, unlik
cbentzel
2010/11/18 01:47:19
Thanks. Could you expand the "For simplejson" comm
|
| + |
| AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("tlslite"))); |
| AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("pyftpdlib"))); |
| @@ -373,4 +379,25 @@ bool TestServer::AddCommandLineArguments(CommandLine* command_line) const { |
| return true; |
| } |
| +bool TestServer::ParseServerData(const std::string& server_data) { |
|
cbentzel
2010/11/17 22:32:50
Should this be non-mutating static and have an out
akalin
2010/11/17 23:21:35
Hmm, in a future CL, the dict value is stashed in
|
| + VLOG(1) << "Server data: " << server_data; |
| + base::JSONReader json_reader; |
| + scoped_ptr<Value> value(json_reader.JsonToValue(server_data, true, true)); |
|
cbentzel
2010/11/17 22:32:50
Why is "allow trailing comma" needed - the parser
akalin
2010/11/17 23:21:35
Done.
|
| + if (!value.get() || |
| + !value->IsType(Value::TYPE_DICTIONARY)) { |
| + LOG(ERROR) << "Could not parse server data: " |
| + << json_reader.GetErrorMessage(); |
| + return false; |
| + } |
| + DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
| + int port = 0; |
| + if (!dict->GetInteger("port", &port) || |
|
cbentzel
2010/11/17 22:32:50
I thought you were working on multiple ports? Or i
akalin
2010/11/17 23:21:35
Yeah, it'll be in a separate CL (i'll send it to y
|
| + (port <= 0) || (port >= kuint16max)) { |
|
cbentzel
2010/11/17 22:32:50
I'd prefer splitting this into two different condi
akalin
2010/11/17 23:21:35
Done.
|
| + LOG(ERROR) << "Could not find valid port value"; |
| + return false; |
| + } |
| + host_port_pair_.set_port(port); |
| + return true; |
| +} |
| + |
| } // namespace net |