| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 MOJO_DART_EMBEDDER_IO_FILTER_H_ | 5 #ifndef MOJO_DART_EMBEDDER_IO_FILTER_H_ |
| 6 #define MOJO_DART_EMBEDDER_IO_FILTER_H_ | 6 #define MOJO_DART_EMBEDDER_IO_FILTER_H_ |
| 7 | 7 |
| 8 #include "dart/runtime/include/dart_api.h" | 8 #include "dart/runtime/include/dart_api.h" |
| 9 #include "mojo/public/cpp/system/macros.h" | 9 #include "mojo/public/cpp/system/macros.h" |
| 10 #include "third_party/zlib/zlib.h" | 10 #include "third_party/zlib/zlib.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 class Filter { | 15 class Filter { |
| 16 public: | 16 public: |
| 17 virtual ~Filter() {} | 17 virtual ~Filter() {} |
| 18 | 18 |
| 19 virtual bool Init() = 0; | 19 virtual bool Init() = 0; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * On a successful call to Process, Process will take ownership of data. On | 22 * On a successful call to Process, Process will take ownership of data. On |
| 23 * successive calls to either Processed or ~Filter, data will be freed with | 23 * successive calls to either Processed or ~Filter, data will be freed with |
| 24 * a delete[] call. | 24 * a delete[] call. |
| 25 */ | 25 */ |
| 26 virtual bool Process(uint8_t* data, intptr_t length) = 0; | 26 virtual bool Process(uint8_t* data, intptr_t length) = 0; |
| 27 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish, | 27 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish, |
| 28 bool end) = 0; | 28 bool end) = 0; |
| 29 | 29 |
| 30 static Dart_Handle SetFilterPointerNativeField(Dart_Handle filter, | 30 static Dart_Handle SetFilterAndCreateFinalizer(Dart_Handle filter, |
| 31 Filter* filter_pointer); | 31 Filter* filter_pointer, |
| 32 static Dart_Handle GetFilterPointerNativeField(Dart_Handle filter, | 32 intptr_t filter_size); |
| 33 Filter** filter_pointer); | 33 static Dart_Handle GetFilterNativeField(Dart_Handle filter, |
| 34 Filter** filter_pointer); |
| 34 | 35 |
| 35 bool initialized() const { return initialized_; } | 36 bool initialized() const { return initialized_; } |
| 36 void set_initialized(bool value) { initialized_ = value; } | 37 void set_initialized(bool value) { initialized_ = value; } |
| 37 uint8_t* processed_buffer() { return processed_buffer_; } | 38 uint8_t* processed_buffer() { return processed_buffer_; } |
| 38 intptr_t processed_buffer_size() const { return kFilterBufferSize; } | 39 intptr_t processed_buffer_size() const { return kFilterBufferSize; } |
| 39 | 40 |
| 40 protected: | 41 protected: |
| 41 Filter() : initialized_(false) {} | 42 Filter() : initialized_(false) {} |
| 42 | 43 |
| 43 private: | 44 private: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 uint8_t* current_buffer_; | 102 uint8_t* current_buffer_; |
| 102 z_stream stream_; | 103 z_stream stream_; |
| 103 | 104 |
| 104 MOJO_DISALLOW_COPY_AND_ASSIGN(ZLibInflateFilter); | 105 MOJO_DISALLOW_COPY_AND_ASSIGN(ZLibInflateFilter); |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 } // namespace dart | 108 } // namespace dart |
| 108 } // namespace mojo | 109 } // namespace mojo |
| 109 | 110 |
| 110 #endif // MOJO_DART_EMBEDDER_IO_FILTER_H_ | 111 #endif // MOJO_DART_EMBEDDER_IO_FILTER_H_ |
| OLD | NEW |