| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 long long m_int; | 731 long long m_int; |
| 732 double m_double; | 732 double m_double; |
| 733 const void* m_pointer; | 733 const void* m_pointer; |
| 734 const char* m_string; | 734 const char* m_string; |
| 735 }; | 735 }; |
| 736 | 736 |
| 737 // Simple container for const char* that should be copied instead of retained. | 737 // Simple container for const char* that should be copied instead of retained. |
| 738 class TraceStringWithCopy { | 738 class TraceStringWithCopy { |
| 739 public: | 739 public: |
| 740 explicit TraceStringWithCopy(const char* str) : m_str(str) { } | 740 explicit TraceStringWithCopy(const char* str) : m_str(str) { } |
| 741 operator const char* () const { return m_str; } | 741 const char* str() const { return m_str; } |
| 742 private: | 742 private: |
| 743 const char* m_str; | 743 const char* m_str; |
| 744 }; | 744 }; |
| 745 | 745 |
| 746 // Define setTraceValue for each allowed type. It stores the type and | 746 // Define setTraceValue for each allowed type. It stores the type and |
| 747 // value in the return arguments. This allows this API to avoid declaring any | 747 // value in the return arguments. This allows this API to avoid declaring any |
| 748 // structures so that it is portable to third_party libraries. | 748 // structures so that it is portable to third_party libraries. |
| 749 #define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \ | 749 #define INTERNAL_DECLARE_SET_TRACE_VALUE(actualType, argExpression, unionMember,
valueTypeId) \ |
| 750 union_member, \ | 750 static inline void setTraceValue(actualType arg, unsigned char* type, unsign
ed long long* value) { \ |
| 751 value_type_id) \ | |
| 752 static inline void setTraceValue(actual_type arg, \ | |
| 753 unsigned char* type, \ | |
| 754 unsigned long long* value) { \ | |
| 755 TraceValueUnion typeValue; \ | 751 TraceValueUnion typeValue; \ |
| 756 typeValue.union_member = arg; \ | 752 typeValue.unionMember = argExpression; \ |
| 757 *type = value_type_id; \ | 753 *type = valueTypeId; \ |
| 758 *value = typeValue.m_uint; \ | 754 *value = typeValue.m_uint; \ |
| 759 } | 755 } |
| 760 // Simpler form for int types that can be safely casted. | 756 // Simpler form for int types that can be safely casted. |
| 761 #define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, \ | 757 #define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actualType, valueTypeId) \ |
| 762 value_type_id) \ | 758 static inline void setTraceValue(actualType arg, \ |
| 763 static inline void setTraceValue(actual_type arg, \ | |
| 764 unsigned char* type, \ | 759 unsigned char* type, \ |
| 765 unsigned long long* value) { \ | 760 unsigned long long* value) { \ |
| 766 *type = value_type_id; \ | 761 *type = valueTypeId; \ |
| 767 *value = static_cast<unsigned long long>(arg); \ | 762 *value = static_cast<unsigned long long>(arg); \ |
| 768 } | 763 } |
| 769 | 764 |
| 770 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT) | 765 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT) |
| 771 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned, TRACE_VALUE_TYPE_UINT) | 766 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned, TRACE_VALUE_TYPE_UINT) |
| 772 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT) | 767 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT) |
| 773 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT) | 768 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT) |
| 774 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT) | 769 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT) |
| 775 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT) | 770 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT) |
| 776 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT) | 771 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT) |
| 777 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT) | 772 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT) |
| 778 INTERNAL_DECLARE_SET_TRACE_VALUE(bool, m_bool, TRACE_VALUE_TYPE_BOOL) | 773 INTERNAL_DECLARE_SET_TRACE_VALUE(bool, arg, m_bool, TRACE_VALUE_TYPE_BOOL) |
| 779 INTERNAL_DECLARE_SET_TRACE_VALUE(double, m_double, TRACE_VALUE_TYPE_DOUBLE) | 774 INTERNAL_DECLARE_SET_TRACE_VALUE(double, arg, m_double, TRACE_VALUE_TYPE_DOUBLE) |
| 780 INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, m_pointer, | 775 INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, arg, m_pointer, TRACE_VALUE_TYPE_P
OINTER) |
| 781 TRACE_VALUE_TYPE_POINTER) | 776 INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, arg, m_string, TRACE_VALUE_TYPE_ST
RING) |
| 782 INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, m_string, | 777 INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, arg.str(), m_string
, TRACE_VALUE_TYPE_COPY_STRING) |
| 783 TRACE_VALUE_TYPE_STRING) | |
| 784 INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, m_string, | |
| 785 TRACE_VALUE_TYPE_COPY_STRING) | |
| 786 | 778 |
| 787 #undef INTERNAL_DECLARE_SET_TRACE_VALUE | 779 #undef INTERNAL_DECLARE_SET_TRACE_VALUE |
| 788 #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT | 780 #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT |
| 789 | 781 |
| 790 // WTF::String version of setTraceValue so that trace arguments can be strings. | 782 // WTF::String version of setTraceValue so that trace arguments can be strings. |
| 791 static inline void setTraceValue(const WTF::CString& arg, unsigned char* type, u
nsigned long long* value) | 783 static inline void setTraceValue(const WTF::CString& arg, unsigned char* type, u
nsigned long long* value) |
| 792 { | 784 { |
| 793 TraceValueUnion typeValue; | 785 TraceValueUnion typeValue; |
| 794 typeValue.m_string = arg.data(); | 786 typeValue.m_string = arg.data(); |
| 795 *type = TRACE_VALUE_TYPE_COPY_STRING; | 787 *type = TRACE_VALUE_TYPE_COPY_STRING; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 const char* m_categoryGroup; | 1001 const char* m_categoryGroup; |
| 1010 const char* m_name; | 1002 const char* m_name; |
| 1011 IDType m_id; | 1003 IDType m_id; |
| 1012 }; | 1004 }; |
| 1013 | 1005 |
| 1014 } // namespace TraceEvent | 1006 } // namespace TraceEvent |
| 1015 | 1007 |
| 1016 } // namespace WebCore | 1008 } // namespace WebCore |
| 1017 | 1009 |
| 1018 #endif | 1010 #endif |
| OLD | NEW |