| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_proxy.h" | 5 #include "chrome/test/automation/browser_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/test/test_timeouts.h" |
| 11 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
| 12 #include "base/time.h" | 13 #include "base/time.h" |
| 13 #include "chrome/common/automation_constants.h" | 14 #include "chrome/common/automation_constants.h" |
| 14 #include "chrome/common/automation_messages.h" | 15 #include "chrome/common/automation_messages.h" |
| 15 #include "chrome/test/automation/autocomplete_edit_proxy.h" | 16 #include "chrome/test/automation/autocomplete_edit_proxy.h" |
| 16 #include "chrome/test/automation/automation_proxy.h" | 17 #include "chrome/test/automation/automation_proxy.h" |
| 17 #include "chrome/test/automation/tab_proxy.h" | 18 #include "chrome/test/automation/tab_proxy.h" |
| 18 #include "chrome/test/automation/window_proxy.h" | 19 #include "chrome/test/automation/window_proxy.h" |
| 19 #include "ui/gfx/point.h" | 20 #include "ui/gfx/point.h" |
| 20 | 21 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 return false; | 571 return false; |
| 571 | 572 |
| 572 bool result = false; | 573 bool result = false; |
| 573 if (!sender_->Send(new AutomationMsg_WaitForPopupMenuToOpen(&result))) | 574 if (!sender_->Send(new AutomationMsg_WaitForPopupMenuToOpen(&result))) |
| 574 return false; | 575 return false; |
| 575 return result; | 576 return result; |
| 576 } | 577 } |
| 577 | 578 |
| 578 bool BrowserProxy::SendJSONRequest(const std::string& request, | 579 bool BrowserProxy::SendJSONRequest(const std::string& request, |
| 579 std::string* response) { | 580 std::string* response) { |
| 581 return SendJSONRequest(request, response, |
| 582 TestTimeouts::action_max_timeout_ms()); |
| 583 } |
| 584 |
| 585 bool BrowserProxy::SendJSONRequest(const std::string& request, |
| 586 std::string* response, int timeout) { |
| 580 if (!is_valid()) | 587 if (!is_valid()) |
| 581 return false; | 588 return false; |
| 582 | 589 |
| 583 bool result = false; | 590 bool result = false; |
| 584 if (!sender_->Send(new AutomationMsg_SendJSONRequest(handle_, | 591 if (!sender_->Send(new AutomationMsg_SendJSONRequest(handle_, |
| 585 request, | 592 request, |
| 586 response, | 593 response, |
| 587 &result))) | 594 &result), |
| 595 timeout)) |
| 588 return false; | 596 return false; |
| 589 return result; | 597 return result; |
| 590 } | 598 } |
| 591 | 599 |
| 592 bool BrowserProxy::GetInitialLoadTimes(float* min_start_time, | 600 bool BrowserProxy::GetInitialLoadTimes(float* min_start_time, |
| 593 float* max_stop_time, | 601 float* max_stop_time, |
| 594 std::vector<float>* stop_times) { | 602 std::vector<float>* stop_times) { |
| 595 std::string json_response; | 603 std::string json_response; |
| 596 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}"; | 604 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}"; |
| 597 | 605 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 if (i == 0) | 649 if (i == 0) |
| 642 *min_start_time = start_ms; | 650 *min_start_time = start_ms; |
| 643 | 651 |
| 644 *min_start_time = std::min(start_ms, *min_start_time); | 652 *min_start_time = std::min(start_ms, *min_start_time); |
| 645 *max_stop_time = std::max(stop_ms, *max_stop_time); | 653 *max_stop_time = std::max(stop_ms, *max_stop_time); |
| 646 stop_times->push_back(stop_ms); | 654 stop_times->push_back(stop_ms); |
| 647 } | 655 } |
| 648 std::sort(stop_times->begin(), stop_times->end()); | 656 std::sort(stop_times->begin(), stop_times->end()); |
| 649 return true; | 657 return true; |
| 650 } | 658 } |
| OLD | NEW |