omaha_response_handler_action.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // Copyright (C) 2011 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. #ifndef UPDATE_ENGINE_OMAHA_RESPONSE_HANDLER_ACTION_H_
  17. #define UPDATE_ENGINE_OMAHA_RESPONSE_HANDLER_ACTION_H_
  18. #include <string>
  19. #include <gtest/gtest_prod.h> // for FRIEND_TEST
  20. #include "update_engine/common/action.h"
  21. #include "update_engine/omaha_request_action.h"
  22. #include "update_engine/payload_consumer/install_plan.h"
  23. #include "update_engine/system_state.h"
  24. // This class reads in an Omaha response and converts what it sees into
  25. // an install plan which is passed out.
  26. namespace chromeos_update_engine {
  27. class OmahaResponseHandlerAction;
  28. template <>
  29. class ActionTraits<OmahaResponseHandlerAction> {
  30. public:
  31. typedef OmahaResponse InputObjectType;
  32. typedef InstallPlan OutputObjectType;
  33. };
  34. class OmahaResponseHandlerAction : public Action<OmahaResponseHandlerAction> {
  35. public:
  36. explicit OmahaResponseHandlerAction(SystemState* system_state);
  37. typedef ActionTraits<OmahaResponseHandlerAction>::InputObjectType
  38. InputObjectType;
  39. typedef ActionTraits<OmahaResponseHandlerAction>::OutputObjectType
  40. OutputObjectType;
  41. void PerformAction() override;
  42. // This is a synchronous action, and thus TerminateProcessing() should
  43. // never be called
  44. void TerminateProcessing() override { CHECK(false); }
  45. const InstallPlan& install_plan() const { return install_plan_; }
  46. // Debugging/logging
  47. static std::string StaticType() { return "OmahaResponseHandlerAction"; }
  48. std::string Type() const override { return StaticType(); }
  49. private:
  50. // Returns true if payload hash checks are mandatory based on the state
  51. // of the system and the contents of the Omaha response. False otherwise.
  52. bool AreHashChecksMandatory(const OmahaResponse& response);
  53. // Global system context.
  54. SystemState* system_state_;
  55. // The install plan, if we have an update.
  56. InstallPlan install_plan_;
  57. // File used for communication deadline to Chrome.
  58. std::string deadline_file_;
  59. friend class OmahaResponseHandlerActionTest;
  60. friend class OmahaResponseHandlerActionProcessorDelegate;
  61. FRIEND_TEST(UpdateAttempterTest, CreatePendingErrorEventResumedTest);
  62. FRIEND_TEST(UpdateAttempterTest, RollbackMetricsNotRollbackFailure);
  63. FRIEND_TEST(UpdateAttempterTest, RollbackMetricsNotRollbackSuccess);
  64. FRIEND_TEST(UpdateAttempterTest, RollbackMetricsRollbackFailure);
  65. FRIEND_TEST(UpdateAttempterTest, RollbackMetricsRollbackSuccess);
  66. FRIEND_TEST(UpdateAttempterTest, SetRollbackHappenedNotRollback);
  67. FRIEND_TEST(UpdateAttempterTest, SetRollbackHappenedRollback);
  68. FRIEND_TEST(UpdateAttempterTest, UpdateDeferredByPolicyTest);
  69. DISALLOW_COPY_AND_ASSIGN(OmahaResponseHandlerAction);
  70. };
  71. } // namespace chromeos_update_engine
  72. #endif // UPDATE_ENGINE_OMAHA_RESPONSE_HANDLER_ACTION_H_