| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 1 | // Copyright 2020 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 | |
| 5 | #include "chrome/updater/update_service_impl_inactive.h" |
| 6 | |
| 7 | #include <string> |
| Joshua Pawlicki | 3208454 | 2021-03-19 18:46:20 | [diff] [blame] | 8 | #include <utility> |
| Xiaoling Bao | a890a31 | 2021-11-30 22:47:16 | [diff] [blame] | 9 | #include <vector> |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 10 | |
| 11 | #include "base/bind.h" |
| 12 | #include "base/callback.h" |
| 13 | #include "base/threading/sequenced_task_runner_handle.h" |
| 14 | #include "base/version.h" |
| 15 | #include "chrome/updater/registration_data.h" |
| 16 | #include "chrome/updater/update_service.h" |
| 17 | |
| 18 | namespace updater { |
| 19 | |
| 20 | namespace { |
| 21 | |
| 22 | class UpdateServiceImplInactive : public UpdateService { |
| 23 | public: |
| 24 | UpdateServiceImplInactive() = default; |
| 25 | |
| 26 | // Overrides for updater::UpdateService. |
| 27 | void GetVersion( |
| Joshua Pawlicki | 0bf0f16f | 2022-02-04 17:50:15 | [diff] [blame^] | 28 | base::OnceCallback<void(const base::Version&)> callback) override { |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 29 | base::SequencedTaskRunnerHandle::Get()->PostTask( |
| 30 | FROM_HERE, base::BindOnce(std::move(callback), base::Version())); |
| 31 | } |
| 32 | |
| 33 | void RegisterApp( |
| 34 | const RegistrationRequest& request, |
| 35 | base::OnceCallback<void(const RegistrationResponse&)> callback) override { |
| 36 | base::SequencedTaskRunnerHandle::Get()->PostTask( |
| 37 | FROM_HERE, |
| 38 | base::BindOnce(std::move(callback), RegistrationResponse(-1))); |
| 39 | } |
| 40 | |
| Xiaoling Bao | a890a31 | 2021-11-30 22:47:16 | [diff] [blame] | 41 | void GetAppStates(base::OnceCallback<void(const std::vector<AppState>&)> |
| 42 | callback) const override { |
| 43 | base::SequencedTaskRunnerHandle::Get()->PostTask( |
| 44 | FROM_HERE, |
| 45 | base::BindOnce(std::move(callback), std::vector<AppState>())); |
| 46 | } |
| 47 | |
| Joshua Pawlicki | 3208454 | 2021-03-19 18:46:20 | [diff] [blame] | 48 | void RunPeriodicTasks(base::OnceClosure callback) override { |
| 49 | std::move(callback).Run(); |
| 50 | } |
| 51 | |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 52 | void UpdateAll(StateChangeCallback state_update, Callback callback) override { |
| 53 | base::SequencedTaskRunnerHandle::Get()->PostTask( |
| 54 | FROM_HERE, |
| 55 | base::BindOnce(std::move(callback), UpdateService::Result::kInactive)); |
| 56 | } |
| 57 | |
| 58 | void Update(const std::string& app_id, |
| Sorin Jianu | 88cf476 | 2021-11-19 15:43:55 | [diff] [blame] | 59 | Priority /*priority*/, |
| 60 | PolicySameVersionUpdate /*policy_same_version_update*/, |
| 61 | StateChangeCallback /*state_update*/, |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 62 | Callback callback) override { |
| 63 | base::SequencedTaskRunnerHandle::Get()->PostTask( |
| 64 | FROM_HERE, |
| 65 | base::BindOnce(std::move(callback), UpdateService::Result::kInactive)); |
| 66 | } |
| 67 | |
| 68 | void Uninitialize() override {} |
| 69 | |
| 70 | private: |
| 71 | ~UpdateServiceImplInactive() override = default; |
| 72 | }; |
| 73 | |
| 74 | } // namespace |
| 75 | |
| 76 | scoped_refptr<UpdateService> MakeInactiveUpdateService() { |
| 77 | return base::MakeRefCounted<UpdateServiceImplInactive>(); |
| 78 | } |
| 79 | |
| 80 | } // namespace updater |