Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(993)

Unified Diff: base/trace_event/trace_event_unittest.cc

Issue 2162183002: Binds an ID to a Globally Unique ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@netinst_macros
Patch Set: reimplemented Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/trace_event/trace_event.h ('K') | « base/trace_event/trace_event_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_event_unittest.cc
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc
index ad3fe92baace2dd598443e495454e8782bfd3e16..d7024af6dd756c32b17174b6b489f5787b23b345 100644
--- a/base/trace_event/trace_event_unittest.cc
+++ b/base/trace_event/trace_event_unittest.cc
@@ -518,10 +518,16 @@ void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) {
TRACE_EVENT_SCOPED_CONTEXT("all", "TRACE_EVENT_SCOPED_CONTEXT call",
context_id);
- TRACE_BIND_IDS("all", "TRACE_BIND_IDS simple call", 0x1000, 0x2000);
- TRACE_BIND_IDS("all", "TRACE_BIND_IDS scoped call",
+ TRACE_LINK_IDS("all", "simple linking", 0x1000, 0x2000);
+ TRACE_LINK_IDS("all", "link scoped ids",
TRACE_ID_WITH_SCOPE("scope 1", 0x1000),
TRACE_ID_WITH_SCOPE("scope 2", 0x2000));
+ TRACE_LINK_IDS("all", "link to a global id", 0x1000,
+ GLOBAL_TRACE_ID_WITH_SCOPE("scope", 0x2000));
+ TRACE_LINK_IDS("all", "link from a global id",
+ GLOBAL_TRACE_ID(0x1000), 0x2000);
+ TRACE_LINK_IDS("all", "link to a composite id", 0x1000,
+ GLOBAL_TRACE_ID_WITH_SCOPE("scope", 0x2000, 0x3000));
} // Scope close causes TRACE_EVENT0 etc to send their END events.
if (task_complete_event)
@@ -963,44 +969,117 @@ void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) {
EXPECT_EQ("0x20151021", id);
}
- EXPECT_FIND_("TRACE_BIND_IDS simple call");
+ EXPECT_FIND_("simple linking");
{
std::string ph;
EXPECT_TRUE((item && item->GetString("ph", &ph)));
EXPECT_EQ("=", ph);
EXPECT_FALSE((item && item->HasKey("scope")));
- std::string id;
- EXPECT_TRUE((item && item->GetString("id", &id)));
- EXPECT_EQ("0x1000", id);
+ EXPECT_FALSE((item && item->HasKey("id_is_global")));
+ std::string id1;
+ EXPECT_TRUE((item && item->GetString("id", &id1)));
+ EXPECT_EQ("0x1000", id1);
- EXPECT_FALSE((item && item->HasKey("args.bind_scope")));
- std::string bind_id;
- EXPECT_TRUE((item && item->GetString("bind_id", &id)));
- EXPECT_EQ("0x2000", id);
+ EXPECT_FALSE((item && item->HasKey("args.linked_id.scope")));
+ EXPECT_FALSE((item && item->HasKey("args.linked_id.id_is_global")));
+ std::string id2;
+ EXPECT_TRUE((item && item->GetString("args.linked_id.id", &id2)));
+ EXPECT_EQ("0x2000", id2);
}
- EXPECT_FIND_("TRACE_BIND_IDS scoped call");
+ EXPECT_FIND_("link scoped ids");
{
std::string ph;
EXPECT_TRUE((item && item->GetString("ph", &ph)));
EXPECT_EQ("=", ph);
- std::string id_scope;
- EXPECT_TRUE((item && item->GetString("scope", &id_scope)));
- EXPECT_EQ("scope 1", id_scope);
- std::string id;
- EXPECT_TRUE((item && item->GetString("id", &id)));
- EXPECT_EQ("0x1000", id);
+ std::string scope1;
+ EXPECT_TRUE((item && item->GetString("scope", &scope1)));
+ EXPECT_EQ("scope 1", scope1);
+ std::string id1;
+ EXPECT_TRUE((item && item->GetString("id", &id1)));
+ EXPECT_EQ("0x1000", id1);
+
+ std::string scope2;
+ EXPECT_TRUE((item && item->GetString("args.linked_id.scope", &scope2)));
+ EXPECT_EQ("scope 2", scope2);
+ std::string id2;
+ EXPECT_TRUE((item && item->GetString("args.linked_id.id", &id2)));
+ EXPECT_EQ("0x2000", id2);
+ }
+
+ EXPECT_FIND_("link to a global id");
+ {
+ std::string ph;
+ EXPECT_TRUE((item && item->GetString("ph", &ph)));
+ EXPECT_EQ("=", ph);
+
+ EXPECT_FALSE((item && item->HasKey("scope")));
+ std::string id1;
+ EXPECT_TRUE((item && item->GetString("id", &id1)));
+ EXPECT_EQ("0x1000", id1);
+
+ std::string scope2;
+ EXPECT_TRUE((item && item->GetString("args.linked_id.scope", &scope2)));
+ EXPECT_EQ("scope", scope2);
+ std::string id2;
+ EXPECT_TRUE((item && item->GetString("args.linked_id.id", &id2)));
+ EXPECT_EQ("0x2000", id2);
+ bool id2_is_global;
+ EXPECT_TRUE((item && item->GetBoolean("args.linked_id.id_is_global",
+ &id2_is_global)));
+ EXPECT_TRUE(id2_is_global);
+ }
+
+ EXPECT_FIND_("link from a global id");
+ {
+ std::string ph;
+ EXPECT_TRUE((item && item->GetString("ph", &ph)));
+ EXPECT_EQ("=", ph);
- std::string bind_scope;
- EXPECT_TRUE((item && item->GetString("args.bind_scope", &bind_scope)));
- EXPECT_EQ("scope 2", bind_scope);
- std::string bind_id;
- EXPECT_TRUE((item && item->GetString("bind_id", &id)));
- EXPECT_EQ("0x2000", id);
+ EXPECT_FALSE((item && item->HasKey("scope")));
+ std::string id1;
+ EXPECT_TRUE((item && item->GetString("id", &id1)));
+ EXPECT_EQ("0x1000", id1);
+ bool id1_is_global;
+ EXPECT_TRUE((item && item->GetBoolean("id_is_global", &id1_is_global)));
+ EXPECT_TRUE(id1_is_global);
+
+ EXPECT_FALSE((item && item->HasKey("args.linked_id.scope")));
+ EXPECT_FALSE((item && item->HasKey("args.linked_id.id_is_global")));
+ std::string id2;
+ EXPECT_TRUE((item && item->GetString("args.linked_id.id", &id2)));
+ EXPECT_EQ("0x2000", id2);
}
+ EXPECT_FIND_("link to a composite id");
+ {
+ std::string ph;
+ EXPECT_TRUE((item && item->GetString("ph", &ph)));
+ EXPECT_EQ("=", ph);
+
+ EXPECT_FALSE((item && item->HasKey("scope")));
+ std::string id1;
+ EXPECT_TRUE((item && item->GetString("id", &id1)));
+ EXPECT_EQ("0x1000", id1);
+
+ std::string scope2;
+ EXPECT_TRUE((item && item->GetString("args.linked_id.scope", &scope2)));
+ EXPECT_EQ("scope", scope2);
+ const ListValue* id2 = NULL;
+ EXPECT_TRUE((item && item->GetList("args.linked_id.id", &id2)));
+ EXPECT_EQ(2u, id2->GetSize());
+ std::string part1, part2;
+ EXPECT_TRUE(id2->GetString(0, &part1));
+ EXPECT_EQ("0x2000", part1);
+ EXPECT_TRUE(id2->GetString(1, &part2));
+ EXPECT_EQ("0x3000", part2);
+ bool id2_is_global;
+ EXPECT_TRUE((item && item->GetBoolean("args.linked_id.id_is_global",
+ &id2_is_global)));
+ EXPECT_TRUE(id2_is_global);
+ }
}
void TraceManyInstantEvents(int thread_id, int num_events,
« base/trace_event/trace_event.h ('K') | « base/trace_event/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698