| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium OS Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPRESSOR_STREAM_H_ | |
| 6 #define COMPRESSOR_STREAM_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 // A IO class that reads and writes data from and to files through JavaScript. | |
| 11 // Currently, Read() and Write() methods are not called at the same time. | |
| 12 // To improve the performance, these should be called in parallel by preparing | |
| 13 // two buffers and calling them with these buffers alternatively. | |
| 14 class CompressorStream { | |
| 15 public: | |
| 16 virtual ~CompressorStream() {} | |
| 17 | |
| 18 // Writes the given buffer onto the archive. After sending a write chunk | |
| 19 // request to JavaScript, it waits until WriteChunkDone() is called in the | |
| 20 // main thread. Thus, This method must not be called in the main thread. | |
| 21 virtual int64_t Write(int64_t bytes_to_write, | |
| 22 const pp::VarArrayBuffer& buffer) = 0; | |
| 23 | |
| 24 // Called when write chunk done response arrives from JavaScript. Sends a | |
| 25 // signal to invoke Write function in another thread again. | |
| 26 virtual void WriteChunkDone(int64_t write_bytes) = 0; | |
| 27 | |
| 28 // Reads a file chunk from the entry that is currently being processed. After | |
| 29 // sending a read file chunk request to JavaScript, it waits until | |
| 30 // ReadFileChunkDone() is called in the main thread. Thus, This method must | |
| 31 // not be called in the main thread. | |
| 32 virtual int64_t Read(int64_t bytes_to_read, char* destination_buffer) = 0; | |
| 33 | |
| 34 // Called when read file chunk done response arrives from JavaScript. Copies | |
| 35 // the binary data in the given buffer to destination_buffer_ and Sends a | |
| 36 // signal to invoke Read function in another thread again. buffer must not be | |
| 37 // const because buffer.Map() and buffer.Unmap() can not be called with const. | |
| 38 virtual void ReadFileChunkDone(int64_t read_bytes, | |
| 39 pp::VarArrayBuffer* buffer) = 0; | |
| 40 }; | |
| 41 | |
| 42 #endif // COMPRESSOR_STREAM_H_ | |
| OLD | NEW |