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

Side by Side Diff: courgette/patcher_x86_32.h

Issue 1855133002: convert //courgette to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment in memory_allocator.h Created 4 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
« no previous file with comments | « courgette/patch_generator_x86_32.h ('k') | courgette/program_detector.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef COURGETTE_WIN32_X86_PATCHER_H_ 5 #ifndef COURGETTE_WIN32_X86_PATCHER_H_
6 #define COURGETTE_WIN32_X86_PATCHER_H_ 6 #define COURGETTE_WIN32_X86_PATCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "courgette/assembly_program.h" 13 #include "courgette/assembly_program.h"
13 #include "courgette/encoded_program.h" 14 #include "courgette/encoded_program.h"
14 #include "courgette/ensemble.h" 15 #include "courgette/ensemble.h"
15 #include "courgette/program_detector.h" 16 #include "courgette/program_detector.h"
16 17
17 namespace courgette { 18 namespace courgette {
18 19
19 // PatcherX86_32 is the universal patcher for all executables. The executable 20 // PatcherX86_32 is the universal patcher for all executables. The executable
20 // type is determined by ParseDetectedExecutable function. 21 // type is determined by ParseDetectedExecutable function.
21 // 22 //
(...skipping 23 matching lines...) Expand all
45 // No code needed to write an 'empty' predicted parameter set. 46 // No code needed to write an 'empty' predicted parameter set.
46 return C_OK; 47 return C_OK;
47 } 48 }
48 49
49 Status Transform(SourceStreamSet* corrected_parameters, 50 Status Transform(SourceStreamSet* corrected_parameters,
50 SinkStreamSet* transformed_element) { 51 SinkStreamSet* transformed_element) {
51 Status status; 52 Status status;
52 if (!corrected_parameters->Empty()) 53 if (!corrected_parameters->Empty())
53 return C_GENERAL_ERROR; // Don't expect any corrected parameters. 54 return C_GENERAL_ERROR; // Don't expect any corrected parameters.
54 55
55 scoped_ptr<AssemblyProgram> program; 56 std::unique_ptr<AssemblyProgram> program;
56 status = ParseDetectedExecutable(ensemble_region_.start() + base_offset_, 57 status = ParseDetectedExecutable(ensemble_region_.start() + base_offset_,
57 base_length_, 58 base_length_,
58 &program); 59 &program);
59 if (status != C_OK) 60 if (status != C_OK)
60 return status; 61 return status;
61 62
62 scoped_ptr<EncodedProgram> encoded; 63 std::unique_ptr<EncodedProgram> encoded;
63 status = Encode(*program, &encoded); 64 status = Encode(*program, &encoded);
64 if (status != C_OK) 65 if (status != C_OK)
65 return status; 66 return status;
66 67
67 program.reset(); 68 program.reset();
68 69
69 return WriteEncodedProgram(encoded.get(), transformed_element); 70 return WriteEncodedProgram(encoded.get(), transformed_element);
70 } 71 }
71 72
72 Status Reform(SourceStreamSet* transformed_element, 73 Status Reform(SourceStreamSet* transformed_element,
73 SinkStream* reformed_element) { 74 SinkStream* reformed_element) {
74 Status status; 75 Status status;
75 scoped_ptr<EncodedProgram> encoded_program; 76 std::unique_ptr<EncodedProgram> encoded_program;
76 status = ReadEncodedProgram(transformed_element, &encoded_program); 77 status = ReadEncodedProgram(transformed_element, &encoded_program);
77 if (status != C_OK) 78 if (status != C_OK)
78 return status; 79 return status;
79 80
80 return Assemble(encoded_program.get(), reformed_element); 81 return Assemble(encoded_program.get(), reformed_element);
81 } 82 }
82 83
83 private: 84 private:
84 Region ensemble_region_; 85 Region ensemble_region_;
85 86
86 uint32_t base_offset_; 87 uint32_t base_offset_;
87 uint32_t base_length_; 88 uint32_t base_length_;
88 89
89 DISALLOW_COPY_AND_ASSIGN(PatcherX86_32); 90 DISALLOW_COPY_AND_ASSIGN(PatcherX86_32);
90 }; 91 };
91 92
92 } // namespace 93 } // namespace
93 94
94 #endif // COURGETTE_WIN32_X86_PATCHER_H_ 95 #endif // COURGETTE_WIN32_X86_PATCHER_H_
OLDNEW
« no previous file with comments | « courgette/patch_generator_x86_32.h ('k') | courgette/program_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698