| OLD | NEW |
| 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 "base/task/cancelable_task_tracker.h" | 5 #include "base/task/cancelable_task_tracker.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 namespace base { | 57 namespace base { |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 const CancelableTaskTracker::TaskId CancelableTaskTracker::kBadTaskId = 0; | 60 const CancelableTaskTracker::TaskId CancelableTaskTracker::kBadTaskId = 0; |
| 61 | 61 |
| 62 CancelableTaskTracker::CancelableTaskTracker() | 62 CancelableTaskTracker::CancelableTaskTracker() |
| 63 : weak_factory_(this), next_id_(1) {} | 63 : next_id_(1),weak_factory_(this) {} |
| 64 | 64 |
| 65 CancelableTaskTracker::~CancelableTaskTracker() { | 65 CancelableTaskTracker::~CancelableTaskTracker() { |
| 66 DCHECK(thread_checker_.CalledOnValidThread()); | 66 DCHECK(thread_checker_.CalledOnValidThread()); |
| 67 | 67 |
| 68 TryCancelAll(); | 68 TryCancelAll(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 CancelableTaskTracker::TaskId CancelableTaskTracker::PostTask( | 71 CancelableTaskTracker::TaskId CancelableTaskTracker::PostTask( |
| 72 TaskRunner* task_runner, | 72 TaskRunner* task_runner, |
| 73 const tracked_objects::Location& from_here, | 73 const tracked_objects::Location& from_here, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 DCHECK(success); | 178 DCHECK(success); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void CancelableTaskTracker::Untrack(TaskId id) { | 181 void CancelableTaskTracker::Untrack(TaskId id) { |
| 182 DCHECK(thread_checker_.CalledOnValidThread()); | 182 DCHECK(thread_checker_.CalledOnValidThread()); |
| 183 size_t num = task_flags_.erase(id); | 183 size_t num = task_flags_.erase(id); |
| 184 DCHECK_EQ(1u, num); | 184 DCHECK_EQ(1u, num); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace base | 187 } // namespace base |
| OLD | NEW |