update_boot_flags_action.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Copyright (C) 2018 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. #include <string>
  17. #include "update_engine/common/action.h"
  18. #include "update_engine/common/boot_control_interface.h"
  19. #include <gtest/gtest_prod.h>
  20. namespace chromeos_update_engine {
  21. class UpdateBootFlagsAction : public AbstractAction {
  22. public:
  23. explicit UpdateBootFlagsAction(BootControlInterface* boot_control)
  24. : boot_control_(boot_control) {}
  25. void PerformAction() override;
  26. void TerminateProcessing() override;
  27. static std::string StaticType() { return "UpdateBootFlagsAction"; }
  28. std::string Type() const override { return StaticType(); }
  29. void CompleteUpdateBootFlags(bool successful);
  30. private:
  31. FRIEND_TEST(UpdateBootFlagsActionTest, SimpleTest);
  32. FRIEND_TEST(UpdateBootFlagsActionTest, DoubleActionTest);
  33. // Originally, both of these flags are false. Once UpdateBootFlags is called,
  34. // |is_running_| is set to true. As soon as UpdateBootFlags completes its
  35. // asynchronous run, |is_running_| is reset to false and |updated_boot_flags_|
  36. // is set to true. From that point on there will be no more changes to these
  37. // flags.
  38. //
  39. // True if have updated the boot flags.
  40. static bool updated_boot_flags_;
  41. // True if we are still updating the boot flags.
  42. static bool is_running_;
  43. // Used for setting the boot flag.
  44. BootControlInterface* boot_control_;
  45. DISALLOW_COPY_AND_ASSIGN(UpdateBootFlagsAction);
  46. };
  47. } // namespace chromeos_update_engine