| OLD | NEW |
| 1 // Copyright (c) 2009 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 #ifndef BASE_TASK_H_ | 5 #ifndef BASE_TASK_H_ |
| 6 #define BASE_TASK_H_ | 6 #define BASE_TASK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/base_api.h" |
| 9 #include "base/raw_scoped_refptr_mismatch_checker.h" | 10 #include "base/raw_scoped_refptr_mismatch_checker.h" |
| 10 #include "base/tracked.h" | 11 #include "base/tracked.h" |
| 11 #include "base/tuple.h" | 12 #include "base/tuple.h" |
| 12 #include "base/weak_ptr.h" | 13 #include "base/weak_ptr.h" |
| 13 | 14 |
| 14 // Task ------------------------------------------------------------------------ | 15 // Task ------------------------------------------------------------------------ |
| 15 // | 16 // |
| 16 // A task is a generic runnable thingy, usually used for running code on a | 17 // A task is a generic runnable thingy, usually used for running code on a |
| 17 // different thread or for scheduling future tasks off of the message loop. | 18 // different thread or for scheduling future tasks off of the message loop. |
| 18 | 19 |
| 19 class Task : public tracked_objects::Tracked { | 20 class BASE_API Task : public tracked_objects::Tracked { |
| 20 public: | 21 public: |
| 21 Task(); | 22 Task(); |
| 22 virtual ~Task(); | 23 virtual ~Task(); |
| 23 | 24 |
| 24 // Tasks are automatically deleted after Run is called. | 25 // Tasks are automatically deleted after Run is called. |
| 25 virtual void Run() = 0; | 26 virtual void Run() = 0; |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 class CancelableTask : public Task { | 29 class BASE_API CancelableTask : public Task { |
| 29 public: | 30 public: |
| 30 CancelableTask(); | 31 CancelableTask(); |
| 31 virtual ~CancelableTask(); | 32 virtual ~CancelableTask(); |
| 32 | 33 |
| 33 // Not all tasks support cancellation. | 34 // Not all tasks support cancellation. |
| 34 virtual void Cancel() = 0; | 35 virtual void Cancel() = 0; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 // Scoped Factories ------------------------------------------------------------ | 38 // Scoped Factories ------------------------------------------------------------ |
| 38 // | 39 // |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 inline CancelableTask* NewRunnableFunction(Function function, | 538 inline CancelableTask* NewRunnableFunction(Function function, |
| 538 const A& a, const B& b, | 539 const A& a, const B& b, |
| 539 const C& c, const D& d, | 540 const C& c, const D& d, |
| 540 const E& e, const F& f, | 541 const E& e, const F& f, |
| 541 const G& g, const H& h) { | 542 const G& g, const H& h) { |
| 542 return new RunnableFunction<Function, Tuple8<A, B, C, D, E, F, G, H> >( | 543 return new RunnableFunction<Function, Tuple8<A, B, C, D, E, F, G, H> >( |
| 543 function, MakeTuple(a, b, c, d, e, f, g, h)); | 544 function, MakeTuple(a, b, c, d, e, f, g, h)); |
| 544 } | 545 } |
| 545 | 546 |
| 546 #endif // BASE_TASK_H_ | 547 #endif // BASE_TASK_H_ |
| OLD | NEW |