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 14 matching lines...) Expand all Loading... | |
25 #include "update_engine/multi_range_http_fetcher.h" | 25 #include "update_engine/multi_range_http_fetcher.h" |
26 #include "update_engine/omaha_request_action.h" | 26 #include "update_engine/omaha_request_action.h" |
27 #include "update_engine/omaha_request_params.h" | 27 #include "update_engine/omaha_request_params.h" |
28 #include "update_engine/omaha_response_handler_action.h" | 28 #include "update_engine/omaha_response_handler_action.h" |
29 #include "update_engine/postinstall_runner_action.h" | 29 #include "update_engine/postinstall_runner_action.h" |
30 #include "update_engine/prefs_interface.h" | 30 #include "update_engine/prefs_interface.h" |
31 #include "update_engine/update_check_scheduler.h" | 31 #include "update_engine/update_check_scheduler.h" |
32 | 32 |
33 using base::TimeDelta; | 33 using base::TimeDelta; |
34 using base::TimeTicks; | 34 using base::TimeTicks; |
35 using google::protobuf::NewPermanentCallback; | |
35 using std::make_pair; | 36 using std::make_pair; |
36 using std::tr1::shared_ptr; | 37 using std::tr1::shared_ptr; |
37 using std::string; | 38 using std::string; |
38 using std::vector; | 39 using std::vector; |
39 | 40 |
40 namespace chromeos_update_engine { | 41 namespace chromeos_update_engine { |
41 | 42 |
42 const int UpdateAttempter::kMaxDeltaUpdateFailures = 3; | 43 const int UpdateAttempter::kMaxDeltaUpdateFailures = 3; |
43 | 44 |
44 const char* kUpdateCompletedMarker = | 45 const char* kUpdateCompletedMarker = |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 new FilesystemCopierAction(true, false)); | 182 new FilesystemCopierAction(true, false)); |
182 shared_ptr<OmahaRequestAction> download_started_action( | 183 shared_ptr<OmahaRequestAction> download_started_action( |
183 new OmahaRequestAction(prefs_, | 184 new OmahaRequestAction(prefs_, |
184 omaha_request_params_, | 185 omaha_request_params_, |
185 new OmahaEvent( | 186 new OmahaEvent( |
186 OmahaEvent::kTypeUpdateDownloadStarted), | 187 OmahaEvent::kTypeUpdateDownloadStarted), |
187 new LibcurlHttpFetcher(GetProxyResolver()))); | 188 new LibcurlHttpFetcher(GetProxyResolver()))); |
188 shared_ptr<DownloadAction> download_action( | 189 shared_ptr<DownloadAction> download_action( |
189 new DownloadAction(prefs_, new MultiRangeHTTPFetcher( | 190 new DownloadAction(prefs_, new MultiRangeHTTPFetcher( |
190 new LibcurlHttpFetcher(GetProxyResolver())))); | 191 new LibcurlHttpFetcher(GetProxyResolver())))); |
192 // This action is always initiall in place to warn of a signature failure. | |
gauravsh
2011/04/06 00:07:23
nit: "initiall"?
| |
193 // If it's not needed, it will be told to skip. | |
194 shared_ptr<OmahaRequestAction> download_signature_warning( | |
195 new OmahaRequestAction( | |
196 prefs_, | |
197 omaha_request_params_, | |
198 new OmahaEvent( | |
199 OmahaEvent::kTypeUpdateDownloadFinished, | |
200 OmahaEvent::kResultError, | |
201 kActionCodeDownloadPayloadPubKeyVerificationError), | |
202 new LibcurlHttpFetcher(GetProxyResolver()))); | |
203 download_action->set_skip_reporting_signature_fail( | |
204 NewPermanentCallback(download_signature_warning.get(), | |
205 &OmahaRequestAction::set_should_skip, | |
206 true)); | |
191 shared_ptr<OmahaRequestAction> download_finished_action( | 207 shared_ptr<OmahaRequestAction> download_finished_action( |
192 new OmahaRequestAction(prefs_, | 208 new OmahaRequestAction(prefs_, |
193 omaha_request_params_, | 209 omaha_request_params_, |
194 new OmahaEvent( | 210 new OmahaEvent( |
195 OmahaEvent::kTypeUpdateDownloadFinished), | 211 OmahaEvent::kTypeUpdateDownloadFinished), |
196 new LibcurlHttpFetcher(GetProxyResolver()))); | 212 new LibcurlHttpFetcher(GetProxyResolver()))); |
197 shared_ptr<FilesystemCopierAction> filesystem_verifier_action( | 213 shared_ptr<FilesystemCopierAction> filesystem_verifier_action( |
198 new FilesystemCopierAction(false, true)); | 214 new FilesystemCopierAction(false, true)); |
199 shared_ptr<FilesystemCopierAction> kernel_filesystem_verifier_action( | 215 shared_ptr<FilesystemCopierAction> kernel_filesystem_verifier_action( |
200 new FilesystemCopierAction(true, true)); | 216 new FilesystemCopierAction(true, true)); |
201 shared_ptr<PostinstallRunnerAction> postinstall_runner_action( | 217 shared_ptr<PostinstallRunnerAction> postinstall_runner_action( |
202 new PostinstallRunnerAction); | 218 new PostinstallRunnerAction); |
203 shared_ptr<OmahaRequestAction> update_complete_action( | 219 shared_ptr<OmahaRequestAction> update_complete_action( |
204 new OmahaRequestAction(prefs_, | 220 new OmahaRequestAction(prefs_, |
205 omaha_request_params_, | 221 omaha_request_params_, |
206 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), | 222 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
207 new LibcurlHttpFetcher(GetProxyResolver()))); | 223 new LibcurlHttpFetcher(GetProxyResolver()))); |
208 | 224 |
209 download_action->set_delegate(this); | 225 download_action->set_delegate(this); |
210 response_handler_action_ = response_handler_action; | 226 response_handler_action_ = response_handler_action; |
211 download_action_ = download_action; | 227 download_action_ = download_action; |
212 | 228 |
213 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); | 229 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); |
214 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); | 230 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); |
215 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); | 231 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); |
216 actions_.push_back(shared_ptr<AbstractAction>( | 232 actions_.push_back(shared_ptr<AbstractAction>( |
217 kernel_filesystem_copier_action)); | 233 kernel_filesystem_copier_action)); |
218 actions_.push_back(shared_ptr<AbstractAction>(download_started_action)); | 234 actions_.push_back(shared_ptr<AbstractAction>(download_started_action)); |
219 actions_.push_back(shared_ptr<AbstractAction>(download_action)); | 235 actions_.push_back(shared_ptr<AbstractAction>(download_action)); |
236 actions_.push_back(shared_ptr<AbstractAction>(download_signature_warning)); | |
220 actions_.push_back(shared_ptr<AbstractAction>(download_finished_action)); | 237 actions_.push_back(shared_ptr<AbstractAction>(download_finished_action)); |
221 actions_.push_back(shared_ptr<AbstractAction>(filesystem_verifier_action)); | 238 actions_.push_back(shared_ptr<AbstractAction>(filesystem_verifier_action)); |
222 actions_.push_back(shared_ptr<AbstractAction>( | 239 actions_.push_back(shared_ptr<AbstractAction>( |
223 kernel_filesystem_verifier_action)); | 240 kernel_filesystem_verifier_action)); |
224 actions_.push_back(shared_ptr<AbstractAction>(postinstall_runner_action)); | 241 actions_.push_back(shared_ptr<AbstractAction>(postinstall_runner_action)); |
225 actions_.push_back(shared_ptr<AbstractAction>(update_complete_action)); | 242 actions_.push_back(shared_ptr<AbstractAction>(update_complete_action)); |
226 | 243 |
227 // Enqueue the actions | 244 // Enqueue the actions |
228 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); | 245 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); |
229 it != actions_.end(); ++it) { | 246 it != actions_.end(); ++it) { |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 uint64_t resume_offset = manifest_metadata_size + next_data_offset; | 596 uint64_t resume_offset = manifest_metadata_size + next_data_offset; |
580 if (resume_offset < response_handler_action_->install_plan().size) { | 597 if (resume_offset < response_handler_action_->install_plan().size) { |
581 fetcher->AddRange(resume_offset, -1); | 598 fetcher->AddRange(resume_offset, -1); |
582 } | 599 } |
583 } else { | 600 } else { |
584 fetcher->AddRange(0, -1); | 601 fetcher->AddRange(0, -1); |
585 } | 602 } |
586 } | 603 } |
587 | 604 |
588 } // namespace chromeos_update_engine | 605 } // namespace chromeos_update_engine |
OLD | NEW |