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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 28593003: Avoid threading races on TraceSamplingThread's members (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed races on WaitableEvent Created 7 years, 2 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
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | tools/valgrind/tsan_v2/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_unittest.cc
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 8ee0884f7034e2e0e1d56ad4166dbb034dbd38df..2cfa805cfcdd1c715d03438137683f71b01d5428 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -1756,13 +1756,10 @@ TEST_F(TraceEventTestFixture, TraceSampling) {
TraceLog::Options(TraceLog::RECORD_UNTIL_FULL |
TraceLog::ENABLE_SAMPLING));
- WaitableEvent* sampled = new WaitableEvent(false, false);
- TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(sampled);
-
TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Stuff");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Things");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
EndTraceAndFlush();
@@ -1778,32 +1775,29 @@ TEST_F(TraceEventTestFixture, TraceSamplingScope) {
TraceLog::Options(TraceLog::RECORD_UNTIL_FULL |
TraceLog::ENABLE_SAMPLING));
- WaitableEvent* sampled = new WaitableEvent(false, false);
- TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(sampled);
-
TRACE_EVENT_SCOPED_SAMPLING_STATE("AAA", "name");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
{
EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA");
TRACE_EVENT_SCOPED_SAMPLING_STATE("BBB", "name");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "BBB");
}
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
{
EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA");
TRACE_EVENT_SCOPED_SAMPLING_STATE("CCC", "name");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "CCC");
}
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
{
EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA");
TRACE_EVENT_SET_SAMPLING_STATE("DDD", "name");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD");
}
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD");
EndTraceAndFlush();
@@ -1815,14 +1809,10 @@ TEST_F(TraceEventTestFixture, TraceContinuousSampling) {
CategoryFilter("*"),
TraceLog::Options(TraceLog::MONITOR_SAMPLING));
- WaitableEvent* sampled = new WaitableEvent(false, false);
- TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(
- sampled);
-
TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "AAA");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "BBB");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
FlushMonitoring();
@@ -1831,12 +1821,12 @@ TEST_F(TraceEventTestFixture, TraceContinuousSampling) {
EXPECT_TRUE(FindNamePhase("BBB", "P"));
Clear();
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "CCC");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "DDD");
- sampled->Wait();
+ TraceLog::GetInstance()->WaitSamplingEventForTesting();
FlushMonitoring();
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | tools/valgrind/tsan_v2/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698