OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_NET_STREAM_PACKET_READER_H_ | 5 #ifndef BLIMP_NET_STREAM_PACKET_READER_H_ |
6 #define BLIMP_NET_STREAM_PACKET_READER_H_ | 6 #define BLIMP_NET_STREAM_PACKET_READER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // kMaxPacketPayloadSizeBytes). | 26 // kMaxPacketPayloadSizeBytes). |
27 class BLIMP_NET_EXPORT StreamPacketReader : public PacketReader { | 27 class BLIMP_NET_EXPORT StreamPacketReader : public PacketReader { |
28 public: | 28 public: |
29 // |socket|: The socket to read packets from. The caller must ensure |socket| | 29 // |socket|: The socket to read packets from. The caller must ensure |socket| |
30 // is valid while the reader is in-use (see ReadPacket below). | 30 // is valid while the reader is in-use (see ReadPacket below). |
31 explicit StreamPacketReader(net::StreamSocket* socket); | 31 explicit StreamPacketReader(net::StreamSocket* socket); |
32 | 32 |
33 ~StreamPacketReader() override; | 33 ~StreamPacketReader() override; |
34 | 34 |
35 // PacketReader implementation. | 35 // PacketReader implementation. |
36 int ReadPacket(const scoped_refptr<net::GrowableIOBuffer>& buf, | 36 void ReadPacket(const scoped_refptr<net::GrowableIOBuffer>& buf, |
37 const net::CompletionCallback& cb) override; | 37 const net::CompletionCallback& cb) override; |
38 | 38 |
39 private: | 39 private: |
40 enum class ReadState { | 40 enum class ReadState { |
41 IDLE, | 41 IDLE, |
42 HEADER, | 42 HEADER, |
43 PAYLOAD, | 43 PAYLOAD, |
44 }; | 44 }; |
45 | 45 |
46 friend std::ostream& operator<<(std::ostream& out, const ReadState state); | 46 friend std::ostream& operator<<(std::ostream& out, const ReadState state); |
47 | 47 |
(...skipping 24 matching lines...) Expand all Loading... |
72 net::CompletionCallback callback_; | 72 net::CompletionCallback callback_; |
73 | 73 |
74 base::WeakPtrFactory<StreamPacketReader> weak_factory_; | 74 base::WeakPtrFactory<StreamPacketReader> weak_factory_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(StreamPacketReader); | 76 DISALLOW_COPY_AND_ASSIGN(StreamPacketReader); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace blimp | 79 } // namespace blimp |
80 | 80 |
81 #endif // BLIMP_NET_STREAM_PACKET_READER_H_ | 81 #endif // BLIMP_NET_STREAM_PACKET_READER_H_ |
OLD | NEW |