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

Side by Side Diff: courgette/ensemble_apply.cc

Issue 1543643002: Switch to standard integer types in courgette/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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
« 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 <stddef.h>
10 #include <stdint.h>
11
10 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
11 #include "base/files/memory_mapped_file.h" 13 #include "base/files/memory_mapped_file.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h"
13 #include "courgette/crc.h" 16 #include "courgette/crc.h"
14 #include "courgette/patcher_x86_32.h" 17 #include "courgette/patcher_x86_32.h"
15 #include "courgette/region.h" 18 #include "courgette/region.h"
16 #include "courgette/simple_delta.h" 19 #include "courgette/simple_delta.h"
17 #include "courgette/streams.h" 20 #include "courgette/streams.h"
18 21
19 namespace courgette { 22 namespace courgette {
20 23
21 // EnsemblePatchApplication is all the logic and data required to apply the 24 // EnsemblePatchApplication is all the logic and data required to apply the
22 // multi-stage patch. 25 // multi-stage patch.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 SinkStream* corrected_ensemble); 57 SinkStream* corrected_ensemble);
55 58
56 private: 59 private:
57 Status SubpatchStreamSets(SinkStreamSet* predicted_items, 60 Status SubpatchStreamSets(SinkStreamSet* predicted_items,
58 SourceStream* correction, 61 SourceStream* correction,
59 SourceStreamSet* corrected_items, 62 SourceStreamSet* corrected_items,
60 SinkStream* corrected_items_storage); 63 SinkStream* corrected_items_storage);
61 64
62 Region base_region_; // Location of in-memory copy of 'old' version. 65 Region base_region_; // Location of in-memory copy of 'old' version.
63 66
64 uint32 source_checksum_; 67 uint32_t source_checksum_;
65 uint32 target_checksum_; 68 uint32_t target_checksum_;
66 uint32 final_patch_input_size_prediction_; 69 uint32_t final_patch_input_size_prediction_;
67 70
68 std::vector<TransformationPatcher*> patchers_; 71 std::vector<TransformationPatcher*> patchers_;
69 72
70 SinkStream corrected_parameters_storage_; 73 SinkStream corrected_parameters_storage_;
71 SinkStream corrected_elements_storage_; 74 SinkStream corrected_elements_storage_;
72 75
73 DISALLOW_COPY_AND_ASSIGN(EnsemblePatchApplication); 76 DISALLOW_COPY_AND_ASSIGN(EnsemblePatchApplication);
74 }; 77 };
75 78
76 EnsemblePatchApplication::EnsemblePatchApplication() 79 EnsemblePatchApplication::EnsemblePatchApplication()
77 : source_checksum_(0), target_checksum_(0), 80 : source_checksum_(0), target_checksum_(0),
78 final_patch_input_size_prediction_(0) { 81 final_patch_input_size_prediction_(0) {
79 } 82 }
80 83
81 EnsemblePatchApplication::~EnsemblePatchApplication() { 84 EnsemblePatchApplication::~EnsemblePatchApplication() {
82 for (size_t i = 0; i < patchers_.size(); ++i) { 85 for (size_t i = 0; i < patchers_.size(); ++i) {
83 delete patchers_[i]; 86 delete patchers_[i];
84 } 87 }
85 } 88 }
86 89
87 Status EnsemblePatchApplication::ReadHeader(SourceStream* header_stream) { 90 Status EnsemblePatchApplication::ReadHeader(SourceStream* header_stream) {
88 uint32 magic; 91 uint32_t magic;
89 if (!header_stream->ReadVarint32(&magic)) 92 if (!header_stream->ReadVarint32(&magic))
90 return C_BAD_ENSEMBLE_MAGIC; 93 return C_BAD_ENSEMBLE_MAGIC;
91 94
92 if (magic != CourgettePatchFile::kMagic) 95 if (magic != CourgettePatchFile::kMagic)
93 return C_BAD_ENSEMBLE_MAGIC; 96 return C_BAD_ENSEMBLE_MAGIC;
94 97
95 uint32 version; 98 uint32_t version;
96 if (!header_stream->ReadVarint32(&version)) 99 if (!header_stream->ReadVarint32(&version))
97 return C_BAD_ENSEMBLE_VERSION; 100 return C_BAD_ENSEMBLE_VERSION;
98 101
99 if (version != CourgettePatchFile::kVersion) 102 if (version != CourgettePatchFile::kVersion)
100 return C_BAD_ENSEMBLE_VERSION; 103 return C_BAD_ENSEMBLE_VERSION;
101 104
102 if (!header_stream->ReadVarint32(&source_checksum_)) 105 if (!header_stream->ReadVarint32(&source_checksum_))
103 return C_BAD_ENSEMBLE_HEADER; 106 return C_BAD_ENSEMBLE_HEADER;
104 107
105 if (!header_stream->ReadVarint32(&target_checksum_)) 108 if (!header_stream->ReadVarint32(&target_checksum_))
106 return C_BAD_ENSEMBLE_HEADER; 109 return C_BAD_ENSEMBLE_HEADER;
107 110
108 if (!header_stream->ReadVarint32(&final_patch_input_size_prediction_)) 111 if (!header_stream->ReadVarint32(&final_patch_input_size_prediction_))
109 return C_BAD_ENSEMBLE_HEADER; 112 return C_BAD_ENSEMBLE_HEADER;
110 113
111 return C_OK; 114 return C_OK;
112 } 115 }
113 116
114 Status EnsemblePatchApplication::InitBase(const Region& region) { 117 Status EnsemblePatchApplication::InitBase(const Region& region) {
115 base_region_.assign(region); 118 base_region_.assign(region);
116 return C_OK; 119 return C_OK;
117 } 120 }
118 121
119 Status EnsemblePatchApplication::ValidateBase() { 122 Status EnsemblePatchApplication::ValidateBase() {
120 uint32 checksum = CalculateCrc(base_region_.start(), base_region_.length()); 123 uint32_t checksum = CalculateCrc(base_region_.start(), base_region_.length());
121 if (source_checksum_ != checksum) 124 if (source_checksum_ != checksum)
122 return C_BAD_ENSEMBLE_CRC; 125 return C_BAD_ENSEMBLE_CRC;
123 126
124 return C_OK; 127 return C_OK;
125 } 128 }
126 129
127 Status EnsemblePatchApplication::ReadInitialParameters( 130 Status EnsemblePatchApplication::ReadInitialParameters(
128 SourceStream* transformation_parameters) { 131 SourceStream* transformation_parameters) {
129 uint32 number_of_transformations = 0; 132 uint32_t number_of_transformations = 0;
130 if (!transformation_parameters->ReadVarint32(&number_of_transformations)) 133 if (!transformation_parameters->ReadVarint32(&number_of_transformations))
131 return C_BAD_ENSEMBLE_HEADER; 134 return C_BAD_ENSEMBLE_HEADER;
132 135
133 for (size_t i = 0; i < number_of_transformations; ++i) { 136 for (size_t i = 0; i < number_of_transformations; ++i) {
134 uint32 kind; 137 uint32_t kind;
135 if (!transformation_parameters->ReadVarint32(&kind)) 138 if (!transformation_parameters->ReadVarint32(&kind))
136 return C_BAD_ENSEMBLE_HEADER; 139 return C_BAD_ENSEMBLE_HEADER;
137 140
138 TransformationPatcher* patcher = NULL; 141 TransformationPatcher* patcher = NULL;
139 142
140 switch (kind) 143 switch (kind)
141 { 144 {
142 case EXE_WIN_32_X86: 145 case EXE_WIN_32_X86:
143 patcher = new PatcherX86_32(base_region_); 146 patcher = new PatcherX86_32(base_region_);
144 break; 147 break;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 static_cast<int>(new_sink_stream.Length())); 423 static_cast<int>(new_sink_stream.Length()));
421 if (written == -1) 424 if (written == -1)
422 return C_WRITE_OPEN_ERROR; 425 return C_WRITE_OPEN_ERROR;
423 if (static_cast<size_t>(written) != new_sink_stream.Length()) 426 if (static_cast<size_t>(written) != new_sink_stream.Length())
424 return C_WRITE_ERROR; 427 return C_WRITE_ERROR;
425 428
426 return C_OK; 429 return C_OK;
427 } 430 }
428 431
429 } // namespace 432 } // 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