Clarify and update GN build flags docs.
[chromium-blink-merge.git] / components / update_client / task_update.cc
blob2cbf001caa1aa1112b9a008d39d4770aea853cb6
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 #include "components/update_client/task_update.h"
6 #include "base/bind.h"
7 #include "base/bind_helpers.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "components/update_client/update_engine.h"
13 namespace update_client {
15 TaskUpdate::TaskUpdate(UpdateEngine* update_engine,
16 const std::vector<std::string>& ids,
17 const UpdateClient::CrxDataCallback& crx_data_callback)
18 : update_engine_(update_engine),
19 ids_(ids),
20 crx_data_callback_(crx_data_callback) {
23 TaskUpdate::~TaskUpdate() {
24 DCHECK(thread_checker_.CalledOnValidThread());
27 void TaskUpdate::Run(const Callback& callback) {
28 DCHECK(thread_checker_.CalledOnValidThread());
30 callback_ = callback;
32 if (ids_.empty())
33 RunComplete(-1);
35 update_engine_->Update(
36 ids_, crx_data_callback_,
37 base::Bind(&TaskUpdate::RunComplete, base::Unretained(this)));
40 void TaskUpdate::RunComplete(int error) {
41 DCHECK(thread_checker_.CalledOnValidThread());
43 callback_.Run(this, error);
46 } // namespace update_client