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

Side by Side Diff: base/threading/thread_collision_warner_unittest.cc

Issue 611153004: replace OVERRIDE and FINAL with override and final in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CC_ -> BASE_ Created 6 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 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/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/synchronization/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "base/threading/platform_thread.h" 8 #include "base/threading/platform_thread.h"
9 #include "base/threading/simple_thread.h" 9 #include "base/threading/simple_thread.h"
10 #include "base/threading/thread_collision_warner.h" 10 #include "base/threading/thread_collision_warner.h"
(...skipping 23 matching lines...) Expand all
34 namespace { 34 namespace {
35 35
36 // This is the asserter used with ThreadCollisionWarner instead of the default 36 // This is the asserter used with ThreadCollisionWarner instead of the default
37 // DCheckAsserter. The method fail_state is used to know if a collision took 37 // DCheckAsserter. The method fail_state is used to know if a collision took
38 // place. 38 // place.
39 class AssertReporter : public base::AsserterBase { 39 class AssertReporter : public base::AsserterBase {
40 public: 40 public:
41 AssertReporter() 41 AssertReporter()
42 : failed_(false) {} 42 : failed_(false) {}
43 43
44 virtual void warn() OVERRIDE { 44 virtual void warn() override {
45 failed_ = true; 45 failed_ = true;
46 } 46 }
47 47
48 virtual ~AssertReporter() {} 48 virtual ~AssertReporter() {}
49 49
50 bool fail_state() const { return failed_; } 50 bool fail_state() const { return failed_; }
51 void reset() { failed_ = false; } 51 void reset() { failed_ = false; }
52 52
53 private: 53 private:
54 bool failed_; 54 bool failed_;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 DFAKE_MUTEX(push_pop_); 144 DFAKE_MUTEX(push_pop_);
145 145
146 DISALLOW_COPY_AND_ASSIGN(NonThreadSafeQueue); 146 DISALLOW_COPY_AND_ASSIGN(NonThreadSafeQueue);
147 }; 147 };
148 148
149 class QueueUser : public base::DelegateSimpleThread::Delegate { 149 class QueueUser : public base::DelegateSimpleThread::Delegate {
150 public: 150 public:
151 explicit QueueUser(NonThreadSafeQueue& queue) 151 explicit QueueUser(NonThreadSafeQueue& queue)
152 : queue_(queue) {} 152 : queue_(queue) {}
153 153
154 virtual void Run() OVERRIDE { 154 virtual void Run() override {
155 queue_.push(0); 155 queue_.push(0);
156 queue_.pop(); 156 queue_.pop();
157 } 157 }
158 158
159 private: 159 private:
160 NonThreadSafeQueue& queue_; 160 NonThreadSafeQueue& queue_;
161 }; 161 };
162 162
163 AssertReporter* local_reporter = new AssertReporter(); 163 AssertReporter* local_reporter = new AssertReporter();
164 164
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 DFAKE_MUTEX(push_pop_); 202 DFAKE_MUTEX(push_pop_);
203 203
204 DISALLOW_COPY_AND_ASSIGN(NonThreadSafeQueue); 204 DISALLOW_COPY_AND_ASSIGN(NonThreadSafeQueue);
205 }; 205 };
206 206
207 class QueueUser : public base::DelegateSimpleThread::Delegate { 207 class QueueUser : public base::DelegateSimpleThread::Delegate {
208 public: 208 public:
209 explicit QueueUser(NonThreadSafeQueue& queue) 209 explicit QueueUser(NonThreadSafeQueue& queue)
210 : queue_(queue) {} 210 : queue_(queue) {}
211 211
212 virtual void Run() OVERRIDE { 212 virtual void Run() override {
213 queue_.push(0); 213 queue_.push(0);
214 queue_.pop(); 214 queue_.pop();
215 } 215 }
216 216
217 private: 217 private:
218 NonThreadSafeQueue& queue_; 218 NonThreadSafeQueue& queue_;
219 }; 219 };
220 220
221 AssertReporter* local_reporter = new AssertReporter(); 221 AssertReporter* local_reporter = new AssertReporter();
222 222
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 }; 263 };
264 264
265 // This time the QueueUser class protects the non thread safe queue with 265 // This time the QueueUser class protects the non thread safe queue with
266 // a lock. 266 // a lock.
267 class QueueUser : public base::DelegateSimpleThread::Delegate { 267 class QueueUser : public base::DelegateSimpleThread::Delegate {
268 public: 268 public:
269 QueueUser(NonThreadSafeQueue& queue, base::Lock& lock) 269 QueueUser(NonThreadSafeQueue& queue, base::Lock& lock)
270 : queue_(queue), 270 : queue_(queue),
271 lock_(lock) {} 271 lock_(lock) {}
272 272
273 virtual void Run() OVERRIDE { 273 virtual void Run() override {
274 { 274 {
275 base::AutoLock auto_lock(lock_); 275 base::AutoLock auto_lock(lock_);
276 queue_.push(0); 276 queue_.push(0);
277 } 277 }
278 { 278 {
279 base::AutoLock auto_lock(lock_); 279 base::AutoLock auto_lock(lock_);
280 queue_.pop(); 280 queue_.pop();
281 } 281 }
282 } 282 }
283 private: 283 private:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 }; 337 };
338 338
339 // This time the QueueUser class protects the non thread safe queue with 339 // This time the QueueUser class protects the non thread safe queue with
340 // a lock. 340 // a lock.
341 class QueueUser : public base::DelegateSimpleThread::Delegate { 341 class QueueUser : public base::DelegateSimpleThread::Delegate {
342 public: 342 public:
343 QueueUser(NonThreadSafeQueue& queue, base::Lock& lock) 343 QueueUser(NonThreadSafeQueue& queue, base::Lock& lock)
344 : queue_(queue), 344 : queue_(queue),
345 lock_(lock) {} 345 lock_(lock) {}
346 346
347 virtual void Run() OVERRIDE { 347 virtual void Run() override {
348 { 348 {
349 base::AutoLock auto_lock(lock_); 349 base::AutoLock auto_lock(lock_);
350 queue_.push(0); 350 queue_.push(0);
351 } 351 }
352 { 352 {
353 base::AutoLock auto_lock(lock_); 353 base::AutoLock auto_lock(lock_);
354 queue_.bar(); 354 queue_.bar();
355 } 355 }
356 { 356 {
357 base::AutoLock auto_lock(lock_); 357 base::AutoLock auto_lock(lock_);
(...skipping 18 matching lines...) Expand all
376 base::DelegateSimpleThread thread_b(&queue_user_b, "queue_user_thread_b"); 376 base::DelegateSimpleThread thread_b(&queue_user_b, "queue_user_thread_b");
377 377
378 thread_a.Start(); 378 thread_a.Start();
379 thread_b.Start(); 379 thread_b.Start();
380 380
381 thread_a.Join(); 381 thread_a.Join();
382 thread_b.Join(); 382 thread_b.Join();
383 383
384 EXPECT_FALSE(local_reporter->fail_state()); 384 EXPECT_FALSE(local_reporter->fail_state());
385 } 385 }
OLDNEW
« no previous file with comments | « base/threading/thread_collision_warner.h ('k') | base/threading/thread_local_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698