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

Unified Diff: third_party/zlib/google/compression_utils.cc

Issue 2860903006: Handle webuis when using the network service. (Closed)
Patch Set: merge Created 3 years, 7 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 | « third_party/zlib/google/compression_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/zlib/google/compression_utils.cc
diff --git a/third_party/zlib/google/compression_utils.cc b/third_party/zlib/google/compression_utils.cc
index 575aa12619ba0b05e974a5d79857e754b1c72194..477f97f293ac88802f6c210cda0227ba61e476d5 100644
--- a/third_party/zlib/google/compression_utils.cc
+++ b/third_party/zlib/google/compression_utils.cc
@@ -114,17 +114,6 @@ int GzipUncompressHelper(Bytef* dest,
return err;
}
-// Returns the uncompressed size from GZIP-compressed |compressed_data|.
-uint32_t GetUncompressedSize(const std::string& compressed_data) {
- // The uncompressed size is stored in the last 4 bytes of |input| in LE.
- uint32_t size;
- if (compressed_data.length() < sizeof(size))
- return 0;
- memcpy(&size, &compressed_data[compressed_data.length() - sizeof(size)],
- sizeof(size));
- return base::ByteSwapToLE32(size);
-}
-
} // namespace
namespace compression {
@@ -162,4 +151,25 @@ bool GzipUncompress(const std::string& input, std::string* output) {
return false;
}
+bool GzipUncompress(base::StringPiece input, base::StringPiece output) {
+ uLongf uncompressed_size = GetUncompressedSize(input);
+ if (uncompressed_size > output.size())
+ return false;
+ return GzipUncompressHelper(bit_cast<Bytef*>(output.data()),
+ &uncompressed_size,
+ bit_cast<const Bytef*>(input.data()),
+ static_cast<uLongf>(input.length())) == Z_OK;
+}
+
+uint32_t GetUncompressedSize(base::StringPiece compressed_data) {
+ // The uncompressed size is stored in the last 4 bytes of |input| in LE.
+ uint32_t size;
+ if (compressed_data.length() < sizeof(size))
+ return 0;
+ memcpy(&size,
+ &compressed_data.data()[compressed_data.length() - sizeof(size)],
+ sizeof(size));
+ return base::ByteSwapToLE32(size);
+}
+
} // namespace compression
« no previous file with comments | « third_party/zlib/google/compression_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698