| 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" |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 if (i == 0) | 632 if (i == 0) |
| 633 *min_start_time = start_ms; | 633 *min_start_time = start_ms; |
| 634 | 634 |
| 635 *min_start_time = std::min(start_ms, *min_start_time); | 635 *min_start_time = std::min(start_ms, *min_start_time); |
| 636 *max_stop_time = std::max(stop_ms, *max_stop_time); | 636 *max_stop_time = std::max(stop_ms, *max_stop_time); |
| 637 stop_times->push_back(stop_ms); | 637 stop_times->push_back(stop_ms); |
| 638 } | 638 } |
| 639 std::sort(stop_times->begin(), stop_times->end()); | 639 std::sort(stop_times->begin(), stop_times->end()); |
| 640 return true; | 640 return true; |
| 641 } | 641 } |
| 642 |
| 643 bool BrowserProxy::BeginTracing(const std::string& included_categories) { |
| 644 std::vector<std::string> included, excluded; |
| 645 included.push_back(included_categories); |
| 646 return BeginTracing(included, excluded); |
| 647 } |
| 648 |
| 649 bool BrowserProxy::BeginTracing( |
| 650 const std::vector<std::string>& included_categories, |
| 651 const std::vector<std::string>& excluded_categories) { |
| 652 if (!is_valid()) |
| 653 return false; |
| 654 |
| 655 bool result = false; |
| 656 sender_->Send(new AutomationMsg_BeginTracing(included_categories, |
| 657 excluded_categories, |
| 658 &result)); |
| 659 return result; |
| 660 } |
| 661 |
| 662 bool BrowserProxy::EndTracing(std::string* json_trace_output) { |
| 663 if (!is_valid()) |
| 664 return false; |
| 665 |
| 666 json_trace_output->clear(); |
| 667 bool success = false; |
| 668 int remaining_chunks = 0; |
| 669 std::string chunk; |
| 670 sender_->Send(new AutomationMsg_EndTracing(&success)); |
| 671 if (success) { |
| 672 // workaround IPC payload size limitation by getting chunks. |
| 673 do { |
| 674 sender_->Send(new AutomationMsg_GetTracingOutput(&chunk, |
| 675 &remaining_chunks)); |
| 676 *json_trace_output += chunk; |
| 677 } while (remaining_chunks > 0); |
| 678 success = (remaining_chunks == 0); |
| 679 } |
| 680 return success; |
| 681 } |
| 682 |
| OLD | NEW |