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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 for (size_t i = 0; i < events.size(); ++i) { | 637 for (size_t i = 0; i < events.size(); ++i) { |
638 if (query.Evaluate(events[i])) | 638 if (query.Evaluate(events[i])) |
639 output->push_back(&events[i]); | 639 output->push_back(&events[i]); |
640 } | 640 } |
641 return output->size(); | 641 return output->size(); |
642 } | 642 } |
643 | 643 |
644 bool ParseEventsFromJson(const std::string& json, | 644 bool ParseEventsFromJson(const std::string& json, |
645 std::vector<TraceEvent>* output) { | 645 std::vector<TraceEvent>* output) { |
646 scoped_ptr<base::Value> root; | 646 scoped_ptr<base::Value> root; |
647 root.reset(base::JSONReader::Read(json, false)); | 647 root.reset(base::JSONReader::Read(json)); |
648 | 648 |
649 ListValue* root_list = NULL; | 649 ListValue* root_list = NULL; |
650 if (!root.get() || !root->GetAsList(&root_list)) | 650 if (!root.get() || !root->GetAsList(&root_list)) |
651 return false; | 651 return false; |
652 | 652 |
653 for (size_t i = 0; i < root_list->GetSize(); ++i) { | 653 for (size_t i = 0; i < root_list->GetSize(); ++i) { |
654 Value* item = NULL; | 654 Value* item = NULL; |
655 if (root_list->Get(i, &item)) { | 655 if (root_list->Get(i, &item)) { |
656 TraceEvent event; | 656 TraceEvent event; |
657 if (event.SetFromJSON(item)) | 657 if (event.SetFromJSON(item)) |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 size_t count = 0u; | 951 size_t count = 0u; |
952 for (size_t i = begin_position; i < end_position; ++i) { | 952 for (size_t i = begin_position; i < end_position; ++i) { |
953 if (query.Evaluate(*events.at(i))) | 953 if (query.Evaluate(*events.at(i))) |
954 ++count; | 954 ++count; |
955 } | 955 } |
956 return count; | 956 return count; |
957 } | 957 } |
958 | 958 |
959 } // namespace trace_analyzer | 959 } // namespace trace_analyzer |
960 | 960 |
OLD | NEW |