| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "update_engine/omaha_response_handler_action.h" | 5 #include "update_engine/omaha_response_handler_action.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include <base/logging.h> | 9 #include <base/logging.h> |
| 10 | 10 |
| 11 #include "update_engine/delta_performer.h" |
| 11 #include "update_engine/prefs_interface.h" | 12 #include "update_engine/prefs_interface.h" |
| 12 #include "update_engine/utils.h" | 13 #include "update_engine/utils.h" |
| 13 | 14 |
| 14 using std::string; | 15 using std::string; |
| 15 | 16 |
| 16 namespace chromeos_update_engine { | 17 namespace chromeos_update_engine { |
| 17 | 18 |
| 18 void OmahaResponseHandlerAction::PerformAction() { | 19 void OmahaResponseHandlerAction::PerformAction() { |
| 19 CHECK(HasInputObject()); | 20 CHECK(HasInputObject()); |
| 20 ScopedActionCompleter completer(processor_, this); | 21 ScopedActionCompleter completer(processor_, this); |
| 21 const OmahaResponse& response = GetInputObject(); | 22 const OmahaResponse& response = GetInputObject(); |
| 22 if (!response.update_exists) { | 23 if (!response.update_exists) { |
| 23 got_no_update_response_ = true; | 24 got_no_update_response_ = true; |
| 24 LOG(INFO) << "There are no updates. Aborting."; | 25 LOG(INFO) << "There are no updates. Aborting."; |
| 25 return; | 26 return; |
| 26 } | 27 } |
| 27 install_plan_.download_url = response.codebase; | 28 install_plan_.download_url = response.codebase; |
| 28 install_plan_.size = response.size; | 29 install_plan_.size = response.size; |
| 29 install_plan_.download_hash = response.hash; | 30 install_plan_.download_hash = response.hash; |
| 30 // TODO(petkov): Decide here if this is going to be a regular update or | 31 |
| 31 // resume-after-boot. This should also set the number of ops performed so far | 32 install_plan_.is_resume = |
| 32 // to invalid if no need to resume. | 33 DeltaPerformer::CanResumeUpdate(prefs_, response.hash); |
| 33 LOG_IF(WARNING, !prefs_->SetString(kPrefsUpdateCheckResponseHash, | 34 if (!install_plan_.is_resume) { |
| 34 response.hash)) | 35 LOG_IF(WARNING, !DeltaPerformer::ResetUpdateProgress(prefs_)) |
| 35 << "Unable to save the update check response hash."; | 36 << "Unable to reset the update progress."; |
| 37 LOG_IF(WARNING, !prefs_->SetString(kPrefsUpdateCheckResponseHash, |
| 38 response.hash)) |
| 39 << "Unable to save the update check response hash."; |
| 40 } |
| 41 |
| 36 TEST_AND_RETURN(GetInstallDev( | 42 TEST_AND_RETURN(GetInstallDev( |
| 37 (!boot_device_.empty() ? boot_device_ : utils::BootDevice()), | 43 (!boot_device_.empty() ? boot_device_ : utils::BootDevice()), |
| 38 &install_plan_.install_path)); | 44 &install_plan_.install_path)); |
| 39 install_plan_.kernel_install_path = | 45 install_plan_.kernel_install_path = |
| 40 utils::BootKernelDevice(install_plan_.install_path); | 46 utils::BootKernelDevice(install_plan_.install_path); |
| 41 | 47 |
| 42 install_plan_.is_full_update = !response.is_delta; | 48 install_plan_.is_full_update = !response.is_delta; |
| 43 | 49 |
| 44 TEST_AND_RETURN(HasOutputPipe()); | 50 TEST_AND_RETURN(HasOutputPipe()); |
| 45 if (HasOutputPipe()) | 51 if (HasOutputPipe()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 56 string ret(boot_dev); | 62 string ret(boot_dev); |
| 57 string::reverse_iterator it = ret.rbegin(); // last character in string | 63 string::reverse_iterator it = ret.rbegin(); // last character in string |
| 58 // Right now, we just switch '3' and '5' partition numbers. | 64 // Right now, we just switch '3' and '5' partition numbers. |
| 59 TEST_AND_RETURN_FALSE((*it == '3') || (*it == '5')); | 65 TEST_AND_RETURN_FALSE((*it == '3') || (*it == '5')); |
| 60 *it = (*it == '3') ? '5' : '3'; | 66 *it = (*it == '3') ? '5' : '3'; |
| 61 *install_dev = ret; | 67 *install_dev = ret; |
| 62 return true; | 68 return true; |
| 63 } | 69 } |
| 64 | 70 |
| 65 } // namespace chromeos_update_engine | 71 } // namespace chromeos_update_engine |
| OLD | NEW |