summaryrefslogtreecommitdiffstats
path: root/o3d/import/cross/gz_decompressor.cc
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 19:49:35 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 19:49:35 +0000
commit91240c947358b33cc19c0923a06d116ab36737dd (patch)
tree7897c99ad9b41d7735c7a42e0ea75fe6f76760b3 /o3d/import/cross/gz_decompressor.cc
parent2e25a9f4152a90a179ad37206bff79e1198379d7 (diff)
downloadchromium_src-91240c947358b33cc19c0923a06d116ab36737dd.zip
chromium_src-91240c947358b33cc19c0923a06d116ab36737dd.tar.gz
chromium_src-91240c947358b33cc19c0923a06d116ab36737dd.tar.bz2
Asynchronous tick now uses NPN_PluginAsyncCall.URL streaming callbacks are now also asynchronous.Implemented NPN_PluginAsyncCall for IE.Allowed WM_PAINT handler to be reentered because it no longer calls into the browser (except to schedule an asynchronous tick if none is pending).Fixed a bug where the EventManager would crash if an event callback called cleanUp on the client.Cleanup destroys all the packs. Doing this in NPP_Destroy seems to make Chrome timeout and fail to load the next page.Tar and GZ decoding happens on a new thread.
Review URL: http://codereview.chromium.org/155733 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/import/cross/gz_decompressor.cc')
-rw-r--r--o3d/import/cross/gz_decompressor.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/o3d/import/cross/gz_decompressor.cc b/o3d/import/cross/gz_decompressor.cc
index 7fa7fee..5499958 100644
--- a/o3d/import/cross/gz_decompressor.cc
+++ b/o3d/import/cross/gz_decompressor.cc
@@ -54,7 +54,7 @@ GzDecompressor::GzDecompressor(StreamProcessor *callback_client)
strm_.next_in = Z_NULL;
// Store this, so we can later check if it's OK to start processing
- init_result_ = inflateInit2(&strm_, 31);
+ initialized_ = inflateInit2(&strm_, 31) == Z_OK;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -64,10 +64,10 @@ GzDecompressor::~GzDecompressor() {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-int GzDecompressor::ProcessBytes(MemoryReadStream *stream,
- size_t bytes_to_process) {
+StreamProcessor::Status GzDecompressor::ProcessBytes(MemoryReadStream *stream,
+ size_t bytes_to_process) {
// Don't even bother trying if we didn't get initialized properly
- if (init_result_ != Z_OK) return init_result_;
+ if (!initialized_) return FAILURE;
uint8 out[kChunkSize];
int result;
@@ -76,7 +76,7 @@ int GzDecompressor::ProcessBytes(MemoryReadStream *stream,
// Don't try to read more than our stream has
size_t remaining = stream->GetRemainingByteCount();
if (bytes_to_process > remaining) {
- return Z_STREAM_ERROR; // could have our own error code, but good enough...
+ return FAILURE;
}
// Use direct memory access on the MemoryStream object
@@ -95,11 +95,9 @@ int GzDecompressor::ProcessBytes(MemoryReadStream *stream,
assert(result != Z_STREAM_ERROR); /* state not clobbered */
switch (result) {
case Z_NEED_DICT:
- result = Z_DATA_ERROR; /* and fall through */
-
case Z_DATA_ERROR:
case Z_MEM_ERROR:
- return result;
+ return FAILURE;
}
have = kChunkSize - strm_.avail_out;
@@ -107,15 +105,26 @@ int GzDecompressor::ProcessBytes(MemoryReadStream *stream,
// Callback with the decompressed byte stream
MemoryReadStream decompressed_stream(out, have);
if (callback_client_) {
- int client_result =
- callback_client_->ProcessBytes(&decompressed_stream, have);
- if (client_result != 0) {
- return client_result; // propagate callback errors
+ if (callback_client_->ProcessBytes(&decompressed_stream,
+ have) == FAILURE) {
+ return FAILURE;
}
}
} while (strm_.avail_out == 0);
- return result;
+ switch (result) {
+ case Z_OK:
+ case Z_BUF_ERROR: // Zlib docs say this is expected.
+ return IN_PROGRESS;
+ case Z_STREAM_END:
+ return SUCCESS;
+ default:
+ return FAILURE;
+ }
+}
+
+void GzDecompressor::Close(bool success) {
+ callback_client_->Close(success);
}
} // namespace o3d