David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (C) 2015 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
| 16 | |
| 17 | #ifndef UPDATE_ENGINE_BOOT_CONTROL_STUB_H_ |
| 18 | #define UPDATE_ENGINE_BOOT_CONTROL_STUB_H_ |
| 19 | |
| 20 | #include <string> |
| 21 | |
| 22 | #include "update_engine/boot_control_interface.h" |
| 23 | |
| 24 | namespace chromeos_update_engine { |
| 25 | |
| 26 | // An implementation of the BootControlInterface that does nothing, |
| 27 | // typically used when e.g. an underlying HAL implementation cannot be |
| 28 | // loaded or doesn't exist. |
| 29 | // |
| 30 | // You are gauranteed that the implementation of GetNumSlots() method |
| 31 | // always returns 0. This can be used to identify that this |
| 32 | // implementation is in use. |
| 33 | class BootControlStub : public BootControlInterface { |
| 34 | public: |
| 35 | BootControlStub() = default; |
| 36 | ~BootControlStub() = default; |
| 37 | |
| 38 | // BootControlInterface overrides. |
| 39 | unsigned int GetNumSlots() const override; |
| 40 | BootControlInterface::Slot GetCurrentSlot() const override; |
| 41 | bool GetPartitionDevice(const std::string& partition_name, |
| 42 | BootControlInterface::Slot slot, |
| 43 | std::string* device) const override; |
| 44 | bool IsSlotBootable(BootControlInterface::Slot slot) const override; |
| 45 | bool MarkSlotUnbootable(BootControlInterface::Slot slot) override; |
| 46 | bool SetActiveBootSlot(BootControlInterface::Slot slot) override; |
| 47 | bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) override; |
| 48 | |
| 49 | private: |
| 50 | DISALLOW_COPY_AND_ASSIGN(BootControlStub); |
| 51 | }; |
| 52 | |
| 53 | } // namespace chromeos_update_engine |
| 54 | |
| 55 | #endif // UPDATE_ENGINE_BOOT_CONTROL_STUB_H_ |