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

Unified Diff: courgette/ensemble.cc

Issue 8166013: Further refactoring, move ImageInfo into Disassembler/DisassemblerWin32X86. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase over other changes, fix nit. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/ensemble.h ('k') | courgette/ensemble_apply.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/ensemble.cc
diff --git a/courgette/ensemble.cc b/courgette/ensemble.cc
index a2bea8f38b7d6086ed8ace733927e27739a5fbdf..fb9b25b81b2fc6692c1a67d72c5764ab848bf4b1 100644
--- a/courgette/ensemble.cc
+++ b/courgette/ensemble.cc
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/string_number_conversions.h"
-#include "courgette/image_info.h"
#include "courgette/region.h"
#include "courgette/streams.h"
#include "courgette/simple_delta.h"
@@ -16,14 +15,11 @@ namespace courgette {
Element::Element(ExecutableType kind,
Ensemble* ensemble,
- const Region& region,
- PEInfo* info)
- : kind_(kind), ensemble_(ensemble), region_(region), info_(info) {
+ const Region& region)
+ : kind_(kind), ensemble_(ensemble), region_(region) {
}
-Element::~Element() {
- delete info_;
-}
+Element::~Element() {}
std::string Element::Name() const {
return ensemble_->name() + "("
@@ -41,41 +37,22 @@ Status Ensemble::FindEmbeddedElements() {
size_t position = 0;
while (position < length) {
- ExecutableType type = DetectExecutableType(start + position,
- length - position);
+ ExecutableType type;
+ size_t detected_length;
+
+ Status result = DetectExecutableType(start + position,
+ length - position,
+ &type, &detected_length);
- //
- // TODO(dgarrett) This switch can go away totally after two things.
- //
- // Make ImageInfo generic for all executable types.
- // Find a generic way to handle length detection for executables.
- //
- // When this switch is gone, that's one less piece of code that is
- // executable type aware.
- //
- switch (type) {
- case UNKNOWN: {
- // No Element found at current position.
- ++position;
- break;
- }
- case WIN32_X86: {
- // The Info is only created to detect the length of the executable
- courgette::PEInfo* info(new courgette::PEInfo());
- info->Init(start + position, length - position);
- if (!info->ParseHeader()) {
- delete info;
- position++;
- break;
- }
- Region region(start + position, info->length());
+ if (result == C_OK) {
+ Region region(start + position, detected_length);
- Element* element = new Element(type, this, region, info);
- owned_elements_.push_back(element);
- elements_.push_back(element);
- position += region.length();
- break;
- }
+ Element* element = new Element(type, this, region);
+ owned_elements_.push_back(element);
+ elements_.push_back(element);
+ position += region.length();
+ } else {
+ position++;
}
}
return C_OK;
« no previous file with comments | « courgette/ensemble.h ('k') | courgette/ensemble_apply.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698