OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 NET_WEBSOCKETS_WEBSOCKET_DEFLATE_STREAM_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_DEFLATE_STREAM_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_DEFLATE_STREAM_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_DEFLATE_STREAM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 #include "net/websockets/websocket_deflater.h" | 15 #include "net/websockets/websocket_deflater.h" |
16 #include "net/websockets/websocket_frame.h" | 16 #include "net/websockets/websocket_frame.h" |
17 #include "net/websockets/websocket_inflater.h" | 17 #include "net/websockets/websocket_inflater.h" |
18 #include "net/websockets/websocket_stream.h" | 18 #include "net/websockets/websocket_stream.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
| 24 class WebSocketDeflateParameters; |
24 class WebSocketDeflatePredictor; | 25 class WebSocketDeflatePredictor; |
25 | 26 |
26 // WebSocketDeflateStream is a WebSocketStream subclass. | 27 // WebSocketDeflateStream is a WebSocketStream subclass. |
27 // WebSocketDeflateStream is for permessage-deflate WebSocket extension[1]. | 28 // WebSocketDeflateStream is for permessage-deflate WebSocket extension[1]. |
28 // | 29 // |
29 // WebSocketDeflateStream::ReadFrames and WriteFrames may change frame | 30 // WebSocketDeflateStream::ReadFrames and WriteFrames may change frame |
30 // boundary. In particular, if a control frame is placed in the middle of | 31 // boundary. In particular, if a control frame is placed in the middle of |
31 // data message frames, the control frame can overtake data frames. | 32 // data message frames, the control frame can overtake data frames. |
32 // Say there are frames df1, df2 and cf, df1 and df2 are frames of a | 33 // Say there are frames df1, df2 and cf, df1 and df2 are frames of a |
33 // data message and cf is a control message frame. cf may arrive first and | 34 // data message and cf is a control message frame. cf may arrive first and |
34 // data frames may follow cf. | 35 // data frames may follow cf. |
35 // Note that message boundary will be preserved, i.e. if the last frame of | 36 // Note that message boundary will be preserved, i.e. if the last frame of |
36 // a message m1 is read / written before the last frame of a message m2, | 37 // a message m1 is read / written before the last frame of a message m2, |
37 // WebSocketDeflateStream will respect the order. | 38 // WebSocketDeflateStream will respect the order. |
38 // | 39 // |
39 // [1]: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-12 | 40 // [1]: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-12 |
40 class NET_EXPORT_PRIVATE WebSocketDeflateStream : public WebSocketStream { | 41 class NET_EXPORT_PRIVATE WebSocketDeflateStream : public WebSocketStream { |
41 public: | 42 public: |
42 WebSocketDeflateStream(scoped_ptr<WebSocketStream> stream, | 43 WebSocketDeflateStream(scoped_ptr<WebSocketStream> stream, |
43 WebSocketDeflater::ContextTakeOverMode mode, | 44 const WebSocketDeflateParameters& params, |
44 int client_window_bits, | |
45 scoped_ptr<WebSocketDeflatePredictor> predictor); | 45 scoped_ptr<WebSocketDeflatePredictor> predictor); |
46 ~WebSocketDeflateStream() override; | 46 ~WebSocketDeflateStream() override; |
47 | 47 |
48 // WebSocketStream functions. | 48 // WebSocketStream functions. |
49 int ReadFrames(ScopedVector<WebSocketFrame>* frames, | 49 int ReadFrames(ScopedVector<WebSocketFrame>* frames, |
50 const CompletionCallback& callback) override; | 50 const CompletionCallback& callback) override; |
51 int WriteFrames(ScopedVector<WebSocketFrame>* frames, | 51 int WriteFrames(ScopedVector<WebSocketFrame>* frames, |
52 const CompletionCallback& callback) override; | 52 const CompletionCallback& callback) override; |
53 void Close() override; | 53 void Close() override; |
54 std::string GetSubProtocol() const override; | 54 std::string GetSubProtocol() const override; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 WebSocketFrameHeader::OpCode current_reading_opcode_; | 96 WebSocketFrameHeader::OpCode current_reading_opcode_; |
97 WebSocketFrameHeader::OpCode current_writing_opcode_; | 97 WebSocketFrameHeader::OpCode current_writing_opcode_; |
98 scoped_ptr<WebSocketDeflatePredictor> predictor_; | 98 scoped_ptr<WebSocketDeflatePredictor> predictor_; |
99 | 99 |
100 DISALLOW_COPY_AND_ASSIGN(WebSocketDeflateStream); | 100 DISALLOW_COPY_AND_ASSIGN(WebSocketDeflateStream); |
101 }; | 101 }; |
102 | 102 |
103 } // namespace net | 103 } // namespace net |
104 | 104 |
105 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATE_STREAM_H_ | 105 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATE_STREAM_H_ |
OLD | NEW |