| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__ |
| 7 | 7 |
| 8 #include <zlib.h> | 8 #include <zlib.h> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "update_engine/file_writer.h" | 10 #include "update_engine/file_writer.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 virtual int Open(const char* path, int flags, mode_t mode) { | 29 virtual int Open(const char* path, int flags, mode_t mode) { |
| 30 return next_->Open(path, flags, mode); | 30 return next_->Open(path, flags, mode); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Write() calls into zlib to decompress the bytes passed in. It will not | 33 // Write() calls into zlib to decompress the bytes passed in. It will not |
| 34 // necessarily write all the decompressed data associated with this set of | 34 // necessarily write all the decompressed data associated with this set of |
| 35 // passed-in compressed data during this call, however for a valid gzip | 35 // passed-in compressed data during this call, however for a valid gzip |
| 36 // stream, after the entire stream has been written to this object, | 36 // stream, after the entire stream has been written to this object, |
| 37 // the entire decompressed stream will have been written to the | 37 // the entire decompressed stream will have been written to the |
| 38 // underlying FileWriter. | 38 // underlying FileWriter. |
| 39 virtual int Write(const void* bytes, size_t count); | 39 virtual ssize_t Write(const void* bytes, size_t count); |
| 40 | 40 |
| 41 virtual int Close() { | 41 virtual int Close() { |
| 42 return next_->Close(); | 42 return next_->Close(); |
| 43 } | 43 } |
| 44 private: | 44 private: |
| 45 // The FileWriter that we write all uncompressed data to | 45 // The FileWriter that we write all uncompressed data to |
| 46 FileWriter* next_; | 46 FileWriter* next_; |
| 47 | 47 |
| 48 // The zlib state | 48 // The zlib state |
| 49 z_stream stream_; | 49 z_stream stream_; |
| 50 | 50 |
| 51 // This is for an optimization in Write(). We can keep this buffer around | 51 // This is for an optimization in Write(). We can keep this buffer around |
| 52 // in our class to avoid repeated calls to malloc(). | 52 // in our class to avoid repeated calls to malloc(). |
| 53 std::vector<char> buffer_; | 53 std::vector<char> buffer_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(GzipDecompressingFileWriter); | 55 DISALLOW_COPY_AND_ASSIGN(GzipDecompressingFileWriter); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 } // namespace chromeos_update_engine | 58 } // namespace chromeos_update_engine |
| 59 | 59 |
| 60 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__ | 60 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__ |
| OLD | NEW |