Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: runtime/bin/filter.h

Issue 14962006: Actually end a ZLib stream with a Z_FINISH marker. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/filter.cc » ('j') | tests/standalone/io/zlib_test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_FILTER_H_ 5 #ifndef BIN_FILTER_H_
6 #define BIN_FILTER_H_ 6 #define BIN_FILTER_H_
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
11 #include "../third_party/zlib/zlib.h" 11 #include "../third_party/zlib/zlib.h"
12 12
13 13
14 namespace dart { 14 namespace dart {
15 namespace bin { 15 namespace bin {
16 16
17 class Filter { 17 class Filter {
18 public: 18 public:
19 virtual ~Filter() {} 19 virtual ~Filter() {}
20 20
21 virtual bool Init() = 0; 21 virtual bool Init() = 0;
22 22
23 /** 23 /**
24 * On a succesfull call to Process, Process will take ownership of data. On 24 * On a succesfull call to Process, Process will take ownership of data. On
25 * successive calls to either Processed or ~Filter, data will be freed with 25 * successive calls to either Processed or ~Filter, data will be freed with
26 * a delete[] call. 26 * a delete[] call.
27 */ 27 */
28 virtual bool Process(uint8_t* data, intptr_t length) = 0; 28 virtual bool Process(uint8_t* data, intptr_t length) = 0;
29 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish) = 0; 29 virtual intptr_t Processed(uint8_t* buffer,
30 intptr_t length,
31 bool finish,
32 bool end) = 0;
30 33
31 static Dart_Handle SetFilterPointerNativeField(Dart_Handle filter, 34 static Dart_Handle SetFilterPointerNativeField(Dart_Handle filter,
32 Filter* filter_pointer); 35 Filter* filter_pointer);
33 static Dart_Handle GetFilterPointerNativeField(Dart_Handle filter, 36 static Dart_Handle GetFilterPointerNativeField(Dart_Handle filter,
34 Filter** filter_pointer); 37 Filter** filter_pointer);
35 38
36 bool initialized() const { return initialized_; } 39 bool initialized() const { return initialized_; }
37 void set_initialized(bool value) { initialized_ = value; } 40 void set_initialized(bool value) { initialized_ = value; }
38 uint8_t* processed_buffer() { return processed_buffer_; } 41 uint8_t* processed_buffer() { return processed_buffer_; }
39 intptr_t processed_buffer_size() const { return kFilterBufferSize; } 42 intptr_t processed_buffer_size() const { return kFilterBufferSize; }
(...skipping 10 matching lines...) Expand all
50 }; 53 };
51 54
52 class ZLibDeflateFilter : public Filter { 55 class ZLibDeflateFilter : public Filter {
53 public: 56 public:
54 ZLibDeflateFilter(bool gzip = false, int level = 6) 57 ZLibDeflateFilter(bool gzip = false, int level = 6)
55 : gzip_(gzip), level_(level), current_buffer_(NULL) {} 58 : gzip_(gzip), level_(level), current_buffer_(NULL) {}
56 virtual ~ZLibDeflateFilter(); 59 virtual ~ZLibDeflateFilter();
57 60
58 virtual bool Init(); 61 virtual bool Init();
59 virtual bool Process(uint8_t* data, intptr_t length); 62 virtual bool Process(uint8_t* data, intptr_t length);
60 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish); 63 virtual intptr_t Processed(uint8_t* buffer,
64 intptr_t length,
65 bool finish,
66 bool end);
61 67
62 private: 68 private:
63 const bool gzip_; 69 const bool gzip_;
64 const int level_; 70 const int level_;
65 uint8_t* current_buffer_; 71 uint8_t* current_buffer_;
66 z_stream stream_; 72 z_stream stream_;
67 73
68 DISALLOW_COPY_AND_ASSIGN(ZLibDeflateFilter); 74 DISALLOW_COPY_AND_ASSIGN(ZLibDeflateFilter);
69 }; 75 };
70 76
71 class ZLibInflateFilter : public Filter { 77 class ZLibInflateFilter : public Filter {
72 public: 78 public:
73 ZLibInflateFilter() : current_buffer_(NULL) {} 79 ZLibInflateFilter() : current_buffer_(NULL) {}
74 virtual ~ZLibInflateFilter(); 80 virtual ~ZLibInflateFilter();
75 81
76 virtual bool Init(); 82 virtual bool Init();
77 virtual bool Process(uint8_t* data, intptr_t length); 83 virtual bool Process(uint8_t* data, intptr_t length);
78 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish); 84 virtual intptr_t Processed(uint8_t* buffer,
85 intptr_t length,
86 bool finish,
87 bool end);
79 88
80 private: 89 private:
81 uint8_t* current_buffer_; 90 uint8_t* current_buffer_;
82 z_stream stream_; 91 z_stream stream_;
83 92
84 DISALLOW_COPY_AND_ASSIGN(ZLibInflateFilter); 93 DISALLOW_COPY_AND_ASSIGN(ZLibInflateFilter);
85 }; 94 };
86 95
87 } // namespace bin 96 } // namespace bin
88 } // namespace dart 97 } // namespace dart
89 98
90 #endif // BIN_FILTER_H_ 99 #endif // BIN_FILTER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/filter.cc » ('j') | tests/standalone/io/zlib_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698