Chromium Code Reviews| Index: net/server/web_socket_encoder.h |
| diff --git a/net/server/web_socket_encoder.h b/net/server/web_socket_encoder.h |
| index 23f0d9cc075b15471ce7c3ef0b54f877f9be809a..1eb749f7c81d894a1f29157eaa9a3c5431c20d5d 100644 |
| --- a/net/server/web_socket_encoder.h |
| +++ b/net/server/web_socket_encoder.h |
| @@ -16,61 +16,50 @@ |
| namespace net { |
| -class WebSocketEncoder { |
| +class WebSocketDeflateParameters; |
| + |
| +class WebSocketEncoder final { |
| public: |
| - ~WebSocketEncoder(); |
| + static const char kClientExtensions[]; |
| - static WebSocketEncoder* CreateServer(const std::string& request_extensions, |
| - std::string* response_extensions); |
| + ~WebSocketEncoder(); |
| - static const char kClientExtensions[]; |
| + // Creates and returns an encoder for a server without extensions. |
| + static scoped_ptr<WebSocketEncoder> CreateServer(); |
| + // Creates and returns an encoder. |
| + // |extensions| is the value of a Sec-WebSocket-Extensions header. |
| + // Returns nullptr when there is an error. |
| + static scoped_ptr<WebSocketEncoder> CreateServer( |
| + const std::string& extensions, |
|
tyoshino (SeeGerritForStatus)
2015/09/16 09:33:10
request_extensions, or change to extensions in .cc
yhirano
2015/09/16 10:47:46
Done.
|
| + WebSocketDeflateParameters* params); |
| + // TODO(yhirano): Return a scoped_ptr instead of a raw pointer. |
| static WebSocketEncoder* CreateClient(const std::string& response_extensions); |
| WebSocket::ParseResult DecodeFrame(const base::StringPiece& frame, |
| int* bytes_consumed, |
| std::string* output); |
| - |
| void EncodeFrame(const std::string& frame, |
| int masking_key, |
| std::string* output); |
| + bool deflate_enabled() const { return deflater_; } |
| + |
| private: |
| - explicit WebSocketEncoder(bool is_server); |
| - WebSocketEncoder(bool is_server, |
| - int deflate_bits, |
| - int inflate_bits, |
| - bool no_context_takeover); |
| - |
| - // Parses a value in the Sec-WebSocket-Extensions header. If it contains a |
| - // single element of the permessage-deflate extension, stores the result of |
| - // parsing the parameters of the extension into the given variables. |
| - // Otherwise, returns with *deflate set to false. |
| - // |
| - // - If the client_max_window_bits parameter is missing, *client_window_bits |
| - // defaults to 15. |
| - // - If the client_max_window_bits parameter has an invalid value, |
| - // *client_window_bits will be set to 0. |
| - // - If the server_max_window_bits parameter is missing, *server_window_bits |
| - // defaults to 15. |
| - // - If the server_max_window_bits parameter has an invalid value, |
| - // *client_window_bits will be set to 0. |
| - // |
| - // TODO(tyoshino): Consider using a struct than taking a lot of pointers for |
| - // output. |
| - static void ParseExtensions(const std::string& header_value, |
| - bool* deflate, |
| - bool* has_client_window_bits, |
| - int* client_window_bits, |
| - int* server_window_bits, |
| - bool* client_no_context_takeover, |
| - bool* server_no_context_takeover); |
| + enum Type { |
| + FOR_SERVER, |
| + FOR_CLIENT, |
| + }; |
| + |
| + WebSocketEncoder(Type type, |
| + scoped_ptr<WebSocketDeflater> deflater, |
| + scoped_ptr<WebSocketInflater> inflater); |
| bool Inflate(std::string* message); |
| bool Deflate(const std::string& message, std::string* output); |
| + Type type_; |
| scoped_ptr<WebSocketDeflater> deflater_; |
| scoped_ptr<WebSocketInflater> inflater_; |
| - bool is_server_; |
| DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder); |
| }; |