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

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: versioning the id field Created 4 years, 3 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
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 TRACE_EVENT_SCOPED_CONTEXT("disabled-by-default-cat", 516 TRACE_EVENT_SCOPED_CONTEXT("disabled-by-default-cat",
517 "TRACE_EVENT_SCOPED_CONTEXT disabled call", 517 "TRACE_EVENT_SCOPED_CONTEXT disabled call",
518 context_id); 518 context_id);
519 TRACE_EVENT_SCOPED_CONTEXT("all", "TRACE_EVENT_SCOPED_CONTEXT call", 519 TRACE_EVENT_SCOPED_CONTEXT("all", "TRACE_EVENT_SCOPED_CONTEXT call",
520 context_id); 520 context_id);
521 521
522 TRACE_BIND_IDS("all", "TRACE_BIND_IDS simple call", 0x1000, 0x2000); 522 TRACE_BIND_IDS("all", "TRACE_BIND_IDS simple call", 0x1000, 0x2000);
523 TRACE_BIND_IDS("all", "TRACE_BIND_IDS scoped call", 523 TRACE_BIND_IDS("all", "TRACE_BIND_IDS scoped call",
524 TRACE_ID_WITH_SCOPE("scope 1", 0x1000), 524 TRACE_ID_WITH_SCOPE("scope 1", 0x1000),
525 TRACE_ID_WITH_SCOPE("scope 2", 0x2000)); 525 TRACE_ID_WITH_SCOPE("scope 2", 0x2000));
526
527 TRACE_EVENT_ASYNC_BEGIN0("all", "async default process scope", 0x1000);
528 TRACE_EVENT_ASYNC_BEGIN0("all", "async local id", TRACE_ID_LOCAL(0x2000));
529 TRACE_EVENT_ASYNC_BEGIN0("all", "async global id", TRACE_ID_GLOBAL(0x3000));
530 TRACE_EVENT_ASYNC_BEGIN0("all", "async global id with scope string",
531 TRACE_ID_WITH_SCOPE("scope string",
532 TRACE_ID_GLOBAL(0x4000)));
526 } // Scope close causes TRACE_EVENT0 etc to send their END events. 533 } // Scope close causes TRACE_EVENT0 etc to send their END events.
527 534
528 if (task_complete_event) 535 if (task_complete_event)
529 task_complete_event->Signal(); 536 task_complete_event->Signal();
530 } 537 }
531 538
532 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { 539 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) {
533 const DictionaryValue* item = NULL; 540 const DictionaryValue* item = NULL;
534 541
535 #define EXPECT_FIND_(string) \ 542 #define EXPECT_FIND_(string) \
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 EXPECT_EQ("0x1000", id); 1002 EXPECT_EQ("0x1000", id);
996 1003
997 std::string bind_scope; 1004 std::string bind_scope;
998 EXPECT_TRUE((item && item->GetString("args.bind_scope", &bind_scope))); 1005 EXPECT_TRUE((item && item->GetString("args.bind_scope", &bind_scope)));
999 EXPECT_EQ("scope 2", bind_scope); 1006 EXPECT_EQ("scope 2", bind_scope);
1000 std::string bind_id; 1007 std::string bind_id;
1001 EXPECT_TRUE((item && item->GetString("bind_id", &id))); 1008 EXPECT_TRUE((item && item->GetString("bind_id", &id)));
1002 EXPECT_EQ("0x2000", id); 1009 EXPECT_EQ("0x2000", id);
1003 } 1010 }
1004 1011
1012 EXPECT_FIND_("async default process scope");
1013 {
1014 std::string ph;
1015 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1016 EXPECT_EQ("S", ph);
1017
1018 std::string id;
1019 EXPECT_TRUE((item && item->GetString("id", &id)));
1020 EXPECT_EQ("0x1000", id);
1021 }
1022
1023 EXPECT_FIND_("async local id");
1024 {
1025 std::string ph;
1026 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1027 EXPECT_EQ("S", ph);
1028
1029 std::string id;
1030 EXPECT_TRUE((item && item->GetString("id2.local", &id)));
1031 EXPECT_EQ("0x2000", id);
1032 }
1033
1034 EXPECT_FIND_("async global id");
1035 {
1036 std::string ph;
1037 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1038 EXPECT_EQ("S", ph);
1039
1040 std::string id;
1041 EXPECT_TRUE((item && item->GetString("id2.global", &id)));
1042 EXPECT_EQ("0x3000", id);
1043 }
1044
1045 EXPECT_FIND_("async global id with scope string");
1046 {
1047 std::string ph;
1048 EXPECT_TRUE((item && item->GetString("ph", &ph)));
1049 EXPECT_EQ("S", ph);
1050
1051 std::string id;
1052 EXPECT_TRUE((item && item->GetString("id2.global", &id)));
1053 EXPECT_EQ("0x4000", id);
1054 std::string scope;
1055 EXPECT_TRUE((item && item->GetString("scope", &scope)));
1056 EXPECT_EQ("scope string", scope);
1057 }
1005 } 1058 }
1006 1059
1007 void TraceManyInstantEvents(int thread_id, int num_events, 1060 void TraceManyInstantEvents(int thread_id, int num_events,
1008 WaitableEvent* task_complete_event) { 1061 WaitableEvent* task_complete_event) {
1009 for (int i = 0; i < num_events; i++) { 1062 for (int i = 0; i < num_events; i++) {
1010 TRACE_EVENT_INSTANT2("all", "multi thread event", 1063 TRACE_EVENT_INSTANT2("all", "multi thread event",
1011 TRACE_EVENT_SCOPE_THREAD, 1064 TRACE_EVENT_SCOPE_THREAD,
1012 "thread", thread_id, 1065 "thread", thread_id,
1013 "event", i); 1066 "event", i);
1014 } 1067 }
(...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 3401
3349 TEST_F(TraceEventTestFixture, ClockSyncEventsAreAlwaysAddedToTrace) { 3402 TEST_F(TraceEventTestFixture, ClockSyncEventsAreAlwaysAddedToTrace) {
3350 BeginSpecificTrace("-*"); 3403 BeginSpecificTrace("-*");
3351 TRACE_EVENT_CLOCK_SYNC_RECEIVER(1); 3404 TRACE_EVENT_CLOCK_SYNC_RECEIVER(1);
3352 EndTraceAndFlush(); 3405 EndTraceAndFlush();
3353 EXPECT_TRUE(FindNamePhase("clock_sync", "c")); 3406 EXPECT_TRUE(FindNamePhase("clock_sync", "c"));
3354 } 3407 }
3355 3408
3356 } // namespace trace_event 3409 } // namespace trace_event
3357 } // namespace base 3410 } // namespace base
OLDNEW
« no previous file with comments | « 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