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

Side by Side Diff: net/websockets/websocket_deflate_predictor.h

Issue 39193005: Introduce WebSocketDeflatePredictor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
OLDNEW
(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 if any.
38 // |frames[frame_index]| must be the first frame of a data message,
39 // but future frames may contain control message frames.
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;
Adam Rice 2013/10/29 04:11:42 I assume this should be called after Predict(), so
yhirano 2013/10/29 06:11:06 Predict will be called only for the first frame of
Adam Rice 2013/10/30 00:28:07 Is it okay to call this method before Predict() fo
yhirano 2013/10/30 02:20:33 I added |Predict| comment.
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;
Adam Rice 2013/10/29 04:11:42 It's ambiguous whether this is supposed to be call
yhirano 2013/10/29 06:11:06 s/Sent/Written/g and add "by the stream"
53 };
54
55 } // namespace net
56
57 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698