sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_UPDATE_CLIENT_TASK_H_ |
| 6 | #define COMPONENTS_UPDATE_CLIENT_TASK_H_ |
| 7 | |
sorin | 08d153c | 2015-10-30 00:04:20 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
Sorin Jianu | f7e35650 | 2018-03-07 20:54:34 | [diff] [blame] | 11 | #include "base/macros.h" |
| 12 | #include "base/memory/ref_counted.h" |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 13 | |
| 14 | namespace update_client { |
| 15 | |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 16 | // Defines an abstraction for a unit of work done by the update client. |
| 17 | // Each invocation of the update client API results in a task being created and |
| 18 | // run. In most cases, a task corresponds to a set of CRXs, which are updated |
| 19 | // together. |
Sorin Jianu | f7e35650 | 2018-03-07 20:54:34 | [diff] [blame] | 20 | class Task : public base::RefCounted<Task> { |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 21 | public: |
Sorin Jianu | f7e35650 | 2018-03-07 20:54:34 | [diff] [blame] | 22 | Task() = default; |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame] | 23 | virtual void Run() = 0; |
sorin | 08d153c | 2015-10-30 00:04:20 | [diff] [blame] | 24 | |
sorin | ecaad3e | 2015-11-13 19:15:52 | [diff] [blame] | 25 | // Does a best effort attempt to make a task release its resources and stop |
| 26 | // soon. It is possible that a running task may complete even if this |
| 27 | // method is called. |
| 28 | virtual void Cancel() = 0; |
| 29 | |
sorin | 08d153c | 2015-10-30 00:04:20 | [diff] [blame] | 30 | // Returns the ids corresponding to the CRXs associated with this update task. |
| 31 | virtual std::vector<std::string> GetIds() const = 0; |
Sorin Jianu | f7e35650 | 2018-03-07 20:54:34 | [diff] [blame] | 32 | |
| 33 | protected: |
| 34 | friend class base::RefCounted<Task>; |
| 35 | virtual ~Task() = default; |
| 36 | |
| 37 | private: |
| 38 | DISALLOW_COPY_AND_ASSIGN(Task); |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | } // namespace update_client |
| 42 | |
| 43 | #endif // COMPONENTS_UPDATE_CLIENT_TASK_H_ |