OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 // The main idea in Courgette is to do patching *under a tranformation*. The | 5 // The main idea in Courgette is to do patching *under a tranformation*. The |
6 // input is transformed into a new representation, patching occurs in the new | 6 // input is transformed into a new representation, patching occurs in the new |
7 // repesentation, and then the tranform is reversed to get the patched data. | 7 // repesentation, and then the tranform is reversed to get the patched data. |
8 // | 8 // |
9 // The idea is applied to pieces (or 'elements') of the whole (or 'ensemble'). | 9 // The idea is applied to pieces (or 'elements') of the whole (or 'ensemble'). |
10 // Each of the elements has to go through the same set of steps in lock-step. | 10 // Each of the elements has to go through the same set of steps in lock-step. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 delete (*generators)[i]; | 179 delete (*generators)[i]; |
180 } | 180 } |
181 generators->clear(); | 181 generators->clear(); |
182 } | 182 } |
183 | 183 |
184 //////////////////////////////////////////////////////////////////////////////// | 184 //////////////////////////////////////////////////////////////////////////////// |
185 | 185 |
186 Status GenerateEnsemblePatch(SourceStream* base, | 186 Status GenerateEnsemblePatch(SourceStream* base, |
187 SourceStream* update, | 187 SourceStream* update, |
188 SinkStream* final_patch) { | 188 SinkStream* final_patch) { |
| 189 LOG(INFO) << "start GenerateEnsemblePatch"; |
| 190 base::Time start_time = base::Time::Now(); |
| 191 |
189 Region old_region(base->Buffer(), base->Remaining()); | 192 Region old_region(base->Buffer(), base->Remaining()); |
190 Region new_region(update->Buffer(), update->Remaining()); | 193 Region new_region(update->Buffer(), update->Remaining()); |
191 Ensemble old_ensemble(old_region, "old"); | 194 Ensemble old_ensemble(old_region, "old"); |
192 Ensemble new_ensemble(new_region, "new"); | 195 Ensemble new_ensemble(new_region, "new"); |
193 std::vector<TransformationPatchGenerator*> generators; | 196 std::vector<TransformationPatchGenerator*> generators; |
194 Status generators_status = FindGenerators(&old_ensemble, &new_ensemble, | 197 Status generators_status = FindGenerators(&old_ensemble, &new_ensemble, |
195 &generators); | 198 &generators); |
196 if (generators_status != C_OK) | 199 if (generators_status != C_OK) |
197 return generators_status; | 200 return generators_status; |
198 | 201 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 final_patch->WriteVarint32(CourgettePatchFile::kVersion); | 372 final_patch->WriteVarint32(CourgettePatchFile::kVersion); |
370 | 373 |
371 final_patch->WriteVarint32( | 374 final_patch->WriteVarint32( |
372 CalculateCrc(old_region.start(), old_region.length())); | 375 CalculateCrc(old_region.start(), old_region.length())); |
373 final_patch->WriteVarint32( | 376 final_patch->WriteVarint32( |
374 CalculateCrc(new_region.start(), new_region.length())); | 377 CalculateCrc(new_region.start(), new_region.length())); |
375 | 378 |
376 if (!patch_streams.CopyTo(final_patch)) | 379 if (!patch_streams.CopyTo(final_patch)) |
377 return C_STREAM_ERROR; | 380 return C_STREAM_ERROR; |
378 | 381 |
| 382 LOG(INFO) << "done GenerateEnsemblePatch " |
| 383 << (base::Time::Now() - start_time).InSecondsF() << "s"; |
| 384 |
379 return C_OK; | 385 return C_OK; |
380 } | 386 } |
381 | 387 |
382 } // namespace | 388 } // namespace |
OLD | NEW |