summaryrefslogtreecommitdiffstats
path: root/o3d/import
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-31 18:13:40 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-31 18:13:40 +0000
commit5edab80091453ee38f28e2240649bf91c9e3e658 (patch)
tree5ed0b46ca44e9f93c0d64986d3b309dcbb94d3ef /o3d/import
parent89382b154bfcf431169b6ded5ebcd26e0ec94aea (diff)
downloadchromium_src-5edab80091453ee38f28e2240649bf91c9e3e658.zip
chromium_src-5edab80091453ee38f28e2240649bf91c9e3e658.tar.gz
chromium_src-5edab80091453ee38f28e2240649bf91c9e3e658.tar.bz2
Fix for archive request. It turns out this thing
can be called recursively. Because of that ArchiveRequest::raw_data_ would be invalid when the outer call came back. This way we mostly don't use that field. Also updated the docs so it can me marked as deprecated. Review URL: http://codereview.chromium.org/173620 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/import')
-rw-r--r--o3d/import/cross/archive_request.cc33
-rw-r--r--o3d/import/cross/archive_request.h8
2 files changed, 22 insertions, 19 deletions
diff --git a/o3d/import/cross/archive_request.cc b/o3d/import/cross/archive_request.cc
index c02e1a5..cab9bc9 100644
--- a/o3d/import/cross/archive_request.cc
+++ b/o3d/import/cross/archive_request.cc
@@ -50,9 +50,9 @@ O3D_DEFN_CLASS(ArchiveRequest, ObjectBase);
// NOTE: The file starts with "aaaaaaaa" in the hope that most tar.gz creation
// utilties can easily sort with this being the file first in the .tgz
// Otherwise you'll have to manually force it to be the first file.
-const char* ArchiveRequest::O3D_MARKER = "aaaaaaaa.o3d";
-const char* ArchiveRequest::O3D_MARKER_CONTENT = "o3d";
-const size_t ArchiveRequest::O3D_MARKER_CONTENT_LENGTH = 3;
+const char* const ArchiveRequest::kO3DMarker = "aaaaaaaa.o3d";
+const char* const ArchiveRequest::kO3DMarkerContent = "o3d";
+const size_t ArchiveRequest::kO3DMarkerContentLength = 3;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ArchiveRequest::ArchiveRequest(ServiceLocator* service_locator,
@@ -196,34 +196,37 @@ bool ArchiveRequest::ReceiveFileData(MemoryReadStream *input_stream,
if (!is_metadata && onfileavailable()) {
// keep track of the "current" data object which the callback will use
- raw_data_ = RawData::Create(service_locator(),
- current_filename_,
- temp_buffer_,
- file_memory_stream_.GetTotalStreamLength() );
+ RawData::Ref raw_data = RawData::Create(
+ service_locator(),
+ current_filename_,
+ temp_buffer_,
+ file_memory_stream_.GetTotalStreamLength() );
// keeps them all around until the ArchiveRequest goes away
- raw_data_list_.push_back(raw_data_);
+ raw_data_list_.push_back(raw_data);
- // If it's the first file is must be the O3D_MARKER or else it's an error.
+ // If it's the first file is must be the kO3DMarker or else it's an error.
if (raw_data_list_.size() == 1) {
- if (raw_data_->uri().compare(O3D_MARKER) != 0 ||
- raw_data_->StringValue().compare(O3D_MARKER_CONTENT) != 0) {
+ if (raw_data->uri().compare(kO3DMarker) != 0 ||
+ raw_data->StringValue().compare(kO3DMarkerContent) != 0) {
set_error(String("Archive '") + uri_ +
String("' is not intended for O3D. Missing '") +
- O3D_MARKER + String("' as first file in archive."));
+ kO3DMarker + String("' as first file in archive."));
return false;
}
} else {
- onfileavailable()->Run(raw_data_);
+ raw_data_ = raw_data;
+ onfileavailable()->Run(raw_data);
+ raw_data_.Reset();
}
// If data hasn't been discarded (inside callback) then writes out to
// temp file so we can get the data back at a later time
- raw_data_.Get()->Flush();
+ raw_data.Get()->Flush();
// Remove the reference to the raw_data so we don't have undefined
// behavior after the callback.
- raw_data_.Reset();
+ raw_data.Reset();
}
}
return true;
diff --git a/o3d/import/cross/archive_request.h b/o3d/import/cross/archive_request.h
index 65158bb..980c449 100644
--- a/o3d/import/cross/archive_request.h
+++ b/o3d/import/cross/archive_request.h
@@ -70,15 +70,15 @@ class ArchiveRequest : public ObjectBase, public ArchiveCallbackClient {
// can not be used to open arbitrary .tgz files but only those files someone
// has specifically prepared for O3D. This file will not be passed to
// the onfileavailable callback.
- static const char* O3D_MARKER;
+ static const char* const kO3DMarker;
- // The contents of the O3D_MARKER file. Arguably the content should not matter
+ // The contents of the O3D marker file. Arguably the content should not matter
// but for the sake of completeness we define the content so there is no
// ambiguity.
- static const char* O3D_MARKER_CONTENT;
+ static const char* const kO3DMarkerContent;
// The size of the O3D_MARKER_CONTENT.
- static const size_t O3D_MARKER_CONTENT_LENGTH;
+ static const size_t kO3DMarkerContentLength;
public:
typedef SmartPointer<ArchiveRequest> Ref;