Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: delta_performer.cc

Issue 3785008: AU: Don't send no-op operations in the delta payload. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: fix comment Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « delta_diff_generator_unittest.cc ('k') | delta_performer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/delta_performer.h" 5 #include "update_engine/delta_performer.h"
6 6
7 #include <endian.h> 7 #include <endian.h>
8 #include <errno.h> 8 #include <errno.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 } // namespace {} 113 } // namespace {}
114 114
115 // Returns true if |op| is idempotent -- i.e., if we can interrupt it and repeat 115 // Returns true if |op| is idempotent -- i.e., if we can interrupt it and repeat
116 // it safely. Returns false otherwise. 116 // it safely. Returns false otherwise.
117 bool DeltaPerformer::IsIdempotentOperation( 117 bool DeltaPerformer::IsIdempotentOperation(
118 const DeltaArchiveManifest_InstallOperation& op) { 118 const DeltaArchiveManifest_InstallOperation& op) {
119 if (op.src_extents_size() == 0) { 119 if (op.src_extents_size() == 0) {
120 return true; 120 return true;
121 } 121 }
122 // TODO(adlr): detect other types of idempotent operations. For example, 122 // When in doubt, it's safe to declare an op non-idempotent. Note that we
123 // a MOVE may move a block onto itself. 123 // could detect other types of idempotent operations here such as a MOVE that
124 124 // moves blocks onto themselves. However, we rely on the server to not send
125 // When in doubt, it's safe to declare an op non-idempotent. 125 // such operations at all.
126 ExtentRanges src_ranges; 126 ExtentRanges src_ranges;
127 src_ranges.AddRepeatedExtents(op.src_extents()); 127 src_ranges.AddRepeatedExtents(op.src_extents());
128 const uint64_t block_count = src_ranges.blocks(); 128 const uint64_t block_count = src_ranges.blocks();
129 src_ranges.SubtractRepeatedExtents(op.dst_extents()); 129 src_ranges.SubtractRepeatedExtents(op.dst_extents());
130 return block_count == src_ranges.blocks(); 130 return block_count == src_ranges.blocks();
131 } 131 }
132 132
133 int DeltaPerformer::Open(const char* path, int flags, mode_t mode) { 133 int DeltaPerformer::Open(const char* path, int flags, mode_t mode) {
134 int err; 134 int err;
135 if (OpenFile(path, &fd_, &err)) 135 if (OpenFile(path, &fd_, &err))
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 if (prefs_->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures)) { 716 if (prefs_->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures)) {
717 resumed_update_failures++; 717 resumed_update_failures++;
718 } else { 718 } else {
719 resumed_update_failures = 1; 719 resumed_update_failures = 1;
720 } 720 }
721 prefs_->SetInt64(kPrefsResumedUpdateFailures, resumed_update_failures); 721 prefs_->SetInt64(kPrefsResumedUpdateFailures, resumed_update_failures);
722 return true; 722 return true;
723 } 723 }
724 724
725 } // namespace chromeos_update_engine 725 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « delta_diff_generator_unittest.cc ('k') | delta_performer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698