Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / update_client / task_update.cc
blobcf1a48f2ea30b396e270aed1c946527299b5811f
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 bool is_foreground,
17 const std::vector<std::string>& ids,
18 const UpdateClient::CrxDataCallback& crx_data_callback,
19 const Callback& callback)
20 : update_engine_(update_engine),
21 is_foreground_(is_foreground),
22 ids_(ids),
23 crx_data_callback_(crx_data_callback),
24 callback_(callback) {
27 TaskUpdate::~TaskUpdate() {
28 DCHECK(thread_checker_.CalledOnValidThread());
31 void TaskUpdate::Run() {
32 DCHECK(thread_checker_.CalledOnValidThread());
34 if (ids_.empty()) {
35 RunComplete(-1);
36 return;
39 update_engine_->Update(
40 is_foreground_, ids_, crx_data_callback_,
41 base::Bind(&TaskUpdate::RunComplete, base::Unretained(this)));
44 void TaskUpdate::RunComplete(int error) {
45 DCHECK(thread_checker_.CalledOnValidThread());
47 callback_.Run(this, error);
50 } // namespace update_client