Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: net/test/spawner_communicator.cc

Issue 10035042: Rewrite base::JSONReader to be 35-40% faster, depending on the input string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix Windows, address comments Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/test/base_test_server.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/spawner_communicator.h" 5 #include "net/test/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/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/supports_user_data.h" 10 #include "base/supports_user_data.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // Send the start command to spawner server to start the Python test server 314 // Send the start command to spawner server to start the Python test server
315 // on remote machine. 315 // on remote machine.
316 std::string server_return_data; 316 std::string server_return_data;
317 int result_code; 317 int result_code;
318 SendCommandAndWaitForResult("start", arguments, &result_code, 318 SendCommandAndWaitForResult("start", arguments, &result_code,
319 &server_return_data); 319 &server_return_data);
320 if (OK != result_code || server_return_data.empty()) 320 if (OK != result_code || server_return_data.empty())
321 return false; 321 return false;
322 322
323 // Check whether the data returned from spawner server is JSON-formatted. 323 // Check whether the data returned from spawner server is JSON-formatted.
324 base::JSONReader json_reader; 324 scoped_ptr<base::Value> value(base::JSONReader::Read(server_return_data));
325 scoped_ptr<base::Value> value(json_reader.JsonToValue(server_return_data,
326 true, false));
327 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) { 325 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) {
328 LOG(ERROR) << "Invalid server data: " << server_return_data.c_str(); 326 LOG(ERROR) << "Invalid server data: " << server_return_data.c_str();
329 return false; 327 return false;
330 } 328 }
331 329
332 // Check whether spawner server returns valid data. 330 // Check whether spawner server returns valid data.
333 DictionaryValue* server_data = static_cast<DictionaryValue*>(value.get()); 331 DictionaryValue* server_data = static_cast<DictionaryValue*>(value.get());
334 std::string message; 332 std::string message;
335 if (!server_data->GetString("message", &message) || message != "started") { 333 if (!server_data->GetString("message", &message) || message != "started") {
336 LOG(ERROR) << "Invalid message in server data: "; 334 LOG(ERROR) << "Invalid message in server data: ";
(...skipping 20 matching lines...) Expand all
357 std::string server_return_data; 355 std::string server_return_data;
358 int result_code; 356 int result_code;
359 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); 357 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data);
360 if (OK != result_code || server_return_data != "killed") 358 if (OK != result_code || server_return_data != "killed")
361 return false; 359 return false;
362 Shutdown(); 360 Shutdown();
363 return true; 361 return true;
364 } 362 }
365 363
366 } // namespace net 364 } // namespace net
OLDNEW
« no previous file with comments | « net/test/base_test_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698