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

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

Issue 11275035: Introduce (private) ZLibFilter to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add InternalError class and LICENSE file. Created 8 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 #ifndef BIN_FILTER_H_
6 #define BIN_FILTER_H_
7
8 #include "bin/builtin.h"
9 #include "bin/utils.h"
10
11 #include "third_party/zlib/zlib.h"
12
13 class Filter {
14 protected:
15 Filter() {}
16
17 public:
18 virtual ~Filter() {}
19
20 public:
21 virtual bool Init() = 0;
22 /**
23 * On a succesfull call to Process, Process will take ownership of data.
24 */
25 virtual bool Process(uint8_t* data, intptr_t length) = 0;
26 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish) = 0;
27
28
29 public:
30 static Dart_Handle SetFilterPointerNativeField(Dart_Handle filter,
31 Filter* filter_pointer);
32 static Dart_Handle GetFilterPointerNativeField(Dart_Handle filter,
33 Filter** filter_pointer);
34 };
35
36 class ZLibDeflateFilter : public Filter {
37 public:
38 ZLibDeflateFilter(bool gZip = false, int level = 6)
39 : gZip(gZip), level(level), current_buffer(NULL) {}
40 virtual ~ZLibDeflateFilter();
41
42 public:
43 virtual bool Init();
44 virtual bool Process(uint8_t* data, intptr_t length);
45 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish);
46
47 private:
48 const bool gZip;
49 const int level;
50 uint8_t* current_buffer;
51 z_stream stream;
52 };
53
54 class ZLibInflateFilter : public Filter {
55 public:
56 ZLibInflateFilter() : current_buffer(NULL) {}
57 virtual ~ZLibInflateFilter();
58
59 public:
60 virtual bool Init();
61 virtual bool Process(uint8_t* data, intptr_t length);
62 virtual intptr_t Processed(uint8_t* buffer, intptr_t length, bool finish);
63
64 private:
65 uint8_t* current_buffer;
66 z_stream stream;
67 };
68
69 #endif // BIN_FILTER_H_
70
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698