Chromium Code Reviews| 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..1042498b86019cd78321ef1f6ee9fa6f123d8d27 100644 |
| --- a/chrome/test/automation/automation_json_requests.cc |
| +++ b/chrome/test/automation/automation_json_requests.cc |
| @@ -19,15 +19,14 @@ |
| #include "content/common/json_value_serializer.h" |
| namespace { |
| - |
| bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
| const DictionaryValue& request_dict, |
| DictionaryValue* reply_dict, |
| + int timeout_ms, |
| 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(); |
| base::Time before_sending = base::Time::Now(); |
| if (!SendAutomationJSONRequest( |
| sender, request, timeout_ms, &reply, &success)) { |
| @@ -78,6 +77,14 @@ bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
| return true; |
| } |
| +bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
| + const DictionaryValue& request_dict, |
| + DictionaryValue* reply_dict, |
| + std::string* error_msg) { |
| + int timeout_ms = TestTimeouts::action_max_timeout_ms(); |
|
kkania
2011/06/07 22:55:28
make this one call sender->Send(msg) instead of se
|
| + return SendAutomationJSONRequest(sender, request_dict, |
| + reply_dict, timeout_ms, error_msg); |
| +} |
| } // namespace |
| WebKeyEvent::WebKeyEvent(automation::KeyEventTypes type, |
| @@ -153,8 +160,10 @@ bool SendNavigateToURLJSONRequest( |
| dict.SetString("url", url.possibly_invalid_spec()); |
| dict.SetInteger("navigation_count", navigation_count); |
| DictionaryValue reply_dict; |
| - if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) |
| + if (!SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg)) { |
| return false; |
| + } |
| int response = 0; |
| if (!reply_dict.GetInteger("result", &response)) |
| return false; |
| @@ -177,8 +186,10 @@ bool SendExecuteJavascriptJSONRequest( |
| dict.SetString("frame_xpath", frame_xpath); |
| dict.SetString("javascript", javascript); |
| DictionaryValue reply_dict; |
| - if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) |
| + if (!SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg)) { |
| return false; |
| + } |
| std::string json; |
| if (!reply_dict.GetString("result", &json)) { |
| @@ -210,7 +221,8 @@ bool SendGoForwardJSONRequest( |
| dict.SetInteger("windex", browser_index); |
| dict.SetInteger("tab_index", tab_index); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
| } |
| bool SendGoBackJSONRequest( |
| @@ -223,7 +235,8 @@ bool SendGoBackJSONRequest( |
| dict.SetInteger("windex", browser_index); |
| dict.SetInteger("tab_index", tab_index); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
| } |
| bool SendReloadJSONRequest( |
| @@ -236,7 +249,8 @@ bool SendReloadJSONRequest( |
| dict.SetInteger("windex", browser_index); |
| dict.SetInteger("tab_index", tab_index); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
| } |
| bool SendCaptureEntirePageJSONRequest( |
| @@ -252,7 +266,8 @@ bool SendCaptureEntirePageJSONRequest( |
| dict.SetString("path", path.value()); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
| } |
| bool SendGetTabURLJSONRequest( |
| @@ -296,7 +311,8 @@ bool SendGetCookiesJSONRequest( |
| dict.SetString("command", "GetCookies"); |
| dict.SetString("url", url); |
| DictionaryValue reply_dict; |
| - if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) |
| + if (!SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg)) |
| return false; |
| Value* cookies_unscoped_value; |
| if (!reply_dict.Remove("cookies", &cookies_unscoped_value)) |
| @@ -319,8 +335,10 @@ bool SendGetCookiesJSONRequestDeprecated( |
| dict.SetString("url", url); |
| DictionaryValue reply_dict; |
| std::string error_msg; |
| - if (!SendAutomationJSONRequest(sender, dict, &reply_dict, &error_msg)) |
| + if (!SendAutomationJSONRequest(sender, dict, &reply_dict, |
|
kkania
2011/06/07 22:55:28
you can forget adding custom timeout to the deprec
|
| + base::kNoTimeout, &error_msg)) { |
| return false; |
| + } |
| return reply_dict.GetString("cookies", cookies); |
| } |
| @@ -334,7 +352,8 @@ bool SendDeleteCookieJSONRequest( |
| dict.SetString("url", url); |
| dict.SetString("name", cookie_name); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
| } |
| bool SendDeleteCookieJSONRequestDeprecated( |
| @@ -349,7 +368,8 @@ bool SendDeleteCookieJSONRequestDeprecated( |
| dict.SetString("name", cookie_name); |
| DictionaryValue reply_dict; |
| std::string error_msg; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, &error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, &error_msg); |
| } |
| bool SendSetCookieJSONRequest( |
| @@ -362,7 +382,8 @@ bool SendSetCookieJSONRequest( |
| dict.SetString("url", url); |
| dict.Set("cookie", cookie_dict->DeepCopy()); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
| } |
| bool SendSetCookieJSONRequestDeprecated( |
| @@ -377,7 +398,8 @@ bool SendSetCookieJSONRequestDeprecated( |
| dict.SetString("cookie", cookie); |
| DictionaryValue reply_dict; |
| std::string error_msg; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, &error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, &error_msg); |
| } |
| bool SendGetTabIdsJSONRequest( |
| @@ -587,8 +609,10 @@ bool SendGetAppModalDialogMessageJSONRequest( |
| DictionaryValue dict; |
| dict.SetString("command", "GetAppModalDialogMessage"); |
| DictionaryValue reply_dict; |
| - if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) |
| + if (!SendAutomationJSONRequest(sender, dict, &reply_dict, |
|
kkania
2011/06/07 22:55:28
I don't think need custom timeout here
|
| + base::kNoTimeout, error_msg)) { |
| return false; |
| + } |
| return reply_dict.GetString("message", message); |
| } |
| @@ -600,7 +624,8 @@ bool SendAcceptOrDismissAppModalDialogJSONRequest( |
| dict.SetString("command", "AcceptOrDismissAppModalDialog"); |
| dict.SetBoolean("accept", accept); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
|
kkania
2011/06/07 22:55:28
or here
|
| } |
| bool SendAcceptPromptAppModalDialogJSONRequest( |
| @@ -612,7 +637,8 @@ bool SendAcceptPromptAppModalDialogJSONRequest( |
| dict.SetBoolean("accept", true); |
| dict.SetString("prompt_text", prompt_text); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
|
kkania
2011/06/07 22:55:28
or here
|
| } |
| bool SendWaitForAllTabsToStopLoadingJSONRequest( |
| @@ -621,7 +647,8 @@ bool SendWaitForAllTabsToStopLoadingJSONRequest( |
| DictionaryValue dict; |
| dict.SetString("command", "WaitForAllTabsToStopLoading"); |
| DictionaryValue reply_dict; |
| - return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); |
| + return SendAutomationJSONRequest(sender, dict, &reply_dict, |
| + base::kNoTimeout, error_msg); |
| } |
| bool SendGetChromeDriverAutomationVersion( |