| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 if (status_ != UPDATE_STATUS_IDLE) { | 94 if (status_ != UPDATE_STATUS_IDLE) { |
| 95 // Update in progress. Do nothing | 95 // Update in progress. Do nothing |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 full_update_ = force_full_update; | 98 full_update_ = force_full_update; |
| 99 CHECK(!processor_.IsRunning()); | 99 CHECK(!processor_.IsRunning()); |
| 100 processor_.set_delegate(this); | 100 processor_.set_delegate(this); |
| 101 | 101 |
| 102 // Actions: | 102 // Actions: |
| 103 shared_ptr<OmahaRequestPrepAction> request_prep_action( | 103 shared_ptr<OmahaRequestPrepAction> update_check_prep_action( |
| 104 new OmahaRequestPrepAction(force_full_update)); | 104 new OmahaRequestPrepAction(force_full_update)); |
| 105 shared_ptr<OmahaRequestAction> update_check_action( | 105 shared_ptr<OmahaRequestAction> update_check_action( |
| 106 new OmahaRequestAction(new LibcurlHttpFetcher)); | 106 new OmahaRequestAction(NULL, new LibcurlHttpFetcher)); |
| 107 shared_ptr<OmahaResponseHandlerAction> response_handler_action( | 107 shared_ptr<OmahaResponseHandlerAction> response_handler_action( |
| 108 new OmahaResponseHandlerAction); | 108 new OmahaResponseHandlerAction); |
| 109 shared_ptr<FilesystemCopierAction> filesystem_copier_action( | 109 shared_ptr<FilesystemCopierAction> filesystem_copier_action( |
| 110 new FilesystemCopierAction(false)); | 110 new FilesystemCopierAction(false)); |
| 111 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( | 111 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( |
| 112 new FilesystemCopierAction(true)); | 112 new FilesystemCopierAction(true)); |
| 113 shared_ptr<DownloadAction> download_action( | 113 shared_ptr<DownloadAction> download_action( |
| 114 new DownloadAction(new LibcurlHttpFetcher)); | 114 new DownloadAction(new LibcurlHttpFetcher)); |
| 115 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit( | 115 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit( |
| 116 new PostinstallRunnerAction(true)); | 116 new PostinstallRunnerAction(true)); |
| 117 shared_ptr<SetBootableFlagAction> set_bootable_flag_action( | 117 shared_ptr<SetBootableFlagAction> set_bootable_flag_action( |
| 118 new SetBootableFlagAction); | 118 new SetBootableFlagAction); |
| 119 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit( | 119 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit( |
| 120 new PostinstallRunnerAction(false)); | 120 new PostinstallRunnerAction(false)); |
| 121 shared_ptr<OmahaRequestPrepAction> install_success_prep_action( |
| 122 new OmahaRequestPrepAction(false)); |
| 123 shared_ptr<OmahaRequestAction> install_success_action( |
| 124 new OmahaRequestAction(new OmahaEvent(OmahaEvent::kTypeInstallComplete, |
| 125 OmahaEvent::kResultSuccess, |
| 126 0), |
| 127 new LibcurlHttpFetcher)); |
| 121 | 128 |
| 122 download_action->set_delegate(this); | 129 download_action->set_delegate(this); |
| 123 response_handler_action_ = response_handler_action; | 130 response_handler_action_ = response_handler_action; |
| 124 | 131 |
| 125 actions_.push_back(shared_ptr<AbstractAction>(request_prep_action)); | 132 actions_.push_back(shared_ptr<AbstractAction>(update_check_prep_action)); |
| 126 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); | 133 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); |
| 127 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); | 134 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); |
| 128 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); | 135 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); |
| 129 actions_.push_back(shared_ptr<AbstractAction>( | 136 actions_.push_back(shared_ptr<AbstractAction>( |
| 130 kernel_filesystem_copier_action)); | 137 kernel_filesystem_copier_action)); |
| 131 actions_.push_back(shared_ptr<AbstractAction>(download_action)); | 138 actions_.push_back(shared_ptr<AbstractAction>(download_action)); |
| 132 actions_.push_back(shared_ptr<AbstractAction>( | 139 actions_.push_back(shared_ptr<AbstractAction>( |
| 133 postinstall_runner_action_precommit)); | 140 postinstall_runner_action_precommit)); |
| 134 actions_.push_back(shared_ptr<AbstractAction>(set_bootable_flag_action)); | 141 actions_.push_back(shared_ptr<AbstractAction>(set_bootable_flag_action)); |
| 135 actions_.push_back(shared_ptr<AbstractAction>( | 142 actions_.push_back(shared_ptr<AbstractAction>( |
| 136 postinstall_runner_action_postcommit)); | 143 postinstall_runner_action_postcommit)); |
| 144 actions_.push_back(shared_ptr<AbstractAction>(install_success_prep_action)); |
| 145 actions_.push_back(shared_ptr<AbstractAction>(install_success_action)); |
| 137 | 146 |
| 138 // Enqueue the actions | 147 // Enqueue the actions |
| 139 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); | 148 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); |
| 140 it != actions_.end(); ++it) { | 149 it != actions_.end(); ++it) { |
| 141 processor_.EnqueueAction(it->get()); | 150 processor_.EnqueueAction(it->get()); |
| 142 } | 151 } |
| 143 | 152 |
| 144 // Bond them together. We have to use the leaf-types when calling | 153 // Bond them together. We have to use the leaf-types when calling |
| 145 // BondActions(). | 154 // BondActions(). |
| 146 BondActions(request_prep_action.get(), | 155 BondActions(update_check_prep_action.get(), |
| 147 update_check_action.get()); | 156 update_check_action.get()); |
| 148 BondActions(update_check_action.get(), | 157 BondActions(update_check_action.get(), |
| 149 response_handler_action.get()); | 158 response_handler_action.get()); |
| 150 BondActions(response_handler_action.get(), | 159 BondActions(response_handler_action.get(), |
| 151 filesystem_copier_action.get()); | 160 filesystem_copier_action.get()); |
| 152 BondActions(filesystem_copier_action.get(), | 161 BondActions(filesystem_copier_action.get(), |
| 153 kernel_filesystem_copier_action.get()); | 162 kernel_filesystem_copier_action.get()); |
| 154 BondActions(kernel_filesystem_copier_action.get(), | 163 BondActions(kernel_filesystem_copier_action.get(), |
| 155 download_action.get()); | 164 download_action.get()); |
| 156 BondActions(download_action.get(), | 165 BondActions(download_action.get(), |
| 157 postinstall_runner_action_precommit.get()); | 166 postinstall_runner_action_precommit.get()); |
| 158 BondActions(postinstall_runner_action_precommit.get(), | 167 BondActions(postinstall_runner_action_precommit.get(), |
| 159 set_bootable_flag_action.get()); | 168 set_bootable_flag_action.get()); |
| 160 BondActions(set_bootable_flag_action.get(), | 169 BondActions(set_bootable_flag_action.get(), |
| 161 postinstall_runner_action_postcommit.get()); | 170 postinstall_runner_action_postcommit.get()); |
| 171 BondActions(install_success_prep_action.get(), |
| 172 install_success_action.get()); |
| 162 | 173 |
| 163 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); | 174 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); |
| 164 processor_.StartProcessing(); | 175 processor_.StartProcessing(); |
| 165 } | 176 } |
| 166 | 177 |
| 167 void UpdateAttempter::CheckForUpdate() { | 178 void UpdateAttempter::CheckForUpdate() { |
| 168 if (status_ != UPDATE_STATUS_IDLE) { | 179 if (status_ != UPDATE_STATUS_IDLE) { |
| 169 LOG(INFO) << "Check for update requested, but status is " | 180 LOG(INFO) << "Check for update requested, but status is " |
| 170 << UpdateStatusToString(status_) << ", so not checking."; | 181 << UpdateStatusToString(status_) << ", so not checking."; |
| 171 return; | 182 return; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 update_engine_service_emit_status_update( | 285 update_engine_service_emit_status_update( |
| 275 dbus_service_, | 286 dbus_service_, |
| 276 last_checked_time_, | 287 last_checked_time_, |
| 277 download_progress_, | 288 download_progress_, |
| 278 UpdateStatusToString(status_), | 289 UpdateStatusToString(status_), |
| 279 new_version_.c_str(), | 290 new_version_.c_str(), |
| 280 new_size_); | 291 new_size_); |
| 281 } | 292 } |
| 282 | 293 |
| 283 } // namespace chromeos_update_engine | 294 } // namespace chromeos_update_engine |
| OLD | NEW |