hunspell: Cleanup to fix the header include guards under google/ directory.
[chromium-blink-merge.git] / cc / base / unique_notifier.h
blob3cbc22a0a794ca8a96cfbe108ade054c27d5f0d3
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.
5 #ifndef CC_BASE_UNIQUE_NOTIFIER_H_
6 #define CC_BASE_UNIQUE_NOTIFIER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "cc/base/cc_export.h"
12 namespace base {
13 class SequencedTaskRunner;
14 } // namespace base
16 namespace cc {
18 class CC_EXPORT UniqueNotifier {
19 public:
20 // Configure this notifier to issue the |closure| notification when scheduled.
21 UniqueNotifier(base::SequencedTaskRunner* task_runner,
22 const base::Closure& closure);
24 // Destroying the notifier will ensure that no further notifications will
25 // happen from this class.
26 ~UniqueNotifier();
28 // Schedule a notification to be run. If another notification is already
29 // pending, then only one notification will take place.
30 void Schedule();
32 // Cancel a pending notification, if one was scheduled.
33 void Cancel();
35 private:
36 void Notify();
38 // TODO(dcheng): How come this doesn't need to hold a ref to the task runner?
39 base::SequencedTaskRunner* task_runner_;
40 base::Closure closure_;
41 bool notification_pending_;
43 base::WeakPtrFactory<UniqueNotifier> weak_ptr_factory_;
45 DISALLOW_COPY_AND_ASSIGN(UniqueNotifier);
48 } // namespace cc
50 #endif // CC_BASE_UNIQUE_NOTIFIER_H_