OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 COMPONENTS_UPDATE_CLIENT_TASK_UPDATE_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_TASK_SEND_UNINSTALL_PING_H_ |
6 #define COMPONENTS_UPDATE_CLIENT_TASK_UPDATE_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_TASK_SEND_UNINSTALL_PING_H_ |
7 | 7 |
8 #include <queue> | |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 | 10 |
12 #include "base/callback.h" | 11 #include "base/callback.h" |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
15 #include "components/update_client/task.h" | 14 #include "components/update_client/task.h" |
16 #include "components/update_client/update_client.h" | 15 #include "components/update_client/update_client.h" |
17 | 16 |
| 17 namespace base { |
| 18 class Version; |
| 19 } |
| 20 |
18 namespace update_client { | 21 namespace update_client { |
19 | 22 |
20 class UpdateEngine; | 23 class UpdateEngine; |
21 enum class Error; | 24 enum class Error; |
22 | 25 |
23 // Defines a specialized task for updating a group of CRXs. | 26 // Defines a specialized task for sending the uninstall ping. |
24 class TaskUpdate : public Task { | 27 class TaskSendUninstallPing : public Task { |
25 public: | 28 public: |
26 using Callback = base::Callback<void(Task* task, Error error)>; | 29 using Callback = base::Callback<void(Task* task, Error error)>; |
27 | 30 |
28 // |update_engine| is injected here to handle the task. | 31 // |update_engine| is injected here to handle the task. |
29 // |is_foreground| is true when the update task is initiated by the user, | 32 // |id| represents the CRX to send the ping for. |
30 // most likely as a result of an on-demand call. | |
31 // |ids| represents the CRXs to be updated by this task. | |
32 // |crx_data_callback| is called to get update data for the these CRXs. | |
33 // |callback| is called to return the execution flow back to creator of | 33 // |callback| is called to return the execution flow back to creator of |
34 // this task when the task is done. | 34 // this task when the task is done. |
35 TaskUpdate(UpdateEngine* update_engine, | 35 TaskSendUninstallPing(UpdateEngine* update_engine, |
36 bool is_foreground, | 36 const std::string& id, |
37 const std::vector<std::string>& ids, | 37 const base::Version& version, |
38 const UpdateClient::CrxDataCallback& crx_data_callback, | 38 int reason, |
39 const Callback& callback); | 39 const Callback& callback); |
40 ~TaskUpdate() override; | 40 ~TaskSendUninstallPing() override; |
41 | 41 |
42 void Run() override; | 42 void Run() override; |
43 | 43 |
44 void Cancel() override; | 44 void Cancel() override; |
45 | 45 |
46 std::vector<std::string> GetIds() const override; | 46 std::vector<std::string> GetIds() const override; |
47 | 47 |
48 private: | 48 private: |
49 // Called when the task has completed either because the task has run or | 49 // Called when the task has completed either because the task has run or |
50 // it has been canceled. | 50 // it has been canceled. |
51 void TaskComplete(Error error); | 51 void TaskComplete(Error error); |
52 | 52 |
53 base::ThreadChecker thread_checker_; | 53 base::ThreadChecker thread_checker_; |
54 | 54 |
55 UpdateEngine* update_engine_; // Not owned by this class. | 55 UpdateEngine* update_engine_; // Not owned by this class. |
56 | 56 const std::string id_; |
57 const bool is_foreground_; | 57 const base::Version version_; |
58 const std::vector<std::string> ids_; | 58 int reason_; |
59 const UpdateClient::CrxDataCallback crx_data_callback_; | |
60 const Callback callback_; | 59 const Callback callback_; |
61 | 60 |
62 DISALLOW_COPY_AND_ASSIGN(TaskUpdate); | 61 DISALLOW_COPY_AND_ASSIGN(TaskSendUninstallPing); |
63 }; | 62 }; |
64 | 63 |
65 } // namespace update_client | 64 } // namespace update_client |
66 | 65 |
67 #endif // COMPONENTS_UPDATE_CLIENT_TASK_UPDATE_H_ | 66 #endif // COMPONENTS_UPDATE_CLIENT_TASK_SEND_UNINSTALL_PING_H_ |
OLD | NEW |