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 |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/pattern.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 | 15 |
15 namespace trace_analyzer { | 16 namespace trace_analyzer { |
16 | 17 |
17 // TraceEvent | 18 // TraceEvent |
18 | 19 |
19 TraceEvent::TraceEvent() | 20 TraceEvent::TraceEvent() |
20 : thread(0, 0), | 21 : thread(0, 0), |
21 timestamp(0), | 22 timestamp(0), |
22 duration(0), | 23 duration(0), |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 315 } |
315 } | 316 } |
316 | 317 |
317 bool Query::CompareAsString(const TraceEvent& event, bool* result) const { | 318 bool Query::CompareAsString(const TraceEvent& event, bool* result) const { |
318 std::string lhs, rhs; | 319 std::string lhs, rhs; |
319 if (!left().GetAsString(event, &lhs) || !right().GetAsString(event, &rhs)) | 320 if (!left().GetAsString(event, &lhs) || !right().GetAsString(event, &rhs)) |
320 return false; | 321 return false; |
321 switch (operator_) { | 322 switch (operator_) { |
322 case OP_EQ: | 323 case OP_EQ: |
323 if (right().is_pattern_) | 324 if (right().is_pattern_) |
324 *result = MatchPattern(lhs, rhs); | 325 *result = base::MatchPattern(lhs, rhs); |
325 else if (left().is_pattern_) | 326 else if (left().is_pattern_) |
326 *result = MatchPattern(rhs, lhs); | 327 *result = base::MatchPattern(rhs, lhs); |
327 else | 328 else |
328 *result = (lhs == rhs); | 329 *result = (lhs == rhs); |
329 return true; | 330 return true; |
330 case OP_NE: | 331 case OP_NE: |
331 if (right().is_pattern_) | 332 if (right().is_pattern_) |
332 *result = !MatchPattern(lhs, rhs); | 333 *result = !base::MatchPattern(lhs, rhs); |
333 else if (left().is_pattern_) | 334 else if (left().is_pattern_) |
334 *result = !MatchPattern(rhs, lhs); | 335 *result = !base::MatchPattern(rhs, lhs); |
335 else | 336 else |
336 *result = (lhs != rhs); | 337 *result = (lhs != rhs); |
337 return true; | 338 return true; |
338 case OP_LT: | 339 case OP_LT: |
339 *result = (lhs < rhs); | 340 *result = (lhs < rhs); |
340 return true; | 341 return true; |
341 case OP_LE: | 342 case OP_LE: |
342 *result = (lhs <= rhs); | 343 *result = (lhs <= rhs); |
343 return true; | 344 return true; |
344 case OP_GT: | 345 case OP_GT: |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 end_position = (end_position < events.size()) ? end_position : events.size(); | 960 end_position = (end_position < events.size()) ? end_position : events.size(); |
960 size_t count = 0u; | 961 size_t count = 0u; |
961 for (size_t i = begin_position; i < end_position; ++i) { | 962 for (size_t i = begin_position; i < end_position; ++i) { |
962 if (query.Evaluate(*events.at(i))) | 963 if (query.Evaluate(*events.at(i))) |
963 ++count; | 964 ++count; |
964 } | 965 } |
965 return count; | 966 return count; |
966 } | 967 } |
967 | 968 |
968 } // namespace trace_analyzer | 969 } // namespace trace_analyzer |
OLD | NEW |