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

Side by Side Diff: cc/base/delayed_unique_notifier.h

Issue 296043005: cc: Add UniqueNotifier to cc/base. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/base/delayed_unique_notifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_BASE_DELAYED_UNIQUE_NOTIFIER_H_
6 #define CC_BASE_DELAYED_UNIQUE_NOTIFIER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "cc/base/cc_export.h"
11
12 namespace base {
13 class SequencedTaskRunner;
14 } // namespace base
15
16 namespace cc {
17
18 class CC_EXPORT DelayedUniqueNotifier {
19 public:
20 // Configure this notifier to issue the |closure| notification in |delay| time
21 // from Schedule() call.
22 DelayedUniqueNotifier(base::SequencedTaskRunner* task_runner,
23 const base::Closure& closure,
24 const base::TimeDelta& delay);
25
26 // Destroying the notifier will ensure that no further notifications will
27 // happen from this class.
28 virtual ~DelayedUniqueNotifier();
29
30 // Schedule a notification to be run. If another notification is already
31 // pending, then it will happen in (at least) given delay from now. That is,
32 // if delay is 16ms and a notification has been scheduled 10ms ago (ie, it
33 // should trigger in no less than 6ms), then calling schedule will ensure that
34 // the only notification that arrives will happen in (at least) 16ms from now.
35 void Schedule();
36
37 // Cancel any previously scheduled runs.
38 void Cancel();
39
40 protected:
41 // Virtual for testing.
42 virtual base::TimeTicks Now() const;
43
44 private:
45 void NotifyIfTime();
46
47 base::SequencedTaskRunner* task_runner_;
48 base::Closure closure_;
49 base::TimeDelta delay_;
50 base::TimeTicks next_notification_time_;
51 bool notification_pending_;
52
53 base::WeakPtrFactory<DelayedUniqueNotifier> weak_ptr_factory_;
54 };
55
56 } // namespace cc
57
58 #endif // CC_BASE_DELAYED_UNIQUE_NOTIFIER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/base/delayed_unique_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698