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

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

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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 | « cc/base/unique_notifier.h ('k') | cc/base/unique_notifier_unittest.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 #include "cc/base/unique_notifier.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/location.h"
10 #include "base/sequenced_task_runner.h"
11
12 namespace cc {
13
14 UniqueNotifier::UniqueNotifier(base::SequencedTaskRunner* task_runner,
15 const base::Closure& closure)
16 : task_runner_(task_runner),
17 closure_(closure),
18 notification_pending_(false),
19 weak_ptr_factory_(this) {
20 }
21
22 UniqueNotifier::~UniqueNotifier() {
23 }
24
25 void UniqueNotifier::Schedule() {
26 if (notification_pending_)
27 return;
28
29 task_runner_->PostTask(
30 FROM_HERE,
31 base::Bind(&UniqueNotifier::Notify, weak_ptr_factory_.GetWeakPtr()));
32 notification_pending_ = true;
33 }
34
35 void UniqueNotifier::Notify() {
36 // Note that the order here is important in case closure schedules another
37 // run.
38 notification_pending_ = false;
39 closure_.Run();
40 }
41
42 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/unique_notifier.h ('k') | cc/base/unique_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698