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

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"
Adam Rice 2013/10/30 02:56:53 Not actually used.
yhirano 2013/10/30 03:19:47 Done.
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 // |frames[frame_index]| cannot be recorded yet and all preceding
41 // data frames have to be already recorded when this method is called.
42 virtual Result Predict(const ScopedVector<WebSocketFrame>& frames,
43 size_t frame_index) = 0;
44
45 // Records frame data for future prediction.
46 // Only data frames should be recorded. Do not pass control frames' data.
47 // All input data frames for the stream must be recorded in order.
48 virtual void RecordInputDataFrame(const WebSocketFrame* frame) = 0;
49
50 // Records frame data for future prediction.
51 // Only data frames should be recorded. Do not pass control frames' data.
52 // All data frames written by the stream must be recorded in order
53 // regardless of whether they are compressed or not.
54 virtual void RecordWrittenDataFrame(const WebSocketFrame* frame) = 0;
55 };
56
57 } // namespace net
58
59 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698