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

#include <filter.h>

Inheritance diagram for dart::bin::ZLibInflateFilter:
dart::bin::Filter

Public Member Functions

 ZLibInflateFilter (int32_t window_bits, uint8_t *dictionary, intptr_t dictionary_length, bool raw)
 
virtual ~ZLibInflateFilter ()
 
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 98 of file filter.h.

Constructor & Destructor Documentation

◆ ZLibInflateFilter()

dart::bin::ZLibInflateFilter::ZLibInflateFilter ( int32_t  window_bits,
uint8_t *  dictionary,
intptr_t  dictionary_length,
bool  raw 
)
inline

Definition at line 100 of file filter.h.

104 : window_bits_(window_bits),
105 dictionary_(dictionary),
106 dictionary_length_(dictionary_length),
107 raw_(raw),
108 current_buffer_(nullptr) {}

◆ ~ZLibInflateFilter()

dart::bin::ZLibInflateFilter::~ZLibInflateFilter ( )
virtual

Definition at line 371 of file filter.cc.

371 {
372 delete[] dictionary_;
373 delete[] current_buffer_;
374 if (initialized()) {
375 inflateEnd(&stream_);
376 }
377}
bool initialized() const
Definition: filter.h:39

Member Function Documentation

◆ Init()

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

Implements dart::bin::Filter.

Definition at line 379 of file filter.cc.

379 {
380 int window_bits =
381 raw_ ? -window_bits_ : window_bits_ | kZLibFlagAcceptAnyHeader;
382
383 stream_.next_in = Z_NULL;
384 stream_.avail_in = 0;
385 stream_.zalloc = Z_NULL;
386 stream_.zfree = Z_NULL;
387 stream_.opaque = Z_NULL;
388 int result = inflateInit2(&stream_, window_bits);
389 if (result != Z_OK) {
390 return false;
391 }
392 set_initialized(true);
393 return true;
394}
void set_initialized(bool value)
Definition: filter.h:40
GAsyncResult * result
const int kZLibFlagAcceptAnyHeader
Definition: filter.cc:16

◆ Process()

bool dart::bin::ZLibInflateFilter::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 396 of file filter.cc.

396 {
397 if (current_buffer_ != nullptr) {
398 return false;
399 }
400 stream_.avail_in = length;
401 stream_.next_in = current_buffer_ = data;
402 return true;
403}
size_t length
static int8_t data[kExtLength]

◆ Processed()

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

Implements dart::bin::Filter.

Definition at line 405 of file filter.cc.

408 {
409 stream_.avail_out = length;
410 stream_.next_out = buffer;
411 bool error = false;
412 int v;
413 switch (v = inflate(&stream_, end ? Z_FINISH
414 : flush ? Z_SYNC_FLUSH
415 : Z_NO_FLUSH)) {
416 case Z_OK:
417 case Z_STREAM_END:
418 case Z_BUF_ERROR: {
419 intptr_t processed = length - stream_.avail_out;
420
421 if (v == Z_STREAM_END) {
422 // Allow for concatenated compressed blocks. For example:
423 // final data = [
424 // ...gzip.encode([1, 2, 3]),
425 // ...gzip.encode([4, 5, 6]),
426 // ];
427 // final decoded = gzip.decode(data); // [1, 2, 3, 4, 5, 6]
428
429 // The return code for `inflateReset` can be ignored because, if the
430 // result is an error, the same error will be returned in the next
431 // call to `inflate`.
432 inflateReset(&stream_);
433 }
434 if (processed == 0) {
435 break;
436 }
437 return processed;
438 }
439
440 case Z_NEED_DICT:
441 if (dictionary_ == nullptr) {
442 error = true;
443 } else {
444 int result =
445 inflateSetDictionary(&stream_, dictionary_, dictionary_length_);
446 delete[] dictionary_;
447 dictionary_ = nullptr;
448 error = result != Z_OK;
449 }
450 if (error) {
451 break;
452 } else {
453 return Processed(buffer, length, flush, end);
454 }
455
456 default:
457 case Z_MEM_ERROR:
458 case Z_DATA_ERROR:
459 case Z_STREAM_ERROR:
460 error = true;
461 }
462
463 delete[] current_buffer_;
464 current_buffer_ = nullptr;
465 // Either 0 Byte processed or error
466 return error ? -1 : 0;
467}
virtual intptr_t Processed(uint8_t *buffer, intptr_t length, bool finish, bool end)
Definition: filter.cc:405
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: