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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/delayed_unique_notifier.h ('k') | cc/base/delayed_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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #include "cc/base/delayed_unique_notifier.h" 5 #include "cc/base/delayed_unique_notifier.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 25 matching lines...) Expand all
36 base::Bind(&DelayedUniqueNotifier::NotifyIfTime, 36 base::Bind(&DelayedUniqueNotifier::NotifyIfTime,
37 weak_ptr_factory_.GetWeakPtr()), 37 weak_ptr_factory_.GetWeakPtr()),
38 delay_); 38 delay_);
39 notification_pending_ = true; 39 notification_pending_ = true;
40 } 40 }
41 41
42 void DelayedUniqueNotifier::Cancel() { 42 void DelayedUniqueNotifier::Cancel() {
43 next_notification_time_ = base::TimeTicks(); 43 next_notification_time_ = base::TimeTicks();
44 } 44 }
45 45
46 void DelayedUniqueNotifier::Shutdown() {
47 // This function must destroy any weak ptrs since after being cancelled, this
48 // class may be destroyed on another thread during compositor shutdown.
49 weak_ptr_factory_.InvalidateWeakPtrs();
50 // Deliberately leaves notification_pending_ = true forever so new tasks with
51 // weak ptrs can not be created.
52 notification_pending_ = true;
53 }
54
46 bool DelayedUniqueNotifier::HasPendingNotification() const { 55 bool DelayedUniqueNotifier::HasPendingNotification() const {
47 return notification_pending_ && !next_notification_time_.is_null(); 56 return notification_pending_ && !next_notification_time_.is_null();
48 } 57 }
49 58
50 base::TimeTicks DelayedUniqueNotifier::Now() const { 59 base::TimeTicks DelayedUniqueNotifier::Now() const {
51 return base::TimeTicks::Now(); 60 return base::TimeTicks::Now();
52 } 61 }
53 62
54 void DelayedUniqueNotifier::NotifyIfTime() { 63 void DelayedUniqueNotifier::NotifyIfTime() {
55 // If next notifiaction time is not valid, then this schedule was canceled. 64 // If next notifiaction time is not valid, then this schedule was canceled.
(...skipping 13 matching lines...) Expand all
69 next_notification_time_ - now); 78 next_notification_time_ - now);
70 return; 79 return;
71 } 80 }
72 81
73 // Note the order here is important since closure might schedule another run. 82 // Note the order here is important since closure might schedule another run.
74 notification_pending_ = false; 83 notification_pending_ = false;
75 closure_.Run(); 84 closure_.Run();
76 } 85 }
77 86
78 } // namespace cc 87 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/delayed_unique_notifier.h ('k') | cc/base/delayed_unique_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698