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

Side by Side Diff: courgette/ensemble_apply.cc

Issue 8344037: Start refactoring to reduce executable type knowledge. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix comment. Created 9 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 | « courgette/ensemble.cc ('k') | courgette/ensemble_create.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) 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 // This file contains the code to apply a Courgette patch. 5 // This file contains the code to apply a Courgette patch.
6 6
7 #include "courgette/ensemble.h" 7 #include "courgette/ensemble.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 SourceStream* transformation_parameters) { 129 SourceStream* transformation_parameters) {
130 uint32 number_of_transformations = 0; 130 uint32 number_of_transformations = 0;
131 if (!transformation_parameters->ReadVarint32(&number_of_transformations)) 131 if (!transformation_parameters->ReadVarint32(&number_of_transformations))
132 return C_BAD_ENSEMBLE_HEADER; 132 return C_BAD_ENSEMBLE_HEADER;
133 133
134 for (size_t i = 0; i < number_of_transformations; ++i) { 134 for (size_t i = 0; i < number_of_transformations; ++i) {
135 uint32 kind; 135 uint32 kind;
136 if (!transformation_parameters->ReadVarint32(&kind)) 136 if (!transformation_parameters->ReadVarint32(&kind))
137 return C_BAD_ENSEMBLE_HEADER; 137 return C_BAD_ENSEMBLE_HEADER;
138 138
139 if (kind == CourgettePatchFile::T_COURGETTE_WIN32_X86) { 139 TransformationPatcher* patcher = NULL;
140 TransformationPatcher* patcher = 140
141 new CourgetteWin32X86Patcher(base_region_); 141 switch (kind)
142 {
143 case CourgettePatchFile::T_COURGETTE_WIN32_X86:
144 patcher = new CourgetteWin32X86Patcher(base_region_);
145 break;
146 }
147
148 if (patcher)
142 patchers_.push_back(patcher); 149 patchers_.push_back(patcher);
143 } else { 150 else
144 return C_BAD_ENSEMBLE_HEADER; 151 return C_BAD_ENSEMBLE_HEADER;
145 }
146 } 152 }
147 153
148 for (size_t i = 0; i < patchers_.size(); ++i) { 154 for (size_t i = 0; i < patchers_.size(); ++i) {
149 Status status = patchers_[i]->Init(transformation_parameters); 155 Status status = patchers_[i]->Init(transformation_parameters);
150 if (status != C_OK) 156 if (status != C_OK)
151 return status; 157 return status;
152 } 158 }
153 159
154 // All transformation_parameters should have been consumed by the above loop. 160 // All transformation_parameters should have been consumed by the above loop.
155 if (!transformation_parameters->Empty()) 161 if (!transformation_parameters->Empty())
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 static_cast<int>(new_sink_stream.Length())); 414 static_cast<int>(new_sink_stream.Length()));
409 if (written == -1) 415 if (written == -1)
410 return C_WRITE_OPEN_ERROR; 416 return C_WRITE_OPEN_ERROR;
411 if (static_cast<size_t>(written) != new_sink_stream.Length()) 417 if (static_cast<size_t>(written) != new_sink_stream.Length())
412 return C_WRITE_ERROR; 418 return C_WRITE_ERROR;
413 419
414 return C_OK; 420 return C_OK;
415 } 421 }
416 422
417 } // namespace 423 } // namespace
OLDNEW
« no previous file with comments | « courgette/ensemble.cc ('k') | courgette/ensemble_create.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698