diff options
author | dsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-19 17:50:20 +0000 |
---|---|---|
committer | dsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-19 17:50:20 +0000 |
commit | 1345310e895137b8f25e64fd00e81ac60cb42f88 (patch) | |
tree | 0d7e451ce9a2c5ef50f8325b99ad751c00fb848a /base | |
parent | 164416f1d21c84509cebb1f0c8e43b311e9d4bd3 (diff) | |
download | chromium_src-1345310e895137b8f25e64fd00e81ac60cb42f88.zip chromium_src-1345310e895137b8f25e64fd00e81ac60cb42f88.tar.gz chromium_src-1345310e895137b8f25e64fd00e81ac60cb42f88.tar.bz2 |
Correctly handle multiple convertable argument names.
This fixes an issue when two convertable types are provided we would
only record one of the argument names. We also correclty handle
convertable names when the argument name is set to be copied.
Review URL: https://chromiumcodereview.appspot.com/14244010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/debug/trace_event.h | 3 | ||||
-rw-r--r-- | base/debug/trace_event_impl.cc | 2 | ||||
-rw-r--r-- | base/debug/trace_event_unittest.cc | 22 |
3 files changed, 24 insertions, 3 deletions
diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h index cdfe9e3..628383f 100644 --- a/base/debug/trace_event.h +++ b/base/debug/trace_event.h @@ -1060,6 +1060,7 @@ static inline void AddTraceEventWithThreadIdAndTimestamp( const char* arg2_name, scoped_ptr<base::debug::ConvertableToTraceFormat> arg2_val) { const int num_args = 2; + const char* arg_names[2] = { arg1_name, arg2_name }; unsigned char arg_types[2] = { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; scoped_ptr<base::debug::ConvertableToTraceFormat> convertable_values[2]; @@ -1068,7 +1069,7 @@ static inline void AddTraceEventWithThreadIdAndTimestamp( TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( phase, category_group_enabled, name, id, thread_id, timestamp, - num_args, &arg1_name, arg_types, NULL, convertable_values, flags); + num_args, arg_names, arg_types, NULL, convertable_values, flags); } static inline void AddTraceEvent( diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc index 96ef2c7..9e441ca 100644 --- a/base/debug/trace_event_impl.cc +++ b/base/debug/trace_event_impl.cc @@ -335,8 +335,6 @@ TraceEvent::TraceEvent( if (copy) { CopyTraceEventParameter(&ptr, &name_, end); for (i = 0; i < num_args; ++i) { - if (arg_types_[i] == TRACE_VALUE_TYPE_CONVERTABLE) - continue; CopyTraceEventParameter(&ptr, &arg_names_[i], end); } } diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc index 82c8dc0..297a345 100644 --- a/base/debug/trace_event_unittest.cc +++ b/base/debug/trace_event_unittest.cc @@ -1636,8 +1636,14 @@ TEST_F(TraceEventTestFixture, ConvertableTypes) { TraceLog::RECORD_UNTIL_FULL); scoped_ptr<MyData> data(new MyData()); + scoped_ptr<MyData> data1(new MyData()); + scoped_ptr<MyData> data2(new MyData()); TRACE_EVENT1("foo", "bar", "data", data.PassAs<base::debug::ConvertableToTraceFormat>()); + TRACE_EVENT2("foo", "baz", + "data1", data1.PassAs<base::debug::ConvertableToTraceFormat>(), + "data2", data2.PassAs<base::debug::ConvertableToTraceFormat>()); + EndTraceAndFlush(); DictionaryValue* dict = FindNamePhase("bar", "B"); @@ -1655,6 +1661,22 @@ TEST_F(TraceEventTestFixture, ConvertableTypes) { int foo_val; EXPECT_TRUE(convertable_dict->GetInteger("foo", &foo_val)); EXPECT_EQ(1, foo_val); + + dict = FindNamePhase("baz", "B"); + ASSERT_TRUE(dict); + args_dict = NULL; + dict->GetDictionary("args", &args_dict); + ASSERT_TRUE(args_dict); + + value = NULL; + convertable_dict = NULL; + EXPECT_TRUE(args_dict->Get("data1", &value)); + ASSERT_TRUE(value->GetAsDictionary(&convertable_dict)); + + value = NULL; + convertable_dict = NULL; + EXPECT_TRUE(args_dict->Get("data2", &value)); + ASSERT_TRUE(value->GetAsDictionary(&convertable_dict)); } |