OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 #include "components/update_client/task_send_uninstall_ping.h" |
| 5 |
| 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/threading/thread_task_runner_handle.h" |
| 11 #include "base/version.h" |
| 12 #include "components/update_client/update_client.h" |
| 13 #include "components/update_client/update_engine.h" |
| 14 |
| 15 namespace update_client { |
| 16 |
| 17 TaskSendUninstallPing::TaskSendUninstallPing(UpdateEngine* update_engine, |
| 18 const std::string& id, |
| 19 const base::Version& version, |
| 20 int reason, |
| 21 const Callback& callback) |
| 22 : update_engine_(update_engine), |
| 23 id_(id), |
| 24 version_(version), |
| 25 reason_(reason), |
| 26 callback_(callback) {} |
| 27 |
| 28 TaskSendUninstallPing::~TaskSendUninstallPing() { |
| 29 DCHECK(thread_checker_.CalledOnValidThread()); |
| 30 } |
| 31 |
| 32 void TaskSendUninstallPing::Run() { |
| 33 DCHECK(thread_checker_.CalledOnValidThread()); |
| 34 |
| 35 if (id_.empty()) { |
| 36 TaskComplete(Error::INVALID_ARGUMENT); |
| 37 return; |
| 38 } |
| 39 |
| 40 update_engine_->SendUninstallPing( |
| 41 id_, version_, reason_, |
| 42 base::Bind(&TaskSendUninstallPing::TaskComplete, base::Unretained(this))); |
| 43 } |
| 44 |
| 45 void TaskSendUninstallPing::Cancel() { |
| 46 DCHECK(thread_checker_.CalledOnValidThread()); |
| 47 |
| 48 TaskComplete(Error::UPDATE_CANCELED); |
| 49 } |
| 50 |
| 51 std::vector<std::string> TaskSendUninstallPing::GetIds() const { |
| 52 return std::vector<std::string>{id_}; |
| 53 } |
| 54 |
| 55 void TaskSendUninstallPing::TaskComplete(Error error) { |
| 56 DCHECK(thread_checker_.CalledOnValidThread()); |
| 57 |
| 58 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 59 FROM_HERE, base::Bind(callback_, this, error)); |
| 60 } |
| 61 |
| 62 } // namespace update_client |
OLD | NEW |