Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::bin::ZLibDeflateFilter Class Reference

#include <filter.h>

Inheritance diagram for dart::bin::ZLibDeflateFilter:
dart::bin::Filter

Public Member Functions

 ZLibDeflateFilter (bool gzip, int32_t level, int32_t window_bits, int32_t mem_level, int32_t strategy, uint8_t *dictionary, intptr_t dictionary_length, bool raw)
 
virtual ~ZLibDeflateFilter ()
 
virtual bool Init ()
 
virtual bool Process (uint8_t *data, intptr_t length)
 
virtual intptr_t Processed (uint8_t *buffer, intptr_t length, bool finish, bool end)
 
- Public Member Functions inherited from dart::bin::Filter
virtual ~Filter ()
 
virtual bool Init ()=0
 
virtual bool Process (uint8_t *data, intptr_t length)=0
 
virtual intptr_t Processed (uint8_t *buffer, intptr_t length, bool finish, bool end)=0
 
bool initialized () const
 
void set_initialized (bool value)
 
uint8_t * processed_buffer ()
 
intptr_t processed_buffer_size () const
 

Additional Inherited Members

- Static Public Member Functions inherited from dart::bin::Filter
static Dart_Handle SetFilterAndCreateFinalizer (Dart_Handle filter, Filter *filter_pointer, intptr_t filter_size)
 
static Dart_Handle GetFilterNativeField (Dart_Handle filter, Filter **filter_pointer)
 
- Protected Member Functions inherited from dart::bin::Filter
 Filter ()
 

Detailed Description

Definition at line 55 of file filter.h.

Constructor & Destructor Documentation

◆ ZLibDeflateFilter()

dart::bin::ZLibDeflateFilter::ZLibDeflateFilter ( bool  gzip,
int32_t  level,
int32_t  window_bits,
int32_t  mem_level,
int32_t  strategy,
uint8_t *  dictionary,
intptr_t  dictionary_length,
bool  raw 
)
inline

Definition at line 57 of file filter.h.

65 : gzip_(gzip),
66 level_(level),
67 window_bits_(window_bits),
68 mem_level_(mem_level),
69 strategy_(strategy),
70 dictionary_(dictionary),
71 dictionary_length_(dictionary_length),
72 raw_(raw),
73 current_buffer_(nullptr) {}

◆ ~ZLibDeflateFilter()

dart::bin::ZLibDeflateFilter::~ZLibDeflateFilter ( )
virtual

Definition at line 285 of file filter.cc.

285 {
286 delete[] dictionary_;
287 delete[] current_buffer_;
288 if (initialized()) {
289 deflateEnd(&stream_);
290 }
291}
bool initialized() const
Definition: filter.h:39

Member Function Documentation

◆ Init()

bool dart::bin::ZLibDeflateFilter::Init ( )
virtual

Implements dart::bin::Filter.

Definition at line 293 of file filter.cc.

293 {
294 int window_bits = window_bits_;
295 if ((raw_ || gzip_) && (window_bits == 8)) {
296 // zlib deflater does not work with windows size of 8 bits. Old versions
297 // of zlib would silently upgrade window size to 9 bits, newer versions
298 // return Z_STREAM_ERROR if window size is 8 bits but the stream header
299 // is suppressed. To maintain the old behavior upgrade window size here.
300 // This is safe because you can inflate a stream deflated with zlib
301 // using 9-bits with 8-bits window.
302 // For more details see https://crbug.com/691074.
303 window_bits = 9;
304 }
305 if (raw_) {
306 window_bits = -window_bits;
307 } else if (gzip_) {
308 window_bits += kZLibFlagUseGZipHeader;
309 }
310 stream_.next_in = Z_NULL;
311 stream_.zalloc = Z_NULL;
312 stream_.zfree = Z_NULL;
313 stream_.opaque = Z_NULL;
314 int result = deflateInit2(&stream_, level_, Z_DEFLATED, window_bits,
315 mem_level_, strategy_);
316 if (result != Z_OK) {
317 return false;
318 }
319 if ((dictionary_ != nullptr) && !gzip_ && !raw_) {
320 result = deflateSetDictionary(&stream_, dictionary_, dictionary_length_);
321 delete[] dictionary_;
322 dictionary_ = nullptr;
323 if (result != Z_OK) {
324 return false;
325 }
326 }
327 set_initialized(true);
328 return true;
329}
void set_initialized(bool value)
Definition: filter.h:40
GAsyncResult * result
const int kZLibFlagUseGZipHeader
Definition: filter.cc:15

◆ Process()

bool dart::bin::ZLibDeflateFilter::Process ( uint8_t *  data,
intptr_t  length 
)
virtual

On a successful call to Process, Process will take ownership of data. On successive calls to either Processed or ~Filter, data will be freed with a delete[] call.

Implements dart::bin::Filter.

Definition at line 331 of file filter.cc.

331 {
332 if (current_buffer_ != nullptr) {
333 return false;
334 }
335 stream_.avail_in = length;
336 stream_.next_in = current_buffer_ = data;
337 return true;
338}
size_t length
static int8_t data[kExtLength]

◆ Processed()

intptr_t dart::bin::ZLibDeflateFilter::Processed ( uint8_t *  buffer,
intptr_t  length,
bool  finish,
bool  end 
)
virtual

Implements dart::bin::Filter.

Definition at line 340 of file filter.cc.

343 {
344 stream_.avail_out = length;
345 stream_.next_out = buffer;
346 bool error = false;
347 switch (deflate(&stream_, end ? Z_FINISH
348 : flush ? Z_SYNC_FLUSH
349 : Z_NO_FLUSH)) {
350 case Z_OK:
351 case Z_STREAM_END:
352 case Z_BUF_ERROR: {
353 intptr_t processed = length - stream_.avail_out;
354 if (processed == 0) {
355 break;
356 }
357 return processed;
358 }
359
360 default:
361 case Z_STREAM_ERROR:
362 error = true;
363 }
364
365 delete[] current_buffer_;
366 current_buffer_ = nullptr;
367 // Either 0 Byte processed or error
368 return error ? -1 : 0;
369}
const uint8_t uint32_t uint32_t GError ** error
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

The documentation for this class was generated from the following files: