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

Side by Side Diff: chrome/test/remoting/waiter.h

Issue 1355063004: Template methods on Timer classes instead of the classes themselves. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: timer: fixcaller Created 5 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
« no previous file with comments | « chrome/test/base/tracing.cc ('k') | chromeos/audio/cras_audio_handler.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_TEST_REMOTING_WAITER_H_ 5 #ifndef CHROME_TEST_REMOTING_WAITER_H_
6 #define CHROME_TEST_REMOTING_WAITER_H_ 6 #define CHROME_TEST_REMOTING_WAITER_H_
7 7
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 15 matching lines...) Expand all
26 // For TimeoutWaiter it should always be true. 26 // For TimeoutWaiter it should always be true.
27 virtual bool Wait(); 27 virtual bool Wait();
28 28
29 protected: 29 protected:
30 virtual void CancelWait(); 30 virtual void CancelWait();
31 31
32 private: 32 private:
33 // Callback used to cancel the TimeoutWaiter::Wait. 33 // Callback used to cancel the TimeoutWaiter::Wait.
34 void CancelWaitCallback(); 34 void CancelWaitCallback();
35 35
36 base::OneShotTimer<TimeoutWaiter> timeout_timer_; 36 base::OneShotTimer timeout_timer_;
37 base::TimeDelta timeout_; 37 base::TimeDelta timeout_;
38 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 38 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
39 39
40 DISALLOW_COPY_AND_ASSIGN(TimeoutWaiter); 40 DISALLOW_COPY_AND_ASSIGN(TimeoutWaiter);
41 }; 41 };
42 42
43 // With a message loop running, keep calling callback in the specified 43 // With a message loop running, keep calling callback in the specified
44 // interval until true is returned. 44 // interval until true is returned.
45 class ConditionalTimeoutWaiter : public TimeoutWaiter { 45 class ConditionalTimeoutWaiter : public TimeoutWaiter {
46 public: 46 public:
47 typedef base::Callback<bool(void)> Predicate; 47 typedef base::Callback<bool(void)> Predicate;
48 48
49 ConditionalTimeoutWaiter(base::TimeDelta timeout, 49 ConditionalTimeoutWaiter(base::TimeDelta timeout,
50 base::TimeDelta interval, 50 base::TimeDelta interval,
51 const Predicate& callback); 51 const Predicate& callback);
52 ~ConditionalTimeoutWaiter() override; 52 ~ConditionalTimeoutWaiter() override;
53 53
54 // Returns true if |callback_| returned true and false in case of timeout. 54 // Returns true if |callback_| returned true and false in case of timeout.
55 bool Wait() override; 55 bool Wait() override;
56 56
57 protected: 57 protected:
58 void CancelWait() override; 58 void CancelWait() override;
59 59
60 private: 60 private:
61 // Callback used to cancel the ConditionalTimeoutWaiter::Wait. 61 // Callback used to cancel the ConditionalTimeoutWaiter::Wait.
62 void CancelWaitCallback(); 62 void CancelWaitCallback();
63 63
64 base::TimeDelta interval_; 64 base::TimeDelta interval_;
65 Predicate callback_; 65 Predicate callback_;
66 base::RepeatingTimer<ConditionalTimeoutWaiter> condition_timer_; 66 base::RepeatingTimer condition_timer_;
67 bool success_; 67 bool success_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(ConditionalTimeoutWaiter); 69 DISALLOW_COPY_AND_ASSIGN(ConditionalTimeoutWaiter);
70 }; 70 };
71 71
72 } // namespace remoting 72 } // namespace remoting
73 73
74 #endif // CHROME_TEST_REMOTING_WAITER_H_ 74 #endif // CHROME_TEST_REMOTING_WAITER_H_
OLDNEW
« no previous file with comments | « chrome/test/base/tracing.cc ('k') | chromeos/audio/cras_audio_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698