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

Side by Side Diff: courgette/ensemble_create.cc

Issue 8417045: Last small bit of refactoring. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month 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/patch_generator_x86_32.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) 2011 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.
(...skipping 10 matching lines...) Expand all
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/time.h" 22 #include "base/time.h"
23 23
24 #include "courgette/third_party/bsdiff.h" 24 #include "courgette/third_party/bsdiff.h"
25 #include "courgette/crc.h" 25 #include "courgette/crc.h"
26 #include "courgette/difference_estimator.h" 26 #include "courgette/difference_estimator.h"
27 #include "courgette/streams.h" 27 #include "courgette/streams.h"
28 #include "courgette/region.h" 28 #include "courgette/region.h"
29 #include "courgette/simple_delta.h" 29 #include "courgette/simple_delta.h"
30 30
31 #include "courgette/win32_x86_patcher.h" 31 #include "courgette/patcher_x86_32.h"
32 #include "courgette/win32_x86_generator.h" 32 #include "courgette/patch_generator_x86_32.h"
33 33
34 namespace courgette { 34 namespace courgette {
35 35
36 TransformationPatchGenerator::TransformationPatchGenerator( 36 TransformationPatchGenerator::TransformationPatchGenerator(
37 Element* old_element, 37 Element* old_element,
38 Element* new_element, 38 Element* new_element,
39 TransformationPatcher* patcher) 39 TransformationPatcher* patcher)
40 : old_element_(old_element), 40 : old_element_(old_element),
41 new_element_(new_element), 41 new_element_(new_element),
42 patcher_(patcher) { 42 patcher_(patcher) {
(...skipping 15 matching lines...) Expand all
58 SourceStreamSet* transformed_element, 58 SourceStreamSet* transformed_element,
59 SinkStream* reformed_element) { 59 SinkStream* reformed_element) {
60 return patcher_->Reform(transformed_element, reformed_element); 60 return patcher_->Reform(transformed_element, reformed_element);
61 } 61 }
62 62
63 // Makes a TransformationPatchGenerator of the appropriate variety for the 63 // Makes a TransformationPatchGenerator of the appropriate variety for the
64 // Element kind. 64 // Element kind.
65 TransformationPatchGenerator* MakeGenerator(Element* old_element, 65 TransformationPatchGenerator* MakeGenerator(Element* old_element,
66 Element* new_element) { 66 Element* new_element) {
67 switch (new_element->kind()) { 67 switch (new_element->kind()) {
68 case UNKNOWN: 68 case EXE_UNKNOWN:
69 break; 69 break;
70 case WIN32_X86: { 70 case EXE_WIN_32_X86: {
71 TransformationPatchGenerator* generator = 71 TransformationPatchGenerator* generator =
72 new CourgetteWin32X86PatchGenerator( 72 new PatchGeneratorX86_32(
73 old_element, 73 old_element,
74 new_element, 74 new_element,
75 new CourgetteWin32X86Patcher(old_element->region())); 75 new PatcherX86_32(old_element->region()),
76 EXE_WIN_32_X86);
76 return generator; 77 return generator;
77 } 78 }
78 } 79 }
79 80
80 LOG(WARNING) << "Unexpected Element::Kind " << old_element->kind(); 81 LOG(WARNING) << "Unexpected Element::Kind " << old_element->kind();
81 return NULL; 82 return NULL;
82 } 83 }
83 84
84 // Checks to see if the proposed comparison is 'unsafe'. Sometimes one element 85 // Checks to see if the proposed comparison is 'unsafe'. Sometimes one element
85 // from 'old' is matched as the closest element to multiple elements from 'new'. 86 // from 'old' is matched as the closest element to multiple elements from 'new'.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 SinkStream* tranformation_descriptions = patch_streams.stream(0); 234 SinkStream* tranformation_descriptions = patch_streams.stream(0);
234 SinkStream* parameter_correction = patch_streams.stream(1); 235 SinkStream* parameter_correction = patch_streams.stream(1);
235 SinkStream* transformed_elements_correction = patch_streams.stream(2); 236 SinkStream* transformed_elements_correction = patch_streams.stream(2);
236 SinkStream* ensemble_correction = patch_streams.stream(3); 237 SinkStream* ensemble_correction = patch_streams.stream(3);
237 238
238 size_t number_of_transformations = generators.size(); 239 size_t number_of_transformations = generators.size();
239 if (!tranformation_descriptions->WriteSizeVarint32(number_of_transformations)) 240 if (!tranformation_descriptions->WriteSizeVarint32(number_of_transformations))
240 return C_STREAM_ERROR; 241 return C_STREAM_ERROR;
241 242
242 for (size_t i = 0; i < number_of_transformations; ++i) { 243 for (size_t i = 0; i < number_of_transformations; ++i) {
243 CourgettePatchFile::TransformationMethodId kind = generators[i]->Kind(); 244 ExecutableType kind = generators[i]->Kind();
244 if (!tranformation_descriptions->WriteVarint32(kind)) 245 if (!tranformation_descriptions->WriteVarint32(kind))
245 return C_STREAM_ERROR; 246 return C_STREAM_ERROR;
246 } 247 }
247 248
248 for (size_t i = 0; i < number_of_transformations; ++i) { 249 for (size_t i = 0; i < number_of_transformations; ++i) {
249 Status status = 250 Status status =
250 generators[i]->WriteInitialParameters(tranformation_descriptions); 251 generators[i]->WriteInitialParameters(tranformation_descriptions);
251 if (status != C_OK) 252 if (status != C_OK)
252 return status; 253 return status;
253 } 254 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 return C_STREAM_ERROR; 419 return C_STREAM_ERROR;
419 } 420 }
420 421
421 VLOG(1) << "done GenerateEnsemblePatch " 422 VLOG(1) << "done GenerateEnsemblePatch "
422 << (base::Time::Now() - start_time).InSecondsF() << "s"; 423 << (base::Time::Now() - start_time).InSecondsF() << "s";
423 424
424 return C_OK; 425 return C_OK;
425 } 426 }
426 427
427 } // namespace 428 } // namespace
OLDNEW
« no previous file with comments | « courgette/ensemble_apply.cc ('k') | courgette/patch_generator_x86_32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698