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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 if (omaha_request_params_.delta_okay && | 512 if (omaha_request_params_.delta_okay && |
513 prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) && | 513 prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) && |
514 delta_failures >= kMaxDeltaUpdateFailures) { | 514 delta_failures >= kMaxDeltaUpdateFailures) { |
515 LOG(WARNING) << "Too many delta update failures, forcing full update."; | 515 LOG(WARNING) << "Too many delta update failures, forcing full update."; |
516 omaha_request_params_.delta_okay = false; | 516 omaha_request_params_.delta_okay = false; |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 void UpdateAttempter::MarkDeltaUpdateFailure() { | 520 void UpdateAttempter::MarkDeltaUpdateFailure() { |
521 CHECK(!is_full_update_); | 521 CHECK(!is_full_update_); |
522 // If a delta update fails after the downloading phase, don't try to resume it | 522 // Don't try to resume a failed delta update. |
523 // the next time. | 523 DeltaPerformer::ResetUpdateProgress(prefs_, false); |
524 if (status_ > UPDATE_STATUS_DOWNLOADING) { | |
525 DeltaPerformer::ResetUpdateProgress(prefs_, false); | |
526 } | |
527 int64_t delta_failures; | 524 int64_t delta_failures; |
528 if (!prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) || | 525 if (!prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) || |
529 delta_failures < 0) { | 526 delta_failures < 0) { |
530 delta_failures = 0; | 527 delta_failures = 0; |
531 } | 528 } |
532 prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures); | 529 prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures); |
533 } | 530 } |
534 | 531 |
535 void UpdateAttempter::SetupDownload() { | 532 void UpdateAttempter::SetupDownload() { |
536 MultiHttpFetcher<LibcurlHttpFetcher>* fetcher = | 533 MultiHttpFetcher<LibcurlHttpFetcher>* fetcher = |
537 dynamic_cast<MultiHttpFetcher<LibcurlHttpFetcher>*>( | 534 dynamic_cast<MultiHttpFetcher<LibcurlHttpFetcher>*>( |
538 download_action_->http_fetcher()); | 535 download_action_->http_fetcher()); |
539 MultiHttpFetcher<LibcurlHttpFetcher>::RangesVect ranges; | 536 MultiHttpFetcher<LibcurlHttpFetcher>::RangesVect ranges; |
540 if (response_handler_action_->install_plan().is_resume) { | 537 if (response_handler_action_->install_plan().is_resume) { |
541 int64_t manifest_metadata_size = 0; | 538 int64_t manifest_metadata_size = 0; |
542 prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size); | 539 prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size); |
543 int64_t next_data_offset = 0; | 540 int64_t next_data_offset = 0; |
544 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); | 541 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); |
545 ranges.push_back(make_pair(0, manifest_metadata_size)); | 542 ranges.push_back(make_pair(0, manifest_metadata_size)); |
546 ranges.push_back(make_pair(manifest_metadata_size + next_data_offset, -1)); | 543 ranges.push_back(make_pair(manifest_metadata_size + next_data_offset, -1)); |
547 } else { | 544 } else { |
548 ranges.push_back(make_pair(0, -1)); | 545 ranges.push_back(make_pair(0, -1)); |
549 } | 546 } |
550 fetcher->set_ranges(ranges); | 547 fetcher->set_ranges(ranges); |
551 } | 548 } |
552 | 549 |
553 } // namespace chromeos_update_engine | 550 } // namespace chromeos_update_engine |
OLD | NEW |