| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 OmahaEvent::kTypeUpdateDownloadStarted), | 152 OmahaEvent::kTypeUpdateDownloadStarted), |
| 153 new LibcurlHttpFetcher)); | 153 new LibcurlHttpFetcher)); |
| 154 shared_ptr<DownloadAction> download_action( | 154 shared_ptr<DownloadAction> download_action( |
| 155 new DownloadAction(prefs_, new MultiHttpFetcher<LibcurlHttpFetcher>)); | 155 new DownloadAction(prefs_, new MultiHttpFetcher<LibcurlHttpFetcher>)); |
| 156 shared_ptr<OmahaRequestAction> download_finished_action( | 156 shared_ptr<OmahaRequestAction> download_finished_action( |
| 157 new OmahaRequestAction(prefs_, | 157 new OmahaRequestAction(prefs_, |
| 158 omaha_request_params_, | 158 omaha_request_params_, |
| 159 new OmahaEvent( | 159 new OmahaEvent( |
| 160 OmahaEvent::kTypeUpdateDownloadFinished), | 160 OmahaEvent::kTypeUpdateDownloadFinished), |
| 161 new LibcurlHttpFetcher)); | 161 new LibcurlHttpFetcher)); |
| 162 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit( | 162 shared_ptr<PostinstallRunnerAction> postinstall_runner_action( |
| 163 new PostinstallRunnerAction(true)); | 163 new PostinstallRunnerAction); |
| 164 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit( | |
| 165 new PostinstallRunnerAction(false)); | |
| 166 shared_ptr<OmahaRequestAction> update_complete_action( | 164 shared_ptr<OmahaRequestAction> update_complete_action( |
| 167 new OmahaRequestAction(prefs_, | 165 new OmahaRequestAction(prefs_, |
| 168 omaha_request_params_, | 166 omaha_request_params_, |
| 169 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), | 167 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
| 170 new LibcurlHttpFetcher)); | 168 new LibcurlHttpFetcher)); |
| 171 | 169 |
| 172 download_action->set_delegate(this); | 170 download_action->set_delegate(this); |
| 173 response_handler_action_ = response_handler_action; | 171 response_handler_action_ = response_handler_action; |
| 174 download_action_ = download_action; | 172 download_action_ = download_action; |
| 175 | 173 |
| 176 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); | 174 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); |
| 177 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); | 175 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); |
| 178 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); | 176 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); |
| 179 actions_.push_back(shared_ptr<AbstractAction>( | 177 actions_.push_back(shared_ptr<AbstractAction>( |
| 180 kernel_filesystem_copier_action)); | 178 kernel_filesystem_copier_action)); |
| 181 actions_.push_back(shared_ptr<AbstractAction>(download_started_action)); | 179 actions_.push_back(shared_ptr<AbstractAction>(download_started_action)); |
| 182 actions_.push_back(shared_ptr<AbstractAction>(download_action)); | 180 actions_.push_back(shared_ptr<AbstractAction>(download_action)); |
| 183 actions_.push_back(shared_ptr<AbstractAction>(download_finished_action)); | 181 actions_.push_back(shared_ptr<AbstractAction>(download_finished_action)); |
| 184 actions_.push_back(shared_ptr<AbstractAction>( | 182 actions_.push_back(shared_ptr<AbstractAction>(postinstall_runner_action)); |
| 185 postinstall_runner_action_precommit)); | |
| 186 actions_.push_back(shared_ptr<AbstractAction>( | |
| 187 postinstall_runner_action_postcommit)); | |
| 188 actions_.push_back(shared_ptr<AbstractAction>(update_complete_action)); | 183 actions_.push_back(shared_ptr<AbstractAction>(update_complete_action)); |
| 189 | 184 |
| 190 // Enqueue the actions | 185 // Enqueue the actions |
| 191 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); | 186 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); |
| 192 it != actions_.end(); ++it) { | 187 it != actions_.end(); ++it) { |
| 193 processor_->EnqueueAction(it->get()); | 188 processor_->EnqueueAction(it->get()); |
| 194 } | 189 } |
| 195 | 190 |
| 196 // Bond them together. We have to use the leaf-types when calling | 191 // Bond them together. We have to use the leaf-types when calling |
| 197 // BondActions(). | 192 // BondActions(). |
| 198 BondActions(update_check_action.get(), | 193 BondActions(update_check_action.get(), |
| 199 response_handler_action.get()); | 194 response_handler_action.get()); |
| 200 BondActions(response_handler_action.get(), | 195 BondActions(response_handler_action.get(), |
| 201 filesystem_copier_action.get()); | 196 filesystem_copier_action.get()); |
| 202 BondActions(filesystem_copier_action.get(), | 197 BondActions(filesystem_copier_action.get(), |
| 203 kernel_filesystem_copier_action.get()); | 198 kernel_filesystem_copier_action.get()); |
| 204 BondActions(kernel_filesystem_copier_action.get(), | 199 BondActions(kernel_filesystem_copier_action.get(), |
| 205 download_action.get()); | 200 download_action.get()); |
| 206 BondActions(download_action.get(), | 201 BondActions(download_action.get(), |
| 207 postinstall_runner_action_precommit.get()); | 202 postinstall_runner_action.get()); |
| 208 BondActions(postinstall_runner_action_precommit.get(), | |
| 209 postinstall_runner_action_postcommit.get()); | |
| 210 | 203 |
| 211 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); | 204 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); |
| 212 processor_->StartProcessing(); | 205 processor_->StartProcessing(); |
| 213 } | 206 } |
| 214 | 207 |
| 215 void UpdateAttempter::CheckForUpdate(const std::string& app_version, | 208 void UpdateAttempter::CheckForUpdate(const std::string& app_version, |
| 216 const std::string& omaha_url) { | 209 const std::string& omaha_url) { |
| 217 if (status_ != UPDATE_STATUS_IDLE) { | 210 if (status_ != UPDATE_STATUS_IDLE) { |
| 218 LOG(INFO) << "Check for update requested, but status is " | 211 LOG(INFO) << "Check for update requested, but status is " |
| 219 << UpdateStatusToString(status_) << ", so not checking."; | 212 << UpdateStatusToString(status_) << ", so not checking."; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 if (resume_offset < response_handler_action_->install_plan().size) { | 527 if (resume_offset < response_handler_action_->install_plan().size) { |
| 535 ranges.push_back(make_pair(resume_offset, -1)); | 528 ranges.push_back(make_pair(resume_offset, -1)); |
| 536 } | 529 } |
| 537 } else { | 530 } else { |
| 538 ranges.push_back(make_pair(0, -1)); | 531 ranges.push_back(make_pair(0, -1)); |
| 539 } | 532 } |
| 540 fetcher->set_ranges(ranges); | 533 fetcher->set_ranges(ranges); |
| 541 } | 534 } |
| 542 | 535 |
| 543 } // namespace chromeos_update_engine | 536 } // namespace chromeos_update_engine |
| OLD | NEW |