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

Side by Side Diff: base/trace_event/trace_event_unittest.cc

Issue 2253973003: Add an explicit way of making IDs local or global (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/trace_event/trace_event.h" 5 #include "base/trace_event/trace_event.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 TRACE_EVENT_SCOPED_CONTEXT("disabled-by-default-cat", 515 TRACE_EVENT_SCOPED_CONTEXT("disabled-by-default-cat",
516 "TRACE_EVENT_SCOPED_CONTEXT disabled call", 516 "TRACE_EVENT_SCOPED_CONTEXT disabled call",
517 context_id); 517 context_id);
518 TRACE_EVENT_SCOPED_CONTEXT("all", "TRACE_EVENT_SCOPED_CONTEXT call", 518 TRACE_EVENT_SCOPED_CONTEXT("all", "TRACE_EVENT_SCOPED_CONTEXT call",
519 context_id); 519 context_id);
520 520
521 TRACE_BIND_IDS("all", "TRACE_BIND_IDS simple call", 0x1000, 0x2000); 521 TRACE_BIND_IDS("all", "TRACE_BIND_IDS simple call", 0x1000, 0x2000);
522 TRACE_BIND_IDS("all", "TRACE_BIND_IDS scoped call", 522 TRACE_BIND_IDS("all", "TRACE_BIND_IDS scoped call",
523 TRACE_ID_WITH_SCOPE("scope 1", 0x1000), 523 TRACE_ID_WITH_SCOPE("scope 1", 0x1000),
524 TRACE_ID_WITH_SCOPE("scope 2", 0x2000)); 524 TRACE_ID_WITH_SCOPE("scope 2", 0x2000));
525
526 TRACE_EVENT_ASYNC_BEGIN0("all", "async default process scope", 0x1000);
527 TRACE_EVENT_ASYNC_BEGIN0("all", "async local id", TRACE_ID_LOCAL(0x2000));
528 TRACE_EVENT_ASYNC_BEGIN0("all", "async global id", TRACE_ID_GLOBAL(0x3000));
529 TRACE_EVENT_ASYNC_BEGIN0("all", "async global id with scope string",
530 TRACE_ID_WITH_SCOPE("scope string",
531 TRACE_ID_GLOBAL(0x4000)));
525 } // Scope close causes TRACE_EVENT0 etc to send their END events. 532 } // Scope close causes TRACE_EVENT0 etc to send their END events.
526 533
527 if (task_complete_event) 534 if (task_complete_event)
528 task_complete_event->Signal(); 535 task_complete_event->Signal();
529 } 536 }
530 537
531 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { 538 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) {
532 const DictionaryValue* item = NULL; 539 const DictionaryValue* item = NULL;
533 540
534 #define EXPECT_FIND_(string) \ 541 #define EXPECT_FIND_(string) \
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 EXPECT_EQ("0x1000", id); 1001 EXPECT_EQ("0x1000", id);
995 1002
996 std::string bind_scope; 1003 std::string bind_scope;
997 EXPECT_TRUE((item && item->GetString("args.bind_scope", &bind_scope))); 1004 EXPECT_TRUE((item && item->GetString("args.bind_scope", &bind_scope)));
998 EXPECT_EQ("scope 2", bind_scope); 1005 EXPECT_EQ("scope 2", bind_scope);
999 std::string bind_id; 1006 std::string bind_id;
1000 EXPECT_TRUE((item && item->GetString("bind_id", &id))); 1007 EXPECT_TRUE((item && item->GetString("bind_id", &id)));
1001 EXPECT_EQ("0x2000", id); 1008 EXPECT_EQ("0x2000", id);
1002 } 1009 }
1003 1010
1011 EXPECT_FIND_("async default process scope");
1012 {
1013 std::string ph;
1014 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1015 EXPECT_EQ("S", ph);
1016
1017 std::string id;
1018 EXPECT_TRUE((item && item->GetString("id", &id)));
1019 EXPECT_EQ("0x1000", id);
1020 bool id_is_global;
1021 EXPECT_FALSE((item && item->GetBoolean("id_is_global", &id_is_global)));
1022 }
1023
1024 EXPECT_FIND_("async local id");
1025 {
1026 std::string ph;
1027 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1028 EXPECT_EQ("S", ph);
1029
1030 std::string id;
1031 EXPECT_TRUE((item && item->GetString("id", &id)));
1032 EXPECT_EQ("0x2000", id);
1033 bool id_is_global = true;
1034 EXPECT_TRUE((item && item->GetBoolean("id_is_global", &id_is_global)));
1035 EXPECT_FALSE(id_is_global);
1036 }
1037
1038 EXPECT_FIND_("async global id");
1039 {
1040 std::string ph;
1041 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1042 EXPECT_EQ("S", ph);
1043
1044 std::string id;
1045 EXPECT_TRUE((item && item->GetString("id", &id)));
1046 EXPECT_EQ("0x3000", id);
1047 bool id_is_global = false;
1048 EXPECT_TRUE((item && item->GetBoolean("id_is_global", &id_is_global)));
1049 EXPECT_TRUE(id_is_global);
1050 }
1051
1052 EXPECT_FIND_("async global id with scope string");
1053 {
1054 std::string ph;
1055 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1056 EXPECT_EQ("S", ph);
1057
1058 std::string id;
1059 EXPECT_TRUE((item && item->GetString("id", &id)));
1060 EXPECT_EQ("0x4000", id);
1061 bool id_is_global = false;
1062 EXPECT_TRUE((item && item->GetBoolean("id_is_global", &id_is_global)));
1063 EXPECT_TRUE(id_is_global);
1064 std::string scope;
1065 EXPECT_TRUE((item && item->GetString("scope", &scope)));
1066 EXPECT_EQ("scope string", scope);
1067 }
1004 } 1068 }
1005 1069
1006 void TraceManyInstantEvents(int thread_id, int num_events, 1070 void TraceManyInstantEvents(int thread_id, int num_events,
1007 WaitableEvent* task_complete_event) { 1071 WaitableEvent* task_complete_event) {
1008 for (int i = 0; i < num_events; i++) { 1072 for (int i = 0; i < num_events; i++) {
1009 TRACE_EVENT_INSTANT2("all", "multi thread event", 1073 TRACE_EVENT_INSTANT2("all", "multi thread event",
1010 TRACE_EVENT_SCOPE_THREAD, 1074 TRACE_EVENT_SCOPE_THREAD,
1011 "thread", thread_id, 1075 "thread", thread_id,
1012 "event", i); 1076 "event", i);
1013 } 1077 }
(...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3219 3283
3220 TEST_F(TraceEventTestFixture, ClockSyncEventsAreAlwaysAddedToTrace) { 3284 TEST_F(TraceEventTestFixture, ClockSyncEventsAreAlwaysAddedToTrace) {
3221 BeginSpecificTrace("-*"); 3285 BeginSpecificTrace("-*");
3222 TRACE_EVENT_CLOCK_SYNC_RECEIVER(1); 3286 TRACE_EVENT_CLOCK_SYNC_RECEIVER(1);
3223 EndTraceAndFlush(); 3287 EndTraceAndFlush();
3224 EXPECT_TRUE(FindNamePhase("clock_sync", "c")); 3288 EXPECT_TRUE(FindNamePhase("clock_sync", "c"));
3225 } 3289 }
3226 3290
3227 } // namespace trace_event 3291 } // namespace trace_event
3228 } // namespace base 3292 } // namespace base
OLDNEW
« base/trace_event/trace_event_impl.cc ('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