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

Side by Side Diff: blimp/net/compressed_packet_reader.h

Issue 2632803002: Remove all blimp network code. (Closed)
Patch Set: merge from origin/master for good measure Created 3 years, 11 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
« no previous file with comments | « blimp/net/common.cc ('k') | blimp/net/compressed_packet_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BLIMP_NET_COMPRESSED_PACKET_READER_H_
6 #define BLIMP_NET_COMPRESSED_PACKET_READER_H_
7
8 #include <memory>
9
10 #include "base/memory/weak_ptr.h"
11 #include "blimp/net/blimp_net_export.h"
12 #include "blimp/net/packet_reader.h"
13 #include "net/base/completion_callback.h"
14 #include "net/base/io_buffer.h"
15 #include "third_party/zlib/zlib.h"
16
17 namespace blimp {
18
19 // Filter object which wraps a PacketReader, adding a DEFLATE decompression step
20 // to received packets.
21 // Details about the encoding format are available in the CompressedPacketWriter
22 // header.
23 class BLIMP_NET_EXPORT CompressedPacketReader : public PacketReader {
24 public:
25 // |source|: The source which from which compressed packets are read.
26 explicit CompressedPacketReader(std::unique_ptr<PacketReader> source);
27
28 ~CompressedPacketReader() override;
29
30 // PacketReader implementation.
31 void ReadPacket(const scoped_refptr<net::GrowableIOBuffer>& decompressed_buf,
32 const net::CompletionCallback& cb) override;
33
34 private:
35 // Called when source->ReadPacket() has completed.
36 // |buf|: The buffer which will receive decompressed data.
37 // |cb|: Callback which is triggered after decompression has finished.
38 // |result|: The result of the read operation.
39 void OnCompressedPacketReceived(
40 const scoped_refptr<net::GrowableIOBuffer> decompressed_buf,
41 const net::CompletionCallback& cb,
42 int result);
43
44 // Decompresses the contents of |compressed_buf_| to the buffer
45 // |decompressed_buf|. The size of |compressed_buf| is passed with the
46 // argument |size_compressed|.
47 // On success, returns a >= 0 value indicating the size of the
48 // decompressed payload.
49 // On failure, returns a negative value indicating the error code
50 // (see net_errors.h).
51 int DecompressPacket(
52 const scoped_refptr<net::GrowableIOBuffer>& decompressed_buf,
53 int size_compressed);
54
55 std::unique_ptr<PacketReader> source_;
56 scoped_refptr<net::GrowableIOBuffer> compressed_buf_;
57 z_stream zlib_stream_;
58
59 // Used to abandon pending ReadPacket() calls on teardown.
60 base::WeakPtrFactory<CompressedPacketReader> weak_factory_;
61
62 DISALLOW_COPY_AND_ASSIGN(CompressedPacketReader);
63 };
64
65 } // namespace blimp
66
67 #endif // BLIMP_NET_COMPRESSED_PACKET_READER_H_
OLDNEW
« no previous file with comments | « blimp/net/common.cc ('k') | blimp/net/compressed_packet_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698