| OLD | NEW |
| 1 // Copyright (c) 2011 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" | |
| 12 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 13 #include "base/time.h" | 12 #include "base/time.h" |
| 14 #include "chrome/common/automation_constants.h" | 13 #include "chrome/common/automation_constants.h" |
| 15 #include "chrome/common/automation_messages.h" | 14 #include "chrome/common/automation_messages.h" |
| 16 #include "chrome/test/automation/automation_proxy.h" | 15 #include "chrome/test/automation/automation_proxy.h" |
| 17 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 18 #include "chrome/test/automation/window_proxy.h" | 17 #include "chrome/test/automation/window_proxy.h" |
| 19 #include "ui/gfx/point.h" | 18 #include "ui/gfx/point.h" |
| 20 | 19 |
| 21 using base::TimeDelta; | 20 using base::TimeDelta; |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 bool result = false; | 571 bool result = false; |
| 573 if (!sender_->Send(new AutomationMsg_SendJSONRequest(handle_, | 572 if (!sender_->Send(new AutomationMsg_SendJSONRequest(handle_, |
| 574 request, | 573 request, |
| 575 response, | 574 response, |
| 576 &result), | 575 &result), |
| 577 timeout_ms)) | 576 timeout_ms)) |
| 578 return false; | 577 return false; |
| 579 return result; | 578 return result; |
| 580 } | 579 } |
| 581 | 580 |
| 582 bool BrowserProxy::GetInitialLoadTimes(float* min_start_time, | 581 bool BrowserProxy::GetInitialLoadTimes(int timeout_ms, |
| 582 float* min_start_time, |
| 583 float* max_stop_time, | 583 float* max_stop_time, |
| 584 std::vector<float>* stop_times) { | 584 std::vector<float>* stop_times) { |
| 585 std::string json_response; | 585 std::string json_response; |
| 586 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}"; | 586 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}"; |
| 587 | 587 |
| 588 *max_stop_time = 0; | 588 *max_stop_time = 0; |
| 589 *min_start_time = -1; | 589 *min_start_time = -1; |
| 590 if (!SendJSONRequest(kJSONCommand, | 590 if (!SendJSONRequest(kJSONCommand, timeout_ms, &json_response)) { |
| 591 TestTimeouts::action_max_timeout_ms(), | |
| 592 &json_response)) { | |
| 593 // Older browser versions do not support GetInitialLoadTimes. | 591 // Older browser versions do not support GetInitialLoadTimes. |
| 594 // Fail gracefully and do not record them in this case. | 592 // Fail gracefully and do not record them in this case. |
| 595 return false; | 593 return false; |
| 596 } | 594 } |
| 597 std::string error; | 595 std::string error; |
| 598 base::JSONReader reader; | 596 base::JSONReader reader; |
| 599 scoped_ptr<Value> values(reader.ReadAndReturnError(json_response, true, | 597 scoped_ptr<Value> values(reader.ReadAndReturnError(json_response, true, |
| 600 NULL, &error)); | 598 NULL, &error)); |
| 601 if (!error.empty() || values->GetType() != Value::TYPE_DICTIONARY) | 599 if (!error.empty() || values->GetType() != Value::TYPE_DICTIONARY) |
| 602 return false; | 600 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 633 if (i == 0) | 631 if (i == 0) |
| 634 *min_start_time = start_ms; | 632 *min_start_time = start_ms; |
| 635 | 633 |
| 636 *min_start_time = std::min(start_ms, *min_start_time); | 634 *min_start_time = std::min(start_ms, *min_start_time); |
| 637 *max_stop_time = std::max(stop_ms, *max_stop_time); | 635 *max_stop_time = std::max(stop_ms, *max_stop_time); |
| 638 stop_times->push_back(stop_ms); | 636 stop_times->push_back(stop_ms); |
| 639 } | 637 } |
| 640 std::sort(stop_times->begin(), stop_times->end()); | 638 std::sort(stop_times->begin(), stop_times->end()); |
| 641 return true; | 639 return true; |
| 642 } | 640 } |
| OLD | NEW |