| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // CancelableCallback is a wrapper around base::Callback that allows | 5 // CancelableCallback is a wrapper around base::Callback that allows |
| 6 // cancellation of a callback. CancelableCallback takes a reference on the | 6 // cancellation of a callback. CancelableCallback takes a reference on the |
| 7 // wrapped callback until this object is destroyed or Reset()/Cancel() are | 7 // wrapped callback until this object is destroyed or Reset()/Cancel() are |
| 8 // called. | 8 // called. |
| 9 // | 9 // |
| 10 // NOTE: | 10 // NOTE: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // CancelableClosure timeout(base::Bind(&TimeoutCallback, "Test timed out.")); | 34 // CancelableClosure timeout(base::Bind(&TimeoutCallback, "Test timed out.")); |
| 35 // MessageLoop::current()->PostDelayedTask(FROM_HERE, timeout.callback(), | 35 // MessageLoop::current()->PostDelayedTask(FROM_HERE, timeout.callback(), |
| 36 // 4000) // 4 seconds to run. | 36 // 4000) // 4 seconds to run. |
| 37 // RunIntensiveTest(); | 37 // RunIntensiveTest(); |
| 38 // MessageLoop::current()->Run(); | 38 // MessageLoop::current()->Run(); |
| 39 // timeout.Cancel(); // Hopefully this is hit before the timeout callback runs. | 39 // timeout.Cancel(); // Hopefully this is hit before the timeout callback runs. |
| 40 // | 40 // |
| 41 | 41 |
| 42 #ifndef BASE_CANCELABLE_CALLBACK_H_ | 42 #ifndef BASE_CANCELABLE_CALLBACK_H_ |
| 43 #define BASE_CANCELABLE_CALLBACK_H_ | 43 #define BASE_CANCELABLE_CALLBACK_H_ |
| 44 #pragma once | |
| 45 | 44 |
| 46 #include "base/base_export.h" | 45 #include "base/base_export.h" |
| 47 #include "base/bind.h" | 46 #include "base/bind.h" |
| 48 #include "base/callback.h" | 47 #include "base/callback.h" |
| 49 #include "base/callback_internal.h" | 48 #include "base/callback_internal.h" |
| 50 #include "base/compiler_specific.h" | 49 #include "base/compiler_specific.h" |
| 51 #include "base/logging.h" | 50 #include "base/logging.h" |
| 52 #include "base/memory/weak_ptr.h" | 51 #include "base/memory/weak_ptr.h" |
| 53 | 52 |
| 54 namespace base { | 53 namespace base { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 base::Callback<void(A1)> callback_; | 193 base::Callback<void(A1)> callback_; |
| 195 | 194 |
| 196 DISALLOW_COPY_AND_ASSIGN(CancelableCallback); | 195 DISALLOW_COPY_AND_ASSIGN(CancelableCallback); |
| 197 }; | 196 }; |
| 198 | 197 |
| 199 typedef CancelableCallback<void(void)> CancelableClosure; | 198 typedef CancelableCallback<void(void)> CancelableClosure; |
| 200 | 199 |
| 201 } // namespace base | 200 } // namespace base |
| 202 | 201 |
| 203 #endif // BASE_CANCELABLE_CALLBACK_H_ | 202 #endif // BASE_CANCELABLE_CALLBACK_H_ |
| OLD | NEW |