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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (status_ != UPDATE_STATUS_IDLE) { | 191 if (status_ != UPDATE_STATUS_IDLE) { |
192 LOG(INFO) << "Check for update requested, but status is " | 192 LOG(INFO) << "Check for update requested, but status is " |
193 << UpdateStatusToString(status_) << ", so not checking."; | 193 << UpdateStatusToString(status_) << ", so not checking."; |
194 return; | 194 return; |
195 } | 195 } |
196 Update(); | 196 Update(); |
197 } | 197 } |
198 | 198 |
199 // Delegate methods: | 199 // Delegate methods: |
200 void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, | 200 void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, |
201 bool success) { | 201 ActionExitCode code) { |
202 CHECK(response_handler_action_); | 202 CHECK(response_handler_action_); |
203 LOG(INFO) << "Processing Done."; | 203 LOG(INFO) << "Processing Done."; |
204 actions_.clear(); | 204 actions_.clear(); |
205 if (success) { | 205 if (code == kActionCodeSuccess) { |
206 SetStatusAndNotify(UPDATE_STATUS_UPDATED_NEED_REBOOT); | 206 SetStatusAndNotify(UPDATE_STATUS_UPDATED_NEED_REBOOT); |
207 utils::WriteFile(kUpdateCompletedMarker, "", 0); | 207 utils::WriteFile(kUpdateCompletedMarker, "", 0); |
208 } else { | 208 } else { |
209 LOG(INFO) << "Update failed."; | 209 LOG(INFO) << "Update failed."; |
210 SetStatusAndNotify(UPDATE_STATUS_IDLE); | 210 SetStatusAndNotify(UPDATE_STATUS_IDLE); |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 void UpdateAttempter::ProcessingStopped(const ActionProcessor* processor) { | 214 void UpdateAttempter::ProcessingStopped(const ActionProcessor* processor) { |
215 download_progress_ = 0.0; | 215 download_progress_ = 0.0; |
216 SetStatusAndNotify(UPDATE_STATUS_IDLE); | 216 SetStatusAndNotify(UPDATE_STATUS_IDLE); |
217 actions_.clear(); | 217 actions_.clear(); |
218 } | 218 } |
219 | 219 |
220 // Called whenever an action has finished processing, either successfully | 220 // Called whenever an action has finished processing, either successfully |
221 // or otherwise. | 221 // or otherwise. |
222 void UpdateAttempter::ActionCompleted(ActionProcessor* processor, | 222 void UpdateAttempter::ActionCompleted(ActionProcessor* processor, |
223 AbstractAction* action, | 223 AbstractAction* action, |
224 bool success) { | 224 ActionExitCode code) { |
225 // Reset download progress regardless of whether or not the download action | 225 // Reset download progress regardless of whether or not the download action |
226 // succeeded. | 226 // succeeded. |
227 const string type = action->Type(); | 227 const string type = action->Type(); |
228 if (type == DownloadAction::StaticType()) | 228 if (type == DownloadAction::StaticType()) |
229 download_progress_ = 0.0; | 229 download_progress_ = 0.0; |
230 if (!success) | 230 if (code != kActionCodeSuccess) |
231 return; | 231 return; |
232 // Find out which action completed. | 232 // Find out which action completed. |
233 if (type == OmahaResponseHandlerAction::StaticType()) { | 233 if (type == OmahaResponseHandlerAction::StaticType()) { |
234 SetStatusAndNotify(UPDATE_STATUS_DOWNLOADING); | 234 SetStatusAndNotify(UPDATE_STATUS_DOWNLOADING); |
235 OmahaResponseHandlerAction* omaha_response_handler_action = | 235 OmahaResponseHandlerAction* omaha_response_handler_action = |
236 dynamic_cast<OmahaResponseHandlerAction*>(action); | 236 dynamic_cast<OmahaResponseHandlerAction*>(action); |
237 CHECK(omaha_response_handler_action); | 237 CHECK(omaha_response_handler_action); |
238 const InstallPlan& plan = omaha_response_handler_action->install_plan(); | 238 const InstallPlan& plan = omaha_response_handler_action->install_plan(); |
239 last_checked_time_ = time(NULL); | 239 last_checked_time_ = time(NULL); |
240 // TODO(adlr): put version in InstallPlan | 240 // TODO(adlr): put version in InstallPlan |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 update_engine_service_emit_status_update( | 297 update_engine_service_emit_status_update( |
298 dbus_service_, | 298 dbus_service_, |
299 last_checked_time_, | 299 last_checked_time_, |
300 download_progress_, | 300 download_progress_, |
301 UpdateStatusToString(status_), | 301 UpdateStatusToString(status_), |
302 new_version_.c_str(), | 302 new_version_.c_str(), |
303 new_size_); | 303 new_size_); |
304 } | 304 } |
305 | 305 |
306 } // namespace chromeos_update_engine | 306 } // namespace chromeos_update_engine |
OLD | NEW |