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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 if (status_ != UPDATE_STATUS_IDLE) { | 133 if (status_ != UPDATE_STATUS_IDLE) { |
134 // Update in progress. Do nothing | 134 // Update in progress. Do nothing |
135 return; | 135 return; |
136 } | 136 } |
137 http_response_code_ = 0; | 137 http_response_code_ = 0; |
138 if (!omaha_request_params_.Init(app_version, omaha_url)) { | 138 if (!omaha_request_params_.Init(app_version, omaha_url)) { |
139 LOG(ERROR) << "Unable to initialize Omaha request device params."; | 139 LOG(ERROR) << "Unable to initialize Omaha request device params."; |
140 return; | 140 return; |
141 } | 141 } |
142 | 142 |
143 obeying_proxies_ = true; | 143 obeying_proxies_ = true; |
144 if (obey_proxies || proxy_manual_checks_ == 0) { | 144 if (obey_proxies || proxy_manual_checks_ == 0) { |
145 LOG(INFO) << "forced to obey proxies"; | 145 LOG(INFO) << "forced to obey proxies"; |
146 // If forced to obey proxies, every 20th request will not use proxies | 146 // If forced to obey proxies, every 20th request will not use proxies |
147 proxy_manual_checks_++; | 147 proxy_manual_checks_++; |
148 LOG(INFO) << "proxy manual checks: " << proxy_manual_checks_; | 148 LOG(INFO) << "proxy manual checks: " << proxy_manual_checks_; |
149 if (proxy_manual_checks_ >= kMaxConsecutiveObeyProxyRequests) { | 149 if (proxy_manual_checks_ >= kMaxConsecutiveObeyProxyRequests) { |
150 proxy_manual_checks_ = 0; | 150 proxy_manual_checks_ = 0; |
151 obeying_proxies_ = false; | 151 obeying_proxies_ = false; |
152 } | 152 } |
(...skipping 15 matching lines...) Expand all Loading... |
168 // libcurl_http_fetcher.cc. | 168 // libcurl_http_fetcher.cc. |
169 update_check_fetcher->set_no_network_max_retries(3); | 169 update_check_fetcher->set_no_network_max_retries(3); |
170 shared_ptr<OmahaRequestAction> update_check_action( | 170 shared_ptr<OmahaRequestAction> update_check_action( |
171 new OmahaRequestAction(prefs_, | 171 new OmahaRequestAction(prefs_, |
172 omaha_request_params_, | 172 omaha_request_params_, |
173 NULL, | 173 NULL, |
174 update_check_fetcher)); // passes ownership | 174 update_check_fetcher)); // passes ownership |
175 shared_ptr<OmahaResponseHandlerAction> response_handler_action( | 175 shared_ptr<OmahaResponseHandlerAction> response_handler_action( |
176 new OmahaResponseHandlerAction(prefs_)); | 176 new OmahaResponseHandlerAction(prefs_)); |
177 shared_ptr<FilesystemCopierAction> filesystem_copier_action( | 177 shared_ptr<FilesystemCopierAction> filesystem_copier_action( |
178 new FilesystemCopierAction(false)); | 178 new FilesystemCopierAction(false, false)); |
179 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( | 179 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( |
180 new FilesystemCopierAction(true)); | 180 new FilesystemCopierAction(true, false)); |
181 shared_ptr<OmahaRequestAction> download_started_action( | 181 shared_ptr<OmahaRequestAction> download_started_action( |
182 new OmahaRequestAction(prefs_, | 182 new OmahaRequestAction(prefs_, |
183 omaha_request_params_, | 183 omaha_request_params_, |
184 new OmahaEvent( | 184 new OmahaEvent( |
185 OmahaEvent::kTypeUpdateDownloadStarted), | 185 OmahaEvent::kTypeUpdateDownloadStarted), |
186 new LibcurlHttpFetcher(GetProxyResolver()))); | 186 new LibcurlHttpFetcher(GetProxyResolver()))); |
187 shared_ptr<DownloadAction> download_action( | 187 shared_ptr<DownloadAction> download_action( |
188 new DownloadAction(prefs_, new MultiHttpFetcher<LibcurlHttpFetcher>( | 188 new DownloadAction(prefs_, new MultiHttpFetcher<LibcurlHttpFetcher>( |
189 GetProxyResolver()))); | 189 GetProxyResolver()))); |
190 shared_ptr<OmahaRequestAction> download_finished_action( | 190 shared_ptr<OmahaRequestAction> download_finished_action( |
191 new OmahaRequestAction(prefs_, | 191 new OmahaRequestAction(prefs_, |
192 omaha_request_params_, | 192 omaha_request_params_, |
193 new OmahaEvent( | 193 new OmahaEvent( |
194 OmahaEvent::kTypeUpdateDownloadFinished), | 194 OmahaEvent::kTypeUpdateDownloadFinished), |
195 new LibcurlHttpFetcher(GetProxyResolver()))); | 195 new LibcurlHttpFetcher(GetProxyResolver()))); |
| 196 shared_ptr<FilesystemCopierAction> filesystem_verifier_action( |
| 197 new FilesystemCopierAction(false, true)); |
| 198 shared_ptr<FilesystemCopierAction> kernel_filesystem_verifier_action( |
| 199 new FilesystemCopierAction(true, true)); |
196 shared_ptr<PostinstallRunnerAction> postinstall_runner_action( | 200 shared_ptr<PostinstallRunnerAction> postinstall_runner_action( |
197 new PostinstallRunnerAction); | 201 new PostinstallRunnerAction); |
198 shared_ptr<OmahaRequestAction> update_complete_action( | 202 shared_ptr<OmahaRequestAction> update_complete_action( |
199 new OmahaRequestAction(prefs_, | 203 new OmahaRequestAction(prefs_, |
200 omaha_request_params_, | 204 omaha_request_params_, |
201 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), | 205 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
202 new LibcurlHttpFetcher(GetProxyResolver()))); | 206 new LibcurlHttpFetcher(GetProxyResolver()))); |
203 | 207 |
204 download_action->set_delegate(this); | 208 download_action->set_delegate(this); |
205 response_handler_action_ = response_handler_action; | 209 response_handler_action_ = response_handler_action; |
206 download_action_ = download_action; | 210 download_action_ = download_action; |
207 | 211 |
208 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); | 212 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); |
209 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); | 213 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); |
210 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); | 214 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); |
211 actions_.push_back(shared_ptr<AbstractAction>( | 215 actions_.push_back(shared_ptr<AbstractAction>( |
212 kernel_filesystem_copier_action)); | 216 kernel_filesystem_copier_action)); |
213 actions_.push_back(shared_ptr<AbstractAction>(download_started_action)); | 217 actions_.push_back(shared_ptr<AbstractAction>(download_started_action)); |
214 actions_.push_back(shared_ptr<AbstractAction>(download_action)); | 218 actions_.push_back(shared_ptr<AbstractAction>(download_action)); |
215 actions_.push_back(shared_ptr<AbstractAction>(download_finished_action)); | 219 actions_.push_back(shared_ptr<AbstractAction>(download_finished_action)); |
| 220 actions_.push_back(shared_ptr<AbstractAction>(filesystem_verifier_action)); |
| 221 actions_.push_back(shared_ptr<AbstractAction>( |
| 222 kernel_filesystem_verifier_action)); |
216 actions_.push_back(shared_ptr<AbstractAction>(postinstall_runner_action)); | 223 actions_.push_back(shared_ptr<AbstractAction>(postinstall_runner_action)); |
217 actions_.push_back(shared_ptr<AbstractAction>(update_complete_action)); | 224 actions_.push_back(shared_ptr<AbstractAction>(update_complete_action)); |
218 | 225 |
219 // Enqueue the actions | 226 // Enqueue the actions |
220 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); | 227 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); |
221 it != actions_.end(); ++it) { | 228 it != actions_.end(); ++it) { |
222 processor_->EnqueueAction(it->get()); | 229 processor_->EnqueueAction(it->get()); |
223 } | 230 } |
224 | 231 |
225 // Bond them together. We have to use the leaf-types when calling | 232 // Bond them together. We have to use the leaf-types when calling |
226 // BondActions(). | 233 // BondActions(). |
227 BondActions(update_check_action.get(), | 234 BondActions(update_check_action.get(), |
228 response_handler_action.get()); | 235 response_handler_action.get()); |
229 BondActions(response_handler_action.get(), | 236 BondActions(response_handler_action.get(), |
230 filesystem_copier_action.get()); | 237 filesystem_copier_action.get()); |
231 BondActions(filesystem_copier_action.get(), | 238 BondActions(filesystem_copier_action.get(), |
232 kernel_filesystem_copier_action.get()); | 239 kernel_filesystem_copier_action.get()); |
233 BondActions(kernel_filesystem_copier_action.get(), | 240 BondActions(kernel_filesystem_copier_action.get(), |
234 download_action.get()); | 241 download_action.get()); |
235 BondActions(download_action.get(), | 242 BondActions(download_action.get(), |
| 243 filesystem_verifier_action.get()); |
| 244 BondActions(filesystem_verifier_action.get(), |
| 245 kernel_filesystem_verifier_action.get()); |
| 246 BondActions(kernel_filesystem_verifier_action.get(), |
236 postinstall_runner_action.get()); | 247 postinstall_runner_action.get()); |
237 | 248 |
238 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); | 249 SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE); |
239 processor_->StartProcessing(); | 250 processor_->StartProcessing(); |
240 } | 251 } |
241 | 252 |
242 void UpdateAttempter::CheckForUpdate(const std::string& app_version, | 253 void UpdateAttempter::CheckForUpdate(const std::string& app_version, |
243 const std::string& omaha_url) { | 254 const std::string& omaha_url) { |
244 if (status_ != UPDATE_STATUS_IDLE) { | 255 if (status_ != UPDATE_STATUS_IDLE) { |
245 LOG(INFO) << "Check for update requested, but status is " | 256 LOG(INFO) << "Check for update requested, but status is " |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 if (resume_offset < response_handler_action_->install_plan().size) { | 572 if (resume_offset < response_handler_action_->install_plan().size) { |
562 ranges.push_back(make_pair(resume_offset, -1)); | 573 ranges.push_back(make_pair(resume_offset, -1)); |
563 } | 574 } |
564 } else { | 575 } else { |
565 ranges.push_back(make_pair(0, -1)); | 576 ranges.push_back(make_pair(0, -1)); |
566 } | 577 } |
567 fetcher->set_ranges(ranges); | 578 fetcher->set_ranges(ranges); |
568 } | 579 } |
569 | 580 |
570 } // namespace chromeos_update_engine | 581 } // namespace chromeos_update_engine |
OLD | NEW |