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

Side by Side Diff: chrome/common/cancelable_task_tracker.h

Issue 11417077: Rewrite CancelableTaskTracker unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/cancelable_task_tracker.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 TaskRunner, 5 // CancelableTaskTracker posts tasks (in the form of a Closure) to a TaskRunner,
6 // and is able to cancel the task later if it's not needed anymore. On 6 // and is able to cancel the task later if it's not needed anymore. On
7 // destruction, CancelableTaskTracker will cancel all tracked tasks. 7 // destruction, CancelableTaskTracker will cancel all tracked tasks.
8 // 8 //
9 // Each cancelable task can be associated with a reply (also a Closure). After 9 // Each cancelable task can be associated with a reply (also a Closure). After
10 // the task is run on the TaskRunner, |reply| will be posted back to originating 10 // the task is run on the TaskRunner, |reply| will be posted back to originating
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 const tracked_objects::Location& from_here, 66 const tracked_objects::Location& from_here,
67 const base::Closure& task); 67 const base::Closure& task);
68 68
69 TaskId PostTaskAndReply(base::TaskRunner* task_runner, 69 TaskId PostTaskAndReply(base::TaskRunner* task_runner,
70 const tracked_objects::Location& from_here, 70 const tracked_objects::Location& from_here,
71 const base::Closure& task, 71 const base::Closure& task,
72 const base::Closure& reply); 72 const base::Closure& reply);
73 73
74 // Creates a tracked TaskId and an associated IsCanceledCallback. Client can 74 // Creates a tracked TaskId and an associated IsCanceledCallback. Client can
75 // later call TryCancel() with the returned TaskId, and run |is_canceled_cb| 75 // later call TryCancel() with the returned TaskId, and run |is_canceled_cb|
76 // to check whether the TaskId is canceled. 76 // from any thread to check whether the TaskId is canceled.
77 // 77 //
78 // Note. This function is used to address some special cancelation requirement 78 // Note. This function is used to address some special cancelation requirement
79 // in existing code. You SHOULD NOT need this function in new code. 79 // in existing code. You SHOULD NOT need this function in new code.
80 TaskId NewTrackedTaskId(IsCanceledCallback* is_canceled_cb); 80 TaskId NewTrackedTaskId(IsCanceledCallback* is_canceled_cb);
81 81
82 // After calling this function, |task| and |reply| will not run. If the 82 // After calling this function, |task| and |reply| will not run. If the
83 // cancelation happens when |task| is running or has finished running, |reply| 83 // cancelation happens when |task| is running or has finished running, |reply|
84 // will not run. If |reply| is running or has finished running, cancellation 84 // will not run. If |reply| is running or has finished running, cancellation
85 // is a noop. 85 // is a noop.
86 // 86 //
(...skipping 12 matching lines...) Expand all
99 base::hash_map<TaskId, base::CancellationFlag*> task_flags_; 99 base::hash_map<TaskId, base::CancellationFlag*> task_flags_;
100 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_; 100 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_;
101 101
102 TaskId next_id_; 102 TaskId next_id_;
103 base::ThreadChecker thread_checker_; 103 base::ThreadChecker thread_checker_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker); 105 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker);
106 }; 106 };
107 107
108 #endif // CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_ 108 #endif // CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/common/cancelable_task_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698