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

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

Issue 296043005: cc: Add UniqueNotifier to cc/base. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo Created 6 years, 7 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/unique_notifier.cc » ('j') | cc/base/unique_notifier.cc » ('J')
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_UNIQUE_NOTIFIER_H_
6 #define CC_BASE_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 UniqueNotifier {
19 public:
20 // Configure this notifier to issue the |closure| notification in |delay| time
21 // from Schedule() call. Note that 0 delay is also acceptable, which will post
22 // the task to be run as soon as possible.
23 UniqueNotifier(const scoped_refptr<base::SequencedTaskRunner>& task_runner,
reveman 2014/05/21 17:03:37 no need to pass ownership here, base::SequencedTas
vmpstr 2014/05/21 17:41:02 Done.
24 const base::Closure& closure,
25 const base::TimeDelta& delay);
reveman 2014/05/21 17:03:37 I would prefer if we had two classes (UniqueNotifi
vmpstr 2014/05/21 17:41:02 I don't think deriving from each other would make
26
27 // Destroying the notifier will ensure that no further notifications will
28 // happen from this class.
29 ~UniqueNotifier();
30
31 // Schedule a notification to be run. If another notification is already
32 // pending, then it will happen in given delay from now. That is, if delay is
33 // 16ms and a notification has been scheduled 10ms ago (ie, it should trigger
34 // in 6ms), then calling schedule will ensure that the only notification that
35 // arrives will happen in 16ms from now.
36 void Schedule();
37
38 private:
39 void NotifyIfTime();
40
41 scoped_refptr<base::SequencedTaskRunner> task_runner_;
42 base::Closure closure_;
43 base::TimeDelta delay_;
44 base::TimeTicks next_notification_time_;
45 bool notification_pending_;
46
47 base::WeakPtrFactory<UniqueNotifier> weak_ptr_factory_;
48 };
49
50 } // namespace cc
51
52 #endif // CC_BASE_UNIQUE_NOTIFIER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/base/unique_notifier.cc » ('j') | cc/base/unique_notifier.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698