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

Side by Side Diff: base/timer_unittest.cc

Issue 552004: Style cleanup in preparation for auto-linting base/. (Closed)
Patch Set: Created 10 years, 11 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/timer.h ('k') | base/trace_event.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "base/task.h" 7 #include "base/task.h"
8 #include "base/timer.h" 8 #include "base/timer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 16 matching lines...) Expand all
27 *did_run_ = true; 27 *did_run_ = true;
28 MessageLoop::current()->Quit(); 28 MessageLoop::current()->Quit();
29 } 29 }
30 bool* did_run_; 30 bool* did_run_;
31 base::OneShotTimer<OneShotTimerTester> timer_; 31 base::OneShotTimer<OneShotTimerTester> timer_;
32 const unsigned delay_ms_; 32 const unsigned delay_ms_;
33 }; 33 };
34 34
35 class OneShotSelfDeletingTimerTester { 35 class OneShotSelfDeletingTimerTester {
36 public: 36 public:
37 OneShotSelfDeletingTimerTester(bool* did_run) : 37 explicit OneShotSelfDeletingTimerTester(bool* did_run) :
38 did_run_(did_run), 38 did_run_(did_run),
39 timer_(new base::OneShotTimer<OneShotSelfDeletingTimerTester>()) { 39 timer_(new base::OneShotTimer<OneShotSelfDeletingTimerTester>()) {
40 } 40 }
41 void Start() { 41 void Start() {
42 timer_->Start(TimeDelta::FromMilliseconds(10), this, 42 timer_->Start(TimeDelta::FromMilliseconds(10), this,
43 &OneShotSelfDeletingTimerTester::Run); 43 &OneShotSelfDeletingTimerTester::Run);
44 } 44 }
45 private: 45 private:
46 void Run() { 46 void Run() {
47 *did_run_ = true; 47 *did_run_ = true;
48 timer_.reset(); 48 timer_.reset();
49 MessageLoop::current()->Quit(); 49 MessageLoop::current()->Quit();
50 } 50 }
51 bool* did_run_; 51 bool* did_run_;
52 scoped_ptr<base::OneShotTimer<OneShotSelfDeletingTimerTester> > timer_; 52 scoped_ptr<base::OneShotTimer<OneShotSelfDeletingTimerTester> > timer_;
53 }; 53 };
54 54
55 class RepeatingTimerTester { 55 class RepeatingTimerTester {
56 public: 56 public:
57 RepeatingTimerTester(bool* did_run) : did_run_(did_run), counter_(10) { 57 explicit RepeatingTimerTester(bool* did_run)
58 : did_run_(did_run), counter_(10) {
58 } 59 }
60
59 void Start() { 61 void Start() {
60 timer_.Start(TimeDelta::FromMilliseconds(10), this, 62 timer_.Start(TimeDelta::FromMilliseconds(10), this,
61 &RepeatingTimerTester::Run); 63 &RepeatingTimerTester::Run);
62 } 64 }
63 private: 65 private:
64 void Run() { 66 void Run() {
65 if (--counter_ == 0) { 67 if (--counter_ == 0) {
66 *did_run_ = true; 68 *did_run_ = true;
67 MessageLoop::current()->Quit(); 69 MessageLoop::current()->Quit();
68 } 70 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 OneShotTimerTester d(&did_run); 346 OneShotTimerTester d(&did_run);
345 { 347 {
346 MessageLoop loop(MessageLoop::TYPE_DEFAULT); 348 MessageLoop loop(MessageLoop::TYPE_DEFAULT);
347 a.Start(); 349 a.Start();
348 b.Start(); 350 b.Start();
349 } // MessageLoop destructs by falling out of scope. 351 } // MessageLoop destructs by falling out of scope.
350 } // OneShotTimers destruct. SHOULD NOT CRASH, of course. 352 } // OneShotTimers destruct. SHOULD NOT CRASH, of course.
351 353
352 EXPECT_EQ(false, did_run); 354 EXPECT_EQ(false, did_run);
353 } 355 }
OLDNEW
« no previous file with comments | « base/timer.h ('k') | base/trace_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698