Remove TraceStringWrapper::operator const char*()

Remove the operator to avoid misuse like the following:
  TRACE_EVENT1("a", "b", "c",
     condition ? TRACE_STR_COPY(short_live_string) : "literal");
In the above case, the argument value is actually const char*, not
TraceValueWithCopy because it is automatically converted back to
const char* with the const char* operator.

Found no errornous usages in chromium, but found one error in WebKit.

R=dsinclair
BUG=382789 (perhaps the reason)

Review URL: https://codereview.chromium.org/338653005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278061 0039d316-1c4b-4281-b951-d872f2087c98
parent fb3cc061
...@@ -1097,7 +1097,7 @@ union TraceValueUnion { ...@@ -1097,7 +1097,7 @@ union TraceValueUnion {
class TraceStringWithCopy { class TraceStringWithCopy {
public: public:
explicit TraceStringWithCopy(const char* str) : str_(str) {} explicit TraceStringWithCopy(const char* str) : str_(str) {}
operator const char* () const { return str_; } const char* str() const { return str_; }
private: private:
const char* str_; const char* str_;
}; };
...@@ -1106,6 +1106,7 @@ class TraceStringWithCopy { ...@@ -1106,6 +1106,7 @@ class TraceStringWithCopy {
// value in the return arguments. This allows this API to avoid declaring any // value in the return arguments. This allows this API to avoid declaring any
// structures so that it is portable to third_party libraries. // structures so that it is portable to third_party libraries.
#define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \ #define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \
arg_expression, \
union_member, \ union_member, \
value_type_id) \ value_type_id) \
static inline void SetTraceValue( \ static inline void SetTraceValue( \
...@@ -1113,7 +1114,7 @@ class TraceStringWithCopy { ...@@ -1113,7 +1114,7 @@ class TraceStringWithCopy {
unsigned char* type, \ unsigned char* type, \
unsigned long long* value) { \ unsigned long long* value) { \
TraceValueUnion type_value; \ TraceValueUnion type_value; \
type_value.union_member = arg; \ type_value.union_member = arg_expression; \
*type = value_type_id; \ *type = value_type_id; \
*value = type_value.as_uint; \ *value = type_value.as_uint; \
} }
...@@ -1138,14 +1139,15 @@ INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT) ...@@ -1138,14 +1139,15 @@ INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT) INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT) INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT) INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE(bool, as_bool, TRACE_VALUE_TYPE_BOOL) INTERNAL_DECLARE_SET_TRACE_VALUE(bool, arg, as_bool, TRACE_VALUE_TYPE_BOOL)
INTERNAL_DECLARE_SET_TRACE_VALUE(double, as_double, TRACE_VALUE_TYPE_DOUBLE) INTERNAL_DECLARE_SET_TRACE_VALUE(double, arg, as_double,
INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, as_pointer, TRACE_VALUE_TYPE_DOUBLE)
INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, arg, as_pointer,
TRACE_VALUE_TYPE_POINTER) TRACE_VALUE_TYPE_POINTER)
INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, as_string, INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, arg, as_string,
TRACE_VALUE_TYPE_STRING) TRACE_VALUE_TYPE_STRING)
INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, as_string, INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, arg.str(),
TRACE_VALUE_TYPE_COPY_STRING) as_string, TRACE_VALUE_TYPE_COPY_STRING)
#undef INTERNAL_DECLARE_SET_TRACE_VALUE #undef INTERNAL_DECLARE_SET_TRACE_VALUE
#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment