Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / update_client / task_update.h
blob2cfac4f8b2e2dbad74d127a9ec3b295c96379257
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.
5 #ifndef COMPONENTS_UPDATE_CLIENT_TASK_UPDATE_H_
6 #define COMPONENTS_UPDATE_CLIENT_TASK_UPDATE_H_
8 #include <queue>
9 #include <string>
10 #include <vector>
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/threading/thread_checker.h"
15 #include "components/update_client/task.h"
16 #include "components/update_client/update_client.h"
18 namespace update_client {
20 class UpdateEngine;
22 // Defines a specialized task for updating a group of CRXs.
23 class TaskUpdate : public Task {
24 public:
25 using Callback = base::Callback<void(Task* task, int error)>;
27 // |update_engine| is injected here to handle the task.
28 // |is_foreground| is true when the update task is initiated by the user,
29 // most likely as a result of an on-demand call.
30 // |ids| represents the CRXs to be updated by this task.
31 // |crx_data_callback| is called to get update data for the these CRXs.
32 // |callback| is called to return the execution flow back to creator of
33 // this task when the task is done.
34 TaskUpdate(UpdateEngine* update_engine,
35 bool is_foreground,
36 const std::vector<std::string>& ids,
37 const UpdateClient::CrxDataCallback& crx_data_callback,
38 const Callback& callback);
39 ~TaskUpdate() override;
41 void Run() override;
43 private:
44 // Called when the Run function associated with this task has completed.
45 void RunComplete(int error);
47 base::ThreadChecker thread_checker_;
49 UpdateEngine* update_engine_; // Not owned by this class.
51 const bool is_foreground_;
52 const std::vector<std::string> ids_;
53 const UpdateClient::CrxDataCallback crx_data_callback_;
54 const Callback callback_;
56 DISALLOW_COPY_AND_ASSIGN(TaskUpdate);
59 } // namespace update_client
61 #endif // COMPONENTS_UPDATE_CLIENT_TASK_UPDATE_H_