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