Chromium Code Reviews| Index: base/test/trace_event_analyzer.h |
| diff --git a/base/test/trace_event_analyzer.h b/base/test/trace_event_analyzer.h |
| index 4bf48845eb1dcd027fc0843b780a955b2b510dd2..86982ca2b02a791d206498276faa8b83a5cf4b68 100644 |
| --- a/base/test/trace_event_analyzer.h |
| +++ b/base/test/trace_event_analyzer.h |
| @@ -131,6 +131,23 @@ struct TraceEvent { |
| // Return the argument value if it exists and it is a number. |
| bool GetArgAsNumber(const std::string& name, double* arg) const; |
| + // If you need an argument as a certain integer type, you can use this method |
| + // to get it and cast it to your type. |
|
nduca
2011/11/01 19:17:49
Copy the way base-value works? GetArgAsBool/etc. T
jbates
2011/11/03 00:51:07
Done. Actually since queries already verify the ex
|
| + // For example: |
| + // MyEnum my_enum; |
| + // bool found = event.GetArgAsIntType("the_enum", &my_enum); |
| + template<class INTEGER_TYPE> |
| + bool GetArgAsIntType(const std::string& name, INTEGER_TYPE* arg) const { |
| + double arg_double; |
| + if (GetArgAsNumber(name, &arg_double)) { |
| + // Certain compilers don't allow casting directly from double to enums. |
| + int64 arg_int = static_cast<int64>(arg_double); |
| + *arg = static_cast<INTEGER_TYPE>(arg_int); |
| + return true; |
| + } |
| + return false; |
| + } |
| + |
| // Process ID and Thread ID. |
| ProcessThreadID thread; |