| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/test/trace_event_analyzer.h" | 5 #include "base/test/trace_event_analyzer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <math.h> | 8 #include <math.h> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 continue; | 641 continue; |
| 642 if (query.Evaluate(events[i])) | 642 if (query.Evaluate(events[i])) |
| 643 output->push_back(&events[i]); | 643 output->push_back(&events[i]); |
| 644 } | 644 } |
| 645 return output->size(); | 645 return output->size(); |
| 646 } | 646 } |
| 647 | 647 |
| 648 bool ParseEventsFromJson(const std::string& json, | 648 bool ParseEventsFromJson(const std::string& json, |
| 649 std::vector<TraceEvent>* output) { | 649 std::vector<TraceEvent>* output) { |
| 650 scoped_ptr<base::Value> root; | 650 scoped_ptr<base::Value> root; |
| 651 root.reset(base::JSONReader::Read(json)); | 651 root.reset(base::JSONReader::DeprecatedRead(json)); |
| 652 | 652 |
| 653 base::ListValue* root_list = NULL; | 653 base::ListValue* root_list = NULL; |
| 654 if (!root.get() || !root->GetAsList(&root_list)) | 654 if (!root.get() || !root->GetAsList(&root_list)) |
| 655 return false; | 655 return false; |
| 656 | 656 |
| 657 for (size_t i = 0; i < root_list->GetSize(); ++i) { | 657 for (size_t i = 0; i < root_list->GetSize(); ++i) { |
| 658 base::Value* item = NULL; | 658 base::Value* item = NULL; |
| 659 if (root_list->Get(i, &item)) { | 659 if (root_list->Get(i, &item)) { |
| 660 TraceEvent event; | 660 TraceEvent event; |
| 661 if (event.SetFromJSON(item)) | 661 if (event.SetFromJSON(item)) |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 end_position = (end_position < events.size()) ? end_position : events.size(); | 959 end_position = (end_position < events.size()) ? end_position : events.size(); |
| 960 size_t count = 0u; | 960 size_t count = 0u; |
| 961 for (size_t i = begin_position; i < end_position; ++i) { | 961 for (size_t i = begin_position; i < end_position; ++i) { |
| 962 if (query.Evaluate(*events.at(i))) | 962 if (query.Evaluate(*events.at(i))) |
| 963 ++count; | 963 ++count; |
| 964 } | 964 } |
| 965 return count; | 965 return count; |
| 966 } | 966 } |
| 967 | 967 |
| 968 } // namespace trace_analyzer | 968 } // namespace trace_analyzer |
| OLD | NEW |