| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 if (!omaha_request_params_.Init(app_version, omaha_url)) { | 128 if (!omaha_request_params_.Init(app_version, omaha_url)) { |
| 129 LOG(ERROR) << "Unable to initialize Omaha request device params."; | 129 LOG(ERROR) << "Unable to initialize Omaha request device params."; |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 CHECK(!processor_.IsRunning()); | 132 CHECK(!processor_.IsRunning()); |
| 133 processor_.set_delegate(this); | 133 processor_.set_delegate(this); |
| 134 | 134 |
| 135 // Actions: | 135 // Actions: |
| 136 shared_ptr<OmahaRequestAction> update_check_action( | 136 shared_ptr<OmahaRequestAction> update_check_action( |
| 137 new OmahaRequestAction(omaha_request_params_, | 137 new OmahaRequestAction(prefs_, |
| 138 omaha_request_params_, |
| 138 NULL, | 139 NULL, |
| 139 new LibcurlHttpFetcher)); | 140 new LibcurlHttpFetcher)); |
| 140 shared_ptr<OmahaResponseHandlerAction> response_handler_action( | 141 shared_ptr<OmahaResponseHandlerAction> response_handler_action( |
| 141 new OmahaResponseHandlerAction); | 142 new OmahaResponseHandlerAction); |
| 142 shared_ptr<FilesystemCopierAction> filesystem_copier_action( | 143 shared_ptr<FilesystemCopierAction> filesystem_copier_action( |
| 143 new FilesystemCopierAction(false)); | 144 new FilesystemCopierAction(false)); |
| 144 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( | 145 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( |
| 145 new FilesystemCopierAction(true)); | 146 new FilesystemCopierAction(true)); |
| 146 shared_ptr<OmahaRequestAction> download_started_action( | 147 shared_ptr<OmahaRequestAction> download_started_action( |
| 147 new OmahaRequestAction(omaha_request_params_, | 148 new OmahaRequestAction(prefs_, |
| 149 omaha_request_params_, |
| 148 new OmahaEvent( | 150 new OmahaEvent( |
| 149 OmahaEvent::kTypeUpdateDownloadStarted), | 151 OmahaEvent::kTypeUpdateDownloadStarted), |
| 150 new LibcurlHttpFetcher)); | 152 new LibcurlHttpFetcher)); |
| 151 shared_ptr<DownloadAction> download_action( | 153 shared_ptr<DownloadAction> download_action( |
| 152 new DownloadAction(new LibcurlHttpFetcher)); | 154 new DownloadAction(new LibcurlHttpFetcher)); |
| 153 shared_ptr<OmahaRequestAction> download_finished_action( | 155 shared_ptr<OmahaRequestAction> download_finished_action( |
| 154 new OmahaRequestAction(omaha_request_params_, | 156 new OmahaRequestAction(prefs_, |
| 157 omaha_request_params_, |
| 155 new OmahaEvent( | 158 new OmahaEvent( |
| 156 OmahaEvent::kTypeUpdateDownloadFinished), | 159 OmahaEvent::kTypeUpdateDownloadFinished), |
| 157 new LibcurlHttpFetcher)); | 160 new LibcurlHttpFetcher)); |
| 158 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit( | 161 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit( |
| 159 new PostinstallRunnerAction(true)); | 162 new PostinstallRunnerAction(true)); |
| 160 shared_ptr<SetBootableFlagAction> set_bootable_flag_action( | 163 shared_ptr<SetBootableFlagAction> set_bootable_flag_action( |
| 161 new SetBootableFlagAction); | 164 new SetBootableFlagAction); |
| 162 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit( | 165 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit( |
| 163 new PostinstallRunnerAction(false)); | 166 new PostinstallRunnerAction(false)); |
| 164 shared_ptr<OmahaRequestAction> update_complete_action( | 167 shared_ptr<OmahaRequestAction> update_complete_action( |
| 165 new OmahaRequestAction(omaha_request_params_, | 168 new OmahaRequestAction(prefs_, |
| 169 omaha_request_params_, |
| 166 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), | 170 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
| 167 new LibcurlHttpFetcher)); | 171 new LibcurlHttpFetcher)); |
| 168 | 172 |
| 169 download_action->set_delegate(this); | 173 download_action->set_delegate(this); |
| 170 response_handler_action_ = response_handler_action; | 174 response_handler_action_ = response_handler_action; |
| 171 | 175 |
| 172 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); | 176 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); |
| 173 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); | 177 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); |
| 174 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); | 178 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); |
| 175 actions_.push_back(shared_ptr<AbstractAction>( | 179 actions_.push_back(shared_ptr<AbstractAction>( |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete, | 386 error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete, |
| 383 OmahaEvent::kResultError, | 387 OmahaEvent::kResultError, |
| 384 code)); | 388 code)); |
| 385 } | 389 } |
| 386 | 390 |
| 387 bool UpdateAttempter::ScheduleErrorEventAction() { | 391 bool UpdateAttempter::ScheduleErrorEventAction() { |
| 388 if (error_event_.get() == NULL) | 392 if (error_event_.get() == NULL) |
| 389 return false; | 393 return false; |
| 390 | 394 |
| 391 shared_ptr<OmahaRequestAction> error_event_action( | 395 shared_ptr<OmahaRequestAction> error_event_action( |
| 392 new OmahaRequestAction(omaha_request_params_, | 396 new OmahaRequestAction(prefs_, |
| 397 omaha_request_params_, |
| 393 error_event_.release(), // Pass ownership. | 398 error_event_.release(), // Pass ownership. |
| 394 new LibcurlHttpFetcher)); | 399 new LibcurlHttpFetcher)); |
| 395 actions_.push_back(shared_ptr<AbstractAction>(error_event_action)); | 400 actions_.push_back(shared_ptr<AbstractAction>(error_event_action)); |
| 396 processor_.EnqueueAction(error_event_action.get()); | 401 processor_.EnqueueAction(error_event_action.get()); |
| 397 SetStatusAndNotify(UPDATE_STATUS_REPORTING_ERROR_EVENT); | 402 SetStatusAndNotify(UPDATE_STATUS_REPORTING_ERROR_EVENT); |
| 398 processor_.StartProcessing(); | 403 processor_.StartProcessing(); |
| 399 return true; | 404 return true; |
| 400 } | 405 } |
| 401 | 406 |
| 402 } // namespace chromeos_update_engine | 407 } // namespace chromeos_update_engine |
| OLD | NEW |