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

Unified Diff: third_party/zlib/google/zip_reader.h

Issue 179963002: New Zip::ZipFromMemory API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup! New Zip::ZipFromMemory API. Created 6 years, 10 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
Index: third_party/zlib/google/zip_reader.h
diff --git a/third_party/zlib/google/zip_reader.h b/third_party/zlib/google/zip_reader.h
index 5f0a16785de3bb51b304eb8723521c1acb839d63..66aba1e2130bc16dc7053a82a2fffd624745a1cc 100644
--- a/third_party/zlib/google/zip_reader.h
+++ b/third_party/zlib/google/zip_reader.h
@@ -21,6 +21,12 @@
#include "third_party/zlib/contrib/minizip/unzip.h"
#endif
+template <class T> class scoped_refptr;
+
+namespace base {
+class RefCountedMemory;
+}
+
namespace zip {
// This class is used for reading zip files. A typical use case of this
@@ -180,6 +186,23 @@ class ZipReader {
bool ExtractCurrentEntryToFd(int fd);
#endif
+ // Extracts the current entry into memory. If the current file is a directory,
+ // NULL is stored in the |output| parameter. If the current file is a file,
+ // |output| is never set to NULL. Returns true on success.
+ // OpenCurrentEntryInZip() must be called beforehand.
+ // Note that EntryInfo::original_size() can return a different value than the
+ // real size of the uncompressed contents. Therefore, to prevent excessive
+ // memory usage, the maximum amount of data to read has to be specified in
+ // |max_read_bytes|. If the size of the uncompressed data is bigger than
+ // max_read_bytes then false is returned. |max_read_bytes| must be positive
+ // non-zero.
+ bool ExtractCurrentEntryToRefCountedMemory(
+ int max_read_bytes,
+ base::RefCountedMemory** output) const;
satorux1 2014/02/26 04:05:47 I found this API complex. RefCountedMemory is tric
João Eiras 2014/02/26 17:35:38 Tricky in what way ? I'd have to warn that files
satorux1 2014/02/27 06:57:00 Reference counting in general is tricky. It makes
satorux1 2014/02/27 16:39:03 Maybe your concern was when the input data was big
+ bool ExtractCurrentEntryToRefCountedMemory(
+ int max_read_bytes,
+ scoped_refptr<base::RefCountedMemory>* output) const;
satorux1 2014/02/26 04:05:47 scoped_refptr<> should only be used when an object
+
// Returns the current entry info. Returns NULL if the current entry is
// not yet opened. OpenCurrentEntryInZip() must be called beforehand.
EntryInfo* current_entry_info() const {

Powered by Google App Engine
This is Rietveld 408576698