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

Unified Diff: chrome/test/automation/automation_json_requests.cc

Issue 7139001: In chromedriver, add /log url (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/automation/automation_json_requests.h ('k') | chrome/test/webdriver/automation.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/automation/automation_json_requests.cc
diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc
index c05770b023341dc81068215efe1f080aa0522064..a6c01fac498f34601dd5209ead263dd733c45235 100644
--- a/chrome/test/automation/automation_json_requests.cc
+++ b/chrome/test/automation/automation_json_requests.cc
@@ -26,44 +26,30 @@ bool SendAutomationJSONRequest(AutomationMessageSender* sender,
std::string* error_msg) {
std::string request, reply;
base::JSONWriter::Write(&request_dict, false, &request);
- bool success = false;
- int timeout_ms = TestTimeouts::action_max_timeout_ms();
+ std::string command;
+ request_dict.GetString("command", &command);
+ LOG(INFO) << "Sending '" << command << "' command.";
+
base::Time before_sending = base::Time::Now();
- if (!SendAutomationJSONRequest(
- sender, request, timeout_ms, &reply, &success)) {
- int64 elapsed_ms = (base::Time::Now() - before_sending).InMilliseconds();
- std::string command;
- request_dict.GetString("command", &command);
- if (elapsed_ms >= timeout_ms) {
- *error_msg = base::StringPrintf(
- "Chrome did not respond to '%s'. Request may have timed out. "
- "Elapsed time was %" PRId64 " ms. Request timeout was %d ms. "
- "Request details: (%s).",
- command.c_str(),
- elapsed_ms,
- timeout_ms,
- request.c_str());
- } else {
- *error_msg = base::StringPrintf(
- "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms. "
- "Request details: (%s).",
- command.c_str(),
- elapsed_ms,
- request.c_str());
- }
+ bool success = false;
+ if (!SendAutomationJSONRequestWithDefaultTimeout(
+ sender, request, &reply, &success)) {
+ *error_msg = base::StringPrintf(
+ "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms. "
+ "Request details: (%s).",
+ command.c_str(),
+ (base::Time::Now() - before_sending).InMilliseconds(),
+ request.c_str());
return false;
}
scoped_ptr<Value> value(base::JSONReader::Read(reply, true));
if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
- std::string command;
- request_dict.GetString("command", &command);
LOG(ERROR) << "JSON request did not return dict: " << command << "\n";
return false;
}
DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
if (!success) {
- std::string command, error;
- request_dict.GetString("command", &command);
+ std::string error;
dict->GetString("error", &error);
*error_msg = base::StringPrintf(
"Internal Chrome error during '%s': (%s). Request details: (%s).",
@@ -100,6 +86,15 @@ bool SendAutomationJSONRequest(AutomationMessageSender* sender,
-1, request, reply, success), timeout_ms);
}
+bool SendAutomationJSONRequestWithDefaultTimeout(
+ AutomationMessageSender* sender,
+ const std::string& request,
+ std::string* reply,
+ bool* success) {
+ return sender->Send(new AutomationMsg_SendJSONRequest(
+ -1, request, reply, success));
+}
+
bool SendGetIndicesFromTabIdJSONRequest(
AutomationMessageSender* sender,
int tab_id,
« no previous file with comments | « chrome/test/automation/automation_json_requests.h ('k') | chrome/test/webdriver/automation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698