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

Side by Side Diff: base/task/cancelable_task_tracker.h

Issue 2672753002: Refactor History's CommitLaterTask with CancelableCallback (Closed)
Patch Set: Remove leftover friendship. Created 3 years, 10 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
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 // CancelableTaskTracker posts tasks (in the form of a Closure) to a 5 // CancelableTaskTracker posts tasks (in the form of a Closure) to a
6 // TaskRunner, and is able to cancel the task later if it's not needed 6 // TaskRunner, and is able to cancel the task later if it's not needed
7 // anymore. On destruction, CancelableTaskTracker will cancel all 7 // anymore. On destruction, CancelableTaskTracker will cancel all
8 // tracked tasks. 8 // tracked tasks.
9 // 9 //
10 // Each cancelable task can be associated with a reply (also a Closure). After 10 // Each cancelable task can be associated with a reply (also a Closure). After
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 task_runner, 88 task_runner,
89 from_here, 89 from_here,
90 base::Bind(&base::internal::ReturnAsParamAdapter<TaskReturnType>, 90 base::Bind(&base::internal::ReturnAsParamAdapter<TaskReturnType>,
91 task, 91 task,
92 base::Unretained(result)), 92 base::Unretained(result)),
93 base::Bind(&base::internal::ReplyAdapter<TaskReturnType, ReplyArgType>, 93 base::Bind(&base::internal::ReplyAdapter<TaskReturnType, ReplyArgType>,
94 reply, 94 reply,
95 base::Owned(result))); 95 base::Owned(result)));
96 } 96 }
97 97
98 TaskId PostDelayedTask(base::TaskRunner* task_runner,
99 const tracked_objects::Location& from_here,
100 const base::Closure& task,
101 base::TimeDelta delay);
102
98 // Creates a tracked TaskId and an associated IsCanceledCallback. Client can 103 // Creates a tracked TaskId and an associated IsCanceledCallback. Client can
99 // later call TryCancel() with the returned TaskId, and run |is_canceled_cb| 104 // later call TryCancel() with the returned TaskId, and run |is_canceled_cb|
100 // from any thread to check whether the TaskId is canceled. 105 // from any thread to check whether the TaskId is canceled.
101 // 106 //
102 // The returned task ID is tracked until the last copy of 107 // The returned task ID is tracked until the last copy of
103 // |is_canceled_cb| is destroyed. 108 // |is_canceled_cb| is destroyed.
104 // 109 //
105 // Note. This function is used to address some special cancelation requirement 110 // Note. This function is used to address some special cancelation requirement
106 // in existing code. You SHOULD NOT need this function in new code. 111 // in existing code. You SHOULD NOT need this function in new code.
107 TaskId NewTrackedTaskId(IsCanceledCallback* is_canceled_cb); 112 TaskId NewTrackedTaskId(IsCanceledCallback* is_canceled_cb);
(...skipping 25 matching lines...) Expand all
133 SequenceChecker sequence_checker_; 138 SequenceChecker sequence_checker_;
134 139
135 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_; 140 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_;
136 141
137 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker); 142 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker);
138 }; 143 };
139 144
140 } // namespace base 145 } // namespace base
141 146
142 #endif // BASE_TASK_CANCELABLE_TASK_TRACKER_H_ 147 #endif // BASE_TASK_CANCELABLE_TASK_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | base/task/cancelable_task_tracker.cc » ('j') | base/task/cancelable_task_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698