Commit 93d8903a authored by Yury Khmel's avatar Yury Khmel Committed by Commit Bot

arc: Fix tracing model unable to build.

This handles new style of applying ids to async events.

TEST=Locally
BUG=b:150030838
BUG=b:160024571

Change-Id: I7ac4ab3241cd04201ae8c7800102bfa43c7df499
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2285506Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Yury Khmel <khmel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786079}
parent 8038a876
......@@ -19,6 +19,8 @@ constexpr char kKeyArguments[] = "args";
constexpr char kKeyDuration[] = "dur";
constexpr char kKeyCategory[] = "cat";
constexpr char kKeyId[] = "id";
constexpr char kKeyId2[] = "id2";
constexpr char kKeyLocal[] = "local";
constexpr char kKeyName[] = "name";
constexpr char kKeyPid[] = "pid";
constexpr char kKeyPhase[] = "ph";
......@@ -90,8 +92,21 @@ void ArcTracingEvent::SetTid(int tid) {
}
std::string ArcTracingEvent::GetId() const {
return GetStringFromDictionary(GetDictionary(), kKeyId,
std::string() /* default_value */);
const base::DictionaryValue* dictionary = GetDictionary();
const base::Value* id_value =
dictionary->FindKeyOfType(kKeyId, base::Value::Type::STRING);
if (id_value)
return id_value->GetString();
const base::Value* id2_value =
dictionary->FindKeyOfType(kKeyId2, base::Value::Type::DICTIONARY);
if (id2_value) {
const base::DictionaryValue* id2_dictionary;
id2_value->GetAsDictionary(&id2_dictionary);
return GetStringFromDictionary(id2_dictionary, kKeyLocal,
std::string() /* default_value */);
}
return std::string();
}
void ArcTracingEvent::SetId(const std::string& id) {
......
......@@ -41,6 +41,10 @@ constexpr char kTestEvent[] =
"name":"Surface::Attach",
"args":{"buffer_id":"0x7f9f5110690","app_id":"org.chromium.arc.6"},
"dur":10,"tdur":9,"tts":1216670360})";
constexpr char kTestEvent2[] =
R"({"args":{},"cat":"exo","id2":{"local":"0x2df1a3130a10"},
"name":"BufferInUse","ph":"F","pid":17518,"tid":17518,
"ts":7654346859.0,"tts":93686437})";
constexpr char kAppId[] = "app_id";
constexpr char kAppIdValue[] = "org.chromium.arc.6";
......@@ -48,11 +52,13 @@ constexpr char kBufferId[] = "buffer_id";
constexpr char kBufferIdBad[] = "_buffer_id";
constexpr char kBufferIdValue[] = "0x7f9f5110690";
constexpr char kBufferIdValueBad[] = "_0x7f9f5110690";
constexpr char kBufferInUse[] = "BufferInUse";
constexpr char kDefault[] = "default";
constexpr char kExo[] = "exo";
constexpr char kExoBad[] = "_exo";
constexpr char kPhaseX = 'X';
constexpr char kPhaseF = 'F';
constexpr char kPhaseP = 'P';
constexpr char kPhaseX = 'X';
constexpr char kSurfaceAttach[] = "Surface::Attach";
constexpr char kSurfaceAttachBad[] = "_Surface::Attach";
......@@ -367,6 +373,21 @@ TEST_F(ArcTracingModelTest, Event) {
EXPECT_EQ(kDefault, event.GetArgAsString(kBufferIdBad, kDefault));
}
TEST_F(ArcTracingModelTest, EventId2) {
const ArcTracingEvent event(base::JSONReader::Read(kTestEvent2).value());
EXPECT_EQ(17518, event.GetPid());
EXPECT_EQ(17518, event.GetTid());
EXPECT_EQ("0x2df1a3130a10", event.GetId());
EXPECT_EQ(kExo, event.GetCategory());
EXPECT_EQ(kBufferInUse, event.GetName());
EXPECT_EQ(kPhaseF, event.GetPhase());
EXPECT_EQ(7654346859UL, event.GetTimestamp());
EXPECT_EQ(0U, event.GetDuration());
EXPECT_EQ(7654346859UL, event.GetEndTimestamp());
EXPECT_NE(nullptr, event.GetDictionary());
}
TEST_F(ArcTracingModelTest, EventClassification) {
const ArcTracingEvent event(base::JSONReader::Read(kTestEvent).value());
......
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