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

Side by Side Diff: chrome/test/automation/automation_json_requests.cc

Issue 9960077: Modify the base::JSONReader interface to take a set of options rather than a boolean flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 8 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
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 "chrome/test/automation/automation_json_requests.h" 5 #include "chrome/test/automation/automation_json_requests.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 28 matching lines...) Expand all
39 bool success = false; 39 bool success = false;
40 if (!SendAutomationJSONRequestWithDefaultTimeout( 40 if (!SendAutomationJSONRequestWithDefaultTimeout(
41 sender, request, &reply, &success)) { 41 sender, request, &reply, &success)) {
42 *error = Error(base::StringPrintf( 42 *error = Error(base::StringPrintf(
43 "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms.", 43 "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms.",
44 command.c_str(), 44 command.c_str(),
45 (base::Time::Now() - before_sending).InMilliseconds())); 45 (base::Time::Now() - before_sending).InMilliseconds()));
46 LOG(INFO) << error->message(); 46 LOG(INFO) << error->message();
47 return false; 47 return false;
48 } 48 }
49 scoped_ptr<Value> value(base::JSONReader::Read(reply, true)); 49 scoped_ptr<Value> value(
50 base::JSONReader::Read(reply, base::JSON_ALLOW_TRAILING_COMMAS));
50 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { 51 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
51 *error = Error("JSON request did not return a dictionary"); 52 *error = Error("JSON request did not return a dictionary");
52 LOG(ERROR) << "JSON request did not return dict: " << command << "\n"; 53 LOG(ERROR) << "JSON request did not return dict: " << command << "\n";
53 return false; 54 return false;
54 } 55 }
55 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 56 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
56 if (!success) { 57 if (!success) {
57 std::string error_msg; 58 std::string error_msg;
58 dict->GetString("error", &error_msg); 59 dict->GetString("error", &error_msg);
59 int int_code = automation::kUnknownError; 60 int int_code = automation::kUnknownError;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 Error* error) { 894 Error* error) {
894 DictionaryValue dict; 895 DictionaryValue dict;
895 dict.SetString("command", "SetPrefs"); 896 dict.SetString("command", "SetPrefs");
896 // TODO(kkania): Set correct auto_id instead of hardcoding windex. 897 // TODO(kkania): Set correct auto_id instead of hardcoding windex.
897 dict.SetInteger("windex", 0); 898 dict.SetInteger("windex", 0);
898 dict.SetString("path", pref); 899 dict.SetString("path", pref);
899 dict.Set("value", value); 900 dict.Set("value", value);
900 DictionaryValue reply_dict; 901 DictionaryValue reply_dict;
901 return SendAutomationJSONRequest(sender, dict, &reply_dict, error); 902 return SendAutomationJSONRequest(sender, dict, &reply_dict, error);
902 } 903 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698