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/spawned_test_server/spawner_communicator.h" | 5 #include "net/test/spawned_test_server/spawner_communicator.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return false; | 335 return false; |
336 | 336 |
337 // Check whether the data returned from spawner server is JSON-formatted. | 337 // Check whether the data returned from spawner server is JSON-formatted. |
338 scoped_ptr<base::Value> value(base::JSONReader::Read(server_return_data)); | 338 scoped_ptr<base::Value> value(base::JSONReader::Read(server_return_data)); |
339 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) { | 339 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) { |
340 LOG(ERROR) << "Invalid server data: " << server_return_data.c_str(); | 340 LOG(ERROR) << "Invalid server data: " << server_return_data.c_str(); |
341 return false; | 341 return false; |
342 } | 342 } |
343 | 343 |
344 // Check whether spawner server returns valid data. | 344 // Check whether spawner server returns valid data. |
345 DictionaryValue* server_data = static_cast<DictionaryValue*>(value.get()); | 345 base::DictionaryValue* server_data = |
| 346 static_cast<base::DictionaryValue*>(value.get()); |
346 std::string message; | 347 std::string message; |
347 if (!server_data->GetString("message", &message) || message != "started") { | 348 if (!server_data->GetString("message", &message) || message != "started") { |
348 LOG(ERROR) << "Invalid message in server data: "; | 349 LOG(ERROR) << "Invalid message in server data: "; |
349 return false; | 350 return false; |
350 } | 351 } |
351 int int_port; | 352 int int_port; |
352 if (!server_data->GetInteger("port", &int_port) || int_port <= 0 || | 353 if (!server_data->GetInteger("port", &int_port) || int_port <= 0 || |
353 int_port > kuint16max) { | 354 int_port > kuint16max) { |
354 LOG(ERROR) << "Invalid port value: " << int_port; | 355 LOG(ERROR) << "Invalid port value: " << int_port; |
355 return false; | 356 return false; |
(...skipping 13 matching lines...) Expand all Loading... |
369 std::string server_return_data; | 370 std::string server_return_data; |
370 int result_code; | 371 int result_code; |
371 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); | 372 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); |
372 Shutdown(); | 373 Shutdown(); |
373 if (OK != result_code || server_return_data != "killed") | 374 if (OK != result_code || server_return_data != "killed") |
374 return false; | 375 return false; |
375 return true; | 376 return true; |
376 } | 377 } |
377 | 378 |
378 } // namespace net | 379 } // namespace net |
OLD | NEW |