| 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/update_attempter.h" | 5 #include "update_engine/update_attempter.h" |
| 6 | 6 |
| 7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L | 7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L |
| 8 #ifndef _POSIX_C_SOURCE | 8 #ifndef _POSIX_C_SOURCE |
| 9 #define _POSIX_C_SOURCE 199309L | 9 #define _POSIX_C_SOURCE 199309L |
| 10 #endif // _POSIX_C_SOURCE | 10 #endif // _POSIX_C_SOURCE |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (type == FilesystemCopierAction::StaticType()) | 107 if (type == FilesystemCopierAction::StaticType()) |
| 108 return kActionCodeFilesystemCopierError; | 108 return kActionCodeFilesystemCopierError; |
| 109 if (type == PostinstallRunnerAction::StaticType()) | 109 if (type == PostinstallRunnerAction::StaticType()) |
| 110 return kActionCodePostinstallRunnerError; | 110 return kActionCodePostinstallRunnerError; |
| 111 if (type == SetBootableFlagAction::StaticType()) | 111 if (type == SetBootableFlagAction::StaticType()) |
| 112 return kActionCodeSetBootableFlagError; | 112 return kActionCodeSetBootableFlagError; |
| 113 | 113 |
| 114 return code; | 114 return code; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void UpdateAttempter::Update() { | 117 void UpdateAttempter::Update(const std::string& app_version, |
| 118 const std::string& omaha_url) { |
| 118 if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) { | 119 if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) { |
| 119 LOG(INFO) << "Not updating b/c we already updated and we're waiting for " | 120 LOG(INFO) << "Not updating b/c we already updated and we're waiting for " |
| 120 << "reboot"; | 121 << "reboot"; |
| 121 return; | 122 return; |
| 122 } | 123 } |
| 123 if (status_ != UPDATE_STATUS_IDLE) { | 124 if (status_ != UPDATE_STATUS_IDLE) { |
| 124 // Update in progress. Do nothing | 125 // Update in progress. Do nothing |
| 125 return; | 126 return; |
| 126 } | 127 } |
| 127 if (!omaha_request_params_.Init()) { | 128 if (!omaha_request_params_.Init(app_version, omaha_url)) { |
| 128 LOG(ERROR) << "Unable to initialize Omaha request device params."; | 129 LOG(ERROR) << "Unable to initialize Omaha request device params."; |
| 129 return; | 130 return; |
| 130 } | 131 } |
| 131 CHECK(!processor_.IsRunning()); | 132 CHECK(!processor_.IsRunning()); |
| 132 processor_.set_delegate(this); | 133 processor_.set_delegate(this); |
| 133 | 134 |
| 134 // Actions: | 135 // Actions: |
| 135 shared_ptr<OmahaRequestAction> update_check_action( | 136 shared_ptr<OmahaRequestAction> update_check_action( |
| 136 new OmahaRequestAction(omaha_request_params_, | 137 new OmahaRequestAction(omaha_request_params_, |
| 137 NULL, | 138 NULL, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 postinstall_runner_action_precommit.get()); | 204 postinstall_runner_action_precommit.get()); |
| 204 BondActions(postinstall_runner_action_precommit.get(), | 205 BondActions(postinstall_runner_action_precommit.get(), |
| 205 set_bootable_flag_action.get()); | 206 set_bootable_flag_action.get()); |
| 206 BondActions(set_bootable_flag_action.get(), | 207 BondActions(set_bootable_flag_action.get(), |
| 207 postinstall_runner_action_postcommit.get()); | 208 postinstall_runner_action_postcommit.get()); |
| 208 | 209 |
| 209 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); | 210 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); |
| 210 processor_.StartProcessing(); | 211 processor_.StartProcessing(); |
| 211 } | 212 } |
| 212 | 213 |
| 213 void UpdateAttempter::CheckForUpdate() { | 214 void UpdateAttempter::CheckForUpdate(const std::string& app_version, |
| 215 const std::string& omaha_url) { |
| 214 if (status_ != UPDATE_STATUS_IDLE) { | 216 if (status_ != UPDATE_STATUS_IDLE) { |
| 215 LOG(INFO) << "Check for update requested, but status is " | 217 LOG(INFO) << "Check for update requested, but status is " |
| 216 << UpdateStatusToString(status_) << ", so not checking."; | 218 << UpdateStatusToString(status_) << ", so not checking."; |
| 217 return; | 219 return; |
| 218 } | 220 } |
| 219 Update(); | 221 Update(app_version, omaha_url); |
| 220 } | 222 } |
| 221 | 223 |
| 222 // Delegate methods: | 224 // Delegate methods: |
| 223 void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, | 225 void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, |
| 224 ActionExitCode code) { | 226 ActionExitCode code) { |
| 225 CHECK(response_handler_action_); | 227 CHECK(response_handler_action_); |
| 226 LOG(INFO) << "Processing Done."; | 228 LOG(INFO) << "Processing Done."; |
| 227 actions_.clear(); | 229 actions_.clear(); |
| 228 | 230 |
| 229 if (status_ == UPDATE_STATUS_REPORTING_ERROR_EVENT) { | 231 if (status_ == UPDATE_STATUS_REPORTING_ERROR_EVENT) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 error_event_.release(), // Pass ownership. | 383 error_event_.release(), // Pass ownership. |
| 382 new LibcurlHttpFetcher)); | 384 new LibcurlHttpFetcher)); |
| 383 actions_.push_back(shared_ptr<AbstractAction>(error_event_action)); | 385 actions_.push_back(shared_ptr<AbstractAction>(error_event_action)); |
| 384 processor_.EnqueueAction(error_event_action.get()); | 386 processor_.EnqueueAction(error_event_action.get()); |
| 385 SetStatusAndNotify(UPDATE_STATUS_REPORTING_ERROR_EVENT); | 387 SetStatusAndNotify(UPDATE_STATUS_REPORTING_ERROR_EVENT); |
| 386 processor_.StartProcessing(); | 388 processor_.StartProcessing(); |
| 387 return true; | 389 return true; |
| 388 } | 390 } |
| 389 | 391 |
| 390 } // namespace chromeos_update_engine | 392 } // namespace chromeos_update_engine |
| OLD | NEW |