| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium 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 #include <string> | 7 #include <string> |
| 8 |
| 9 #include <base/logging.h> |
| 10 |
| 11 #include "update_engine/prefs_interface.h" |
| 7 #include "update_engine/utils.h" | 12 #include "update_engine/utils.h" |
| 8 | 13 |
| 9 using std::string; | 14 using std::string; |
| 10 | 15 |
| 11 namespace chromeos_update_engine { | 16 namespace chromeos_update_engine { |
| 12 | 17 |
| 13 namespace { | |
| 14 // If the file part of the download URL contains kFullUpdateTag, then and | |
| 15 // only then do we assume it's a full update. Otherwise, we assume it's a | |
| 16 // delta update. | |
| 17 const string kFullUpdateTag = "_FULL_"; | |
| 18 } // namespace | |
| 19 | |
| 20 void OmahaResponseHandlerAction::PerformAction() { | 18 void OmahaResponseHandlerAction::PerformAction() { |
| 21 CHECK(HasInputObject()); | 19 CHECK(HasInputObject()); |
| 22 ScopedActionCompleter completer(processor_, this); | 20 ScopedActionCompleter completer(processor_, this); |
| 23 const OmahaResponse& response = GetInputObject(); | 21 const OmahaResponse& response = GetInputObject(); |
| 24 if (!response.update_exists) { | 22 if (!response.update_exists) { |
| 25 got_no_update_response_ = true; | 23 got_no_update_response_ = true; |
| 26 LOG(INFO) << "There are no updates. Aborting."; | 24 LOG(INFO) << "There are no updates. Aborting."; |
| 27 return; | 25 return; |
| 28 } | 26 } |
| 29 install_plan_.download_url = response.codebase; | 27 install_plan_.download_url = response.codebase; |
| 30 install_plan_.size = response.size; | 28 install_plan_.size = response.size; |
| 31 install_plan_.download_hash = response.hash; | 29 install_plan_.download_hash = response.hash; |
| 30 // TODO(petkov): Decide here if this is going to be a regular update or |
| 31 // resume-after-boot. This should also set the number of ops performed so far |
| 32 // to invalid if no need to resume. |
| 33 LOG_IF(WARNING, !prefs_->SetString(kPrefsUpdateCheckResponseHash, |
| 34 response.hash)) |
| 35 << "Unable to save the update check response hash."; |
| 32 TEST_AND_RETURN(GetInstallDev( | 36 TEST_AND_RETURN(GetInstallDev( |
| 33 (!boot_device_.empty() ? boot_device_ : utils::BootDevice()), | 37 (!boot_device_.empty() ? boot_device_ : utils::BootDevice()), |
| 34 &install_plan_.install_path)); | 38 &install_plan_.install_path)); |
| 35 install_plan_.kernel_install_path = | 39 install_plan_.kernel_install_path = |
| 36 utils::BootKernelDevice(install_plan_.install_path); | 40 utils::BootKernelDevice(install_plan_.install_path); |
| 37 | 41 |
| 38 install_plan_.is_full_update = !response.is_delta; | 42 install_plan_.is_full_update = !response.is_delta; |
| 39 | 43 |
| 40 TEST_AND_RETURN(HasOutputPipe()); | 44 TEST_AND_RETURN(HasOutputPipe()); |
| 41 if (HasOutputPipe()) | 45 if (HasOutputPipe()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 string ret(boot_dev); | 56 string ret(boot_dev); |
| 53 string::reverse_iterator it = ret.rbegin(); // last character in string | 57 string::reverse_iterator it = ret.rbegin(); // last character in string |
| 54 // Right now, we just switch '3' and '5' partition numbers. | 58 // Right now, we just switch '3' and '5' partition numbers. |
| 55 TEST_AND_RETURN_FALSE((*it == '3') || (*it == '5')); | 59 TEST_AND_RETURN_FALSE((*it == '3') || (*it == '5')); |
| 56 *it = (*it == '3') ? '5' : '3'; | 60 *it = (*it == '3') ? '5' : '3'; |
| 57 *install_dev = ret; | 61 *install_dev = ret; |
| 58 return true; | 62 return true; |
| 59 } | 63 } |
| 60 | 64 |
| 61 } // namespace chromeos_update_engine | 65 } // namespace chromeos_update_engine |
| OLD | NEW |