OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PREDICTOR_H_ | |
6 #define NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PREDICTOR_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/scoped_vector.h" | |
11 #include "net/base/net_export.h" | |
12 | |
13 namespace net { | |
14 | |
15 struct WebSocketFrame; | |
16 | |
17 // WebSocketDeflatePredictor is an interface class used for judging whether | |
18 // a WebSocketDeflateStream should compress a message or not. | |
19 class NET_EXPORT_PRIVATE WebSocketDeflatePredictor { | |
20 public: | |
21 enum Result { | |
22 // Deflate and send the message. | |
23 DEFLATE, | |
24 // Do not deflate and send the original message. | |
25 DO_NOT_DEFLATE, | |
26 // Try compressing the message and send the smaller one of the original | |
27 // and the compressed message. | |
28 // Returning this result implies that the deflater is running on | |
29 // DoNotTakeOverContext mode and the entire message is visible. | |
30 TRY_DEFLATE, | |
31 }; | |
32 | |
33 virtual ~WebSocketDeflatePredictor() {} | |
34 | |
35 // Predicts and returns whether the deflater should deflate the message | |
36 // which begins with |frames[frame_index]| or not. | |
37 // frames[(frame_index + 1):] consists of future frames. | |
38 // |frames[frame_index]| must be the first frame of a data message, | |
39 // but future frames may contain control message frames. | |
Adam Rice
2013/10/25 13:05:25
You might want to mention that if frame_index is t
yhirano
2013/10/28 01:42:46
I intended to use Python notation which will work
| |
40 virtual Result Predict(const ScopedVector<WebSocketFrame>& frames, | |
41 size_t frame_index) = 0; | |
42 | |
43 // Records frame data for future prediction. | |
44 // Only data frames should be recorded. Do not pass control frames' data. | |
45 // All input data frames must be recorded in order. | |
46 virtual void RecordProcessedDataFrame(const WebSocketFrame* frame) = 0; | |
47 | |
48 // Records frame data for future prediction. | |
49 // Only data frames should be recorded. Do not pass control frames' data. | |
50 // All sent data frames must be recorded in order regardless of whether | |
51 // they are compressed or not. | |
52 virtual void RecordSentDataFrame(const WebSocketFrame* frame) = 0; | |
53 }; | |
54 | |
55 } // namespace net | |
56 | |
57 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PREDICTOR_H_ | |
OLD | NEW |