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

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

Issue 2791243002: Rewrite base::Bind into base::BindOnce on trivial cases in base (Closed)
Patch Set: rebase Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <string.h> 5 #include <string.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 const int kNumThreads = 32; 123 const int kNumThreads = 32;
124 std::unique_ptr<Thread> threads[kNumThreads]; 124 std::unique_ptr<Thread> threads[kNumThreads];
125 for (int i = 0; i < kNumThreads; i++) { 125 for (int i = 0; i < kNumThreads; i++) {
126 threads[i].reset(new Thread("test thread")); 126 threads[i].reset(new Thread("test thread"));
127 threads[i]->Start(); 127 threads[i]->Start();
128 } 128 }
129 WaitableEvent sync_event(WaitableEvent::ResetPolicy::MANUAL, 129 WaitableEvent sync_event(WaitableEvent::ResetPolicy::MANUAL,
130 WaitableEvent::InitialState::NOT_SIGNALED); 130 WaitableEvent::InitialState::NOT_SIGNALED);
131 for (int i = 0; i < kNumThreads; i++) { 131 for (int i = 0; i < kNumThreads; i++) {
132 threads[i]->task_runner()->PostTask( 132 threads[i]->task_runner()->PostTask(
133 FROM_HERE, Bind(&TestRaceThreadMain, Unretained(&sync_event))); 133 FROM_HERE, BindOnce(&TestRaceThreadMain, Unretained(&sync_event)));
134 } 134 }
135 sync_event.Signal(); 135 sync_event.Signal();
136 for (int i = 0; i < kNumThreads; i++) 136 for (int i = 0; i < kNumThreads; i++)
137 threads[i]->Stop(); 137 threads[i]->Stop();
138 138
139 int num_times_seen = 0; 139 int num_times_seen = 0;
140 for (const TraceCategory& cat : GetAllCategories()) { 140 for (const TraceCategory& cat : GetAllCategories()) {
141 if (strcmp(cat.name(), "__test_race") == 0) 141 if (strcmp(cat.name(), "__test_race") == 0)
142 num_times_seen++; 142 num_times_seen++;
143 } 143 }
144 ASSERT_EQ(1, num_times_seen); 144 ASSERT_EQ(1, num_times_seen);
145 } 145 }
146 146
147 } // namespace trace_event 147 } // namespace trace_event
148 } // namespace base 148 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_scheduler.cc ('k') | base/trace_event/trace_event_system_stats_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698