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

Side by Side Diff: courgette/ensemble_create.cc

Issue 6677141: Switch out use of std::string and std::vector for large allocations for a buffer class that doesn... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix linux build error. remove unnecessary call Created 9 years, 8 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 | « courgette/ensemble_apply.cc ('k') | courgette/memory_allocator.h » ('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 Authors. All rights reserved. 1 // Copyright (c) 2011 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.
11 11
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return generators_status; 226 return generators_status;
227 227
228 SinkStreamSet patch_streams; 228 SinkStreamSet patch_streams;
229 229
230 SinkStream* tranformation_descriptions = patch_streams.stream(0); 230 SinkStream* tranformation_descriptions = patch_streams.stream(0);
231 SinkStream* parameter_correction = patch_streams.stream(1); 231 SinkStream* parameter_correction = patch_streams.stream(1);
232 SinkStream* transformed_elements_correction = patch_streams.stream(2); 232 SinkStream* transformed_elements_correction = patch_streams.stream(2);
233 SinkStream* ensemble_correction = patch_streams.stream(3); 233 SinkStream* ensemble_correction = patch_streams.stream(3);
234 234
235 size_t number_of_transformations = generators.size(); 235 size_t number_of_transformations = generators.size();
236 tranformation_descriptions->WriteSizeVarint32(number_of_transformations); 236 if (!tranformation_descriptions->WriteSizeVarint32(number_of_transformations))
237 return C_STREAM_ERROR;
237 238
238 for (size_t i = 0; i < number_of_transformations; ++i) { 239 for (size_t i = 0; i < number_of_transformations; ++i) {
239 CourgettePatchFile::TransformationMethodId kind = generators[i]->Kind(); 240 CourgettePatchFile::TransformationMethodId kind = generators[i]->Kind();
240 tranformation_descriptions->WriteVarint32(kind); 241 if (!tranformation_descriptions->WriteVarint32(kind))
242 return C_STREAM_ERROR;
241 } 243 }
242 244
243 for (size_t i = 0; i < number_of_transformations; ++i) { 245 for (size_t i = 0; i < number_of_transformations; ++i) {
244 Status status = 246 Status status =
245 generators[i]->WriteInitialParameters(tranformation_descriptions); 247 generators[i]->WriteInitialParameters(tranformation_descriptions);
246 if (status != C_OK) 248 if (status != C_OK)
247 return status; 249 return status;
248 } 250 }
249 251
250 // 252 //
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 predicted_ensemble_source.Init(predicted_ensemble); 396 predicted_ensemble_source.Init(predicted_ensemble);
395 Status delta3_status = GenerateSimpleDelta(&predicted_ensemble_source, 397 Status delta3_status = GenerateSimpleDelta(&predicted_ensemble_source,
396 update, 398 update,
397 ensemble_correction); 399 ensemble_correction);
398 if (delta3_status != C_OK) 400 if (delta3_status != C_OK)
399 return delta3_status; 401 return delta3_status;
400 402
401 // 403 //
402 // Final output stream has a header followed by a StreamSet. 404 // Final output stream has a header followed by a StreamSet.
403 // 405 //
404 final_patch->WriteVarint32(CourgettePatchFile::kMagic); 406 if (!final_patch->WriteVarint32(CourgettePatchFile::kMagic) ||
405 final_patch->WriteVarint32(CourgettePatchFile::kVersion); 407 !final_patch->WriteVarint32(CourgettePatchFile::kVersion) ||
406 408 !final_patch->WriteVarint32(CalculateCrc(old_region.start(),
407 final_patch->WriteVarint32( 409 old_region.length())) ||
408 CalculateCrc(old_region.start(), old_region.length())); 410 !final_patch->WriteVarint32(CalculateCrc(new_region.start(),
409 final_patch->WriteVarint32( 411 new_region.length())) ||
410 CalculateCrc(new_region.start(), new_region.length())); 412 !final_patch->WriteSizeVarint32(final_patch_input_size) ||
411 final_patch->WriteSizeVarint32(final_patch_input_size); 413 !patch_streams.CopyTo(final_patch)) {
412
413 if (!patch_streams.CopyTo(final_patch))
414 return C_STREAM_ERROR; 414 return C_STREAM_ERROR;
415 }
415 416
416 VLOG(1) << "done GenerateEnsemblePatch " 417 VLOG(1) << "done GenerateEnsemblePatch "
417 << (base::Time::Now() - start_time).InSecondsF() << "s"; 418 << (base::Time::Now() - start_time).InSecondsF() << "s";
418 419
419 return C_OK; 420 return C_OK;
420 } 421 }
421 422
422 } // namespace 423 } // namespace
OLDNEW
« no previous file with comments | « courgette/ensemble_apply.cc ('k') | courgette/memory_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698