| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SERVER_WEB_SOCKET_ENCODER_H_ | 5 #ifndef NET_SERVER_WEB_SOCKET_ENCODER_H_ |
| 6 #define NET_SERVER_WEB_SOCKET_ENCODER_H_ | 6 #define NET_SERVER_WEB_SOCKET_ENCODER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 static scoped_ptr<WebSocketEncoder> CreateClient( | 35 static scoped_ptr<WebSocketEncoder> CreateClient( |
| 36 const std::string& response_extensions); | 36 const std::string& response_extensions); |
| 37 | 37 |
| 38 WebSocket::ParseResult DecodeFrame(const base::StringPiece& frame, | 38 WebSocket::ParseResult DecodeFrame(const base::StringPiece& frame, |
| 39 int* bytes_consumed, | 39 int* bytes_consumed, |
| 40 std::string* output); | 40 std::string* output); |
| 41 void EncodeFrame(const std::string& frame, | 41 void EncodeFrame(const std::string& frame, |
| 42 int masking_key, | 42 int masking_key, |
| 43 std::string* output); | 43 std::string* output); |
| 44 | 44 |
| 45 bool deflate_enabled() const { return deflater_; } | 45 bool deflate_enabled() const { return !!deflater_; } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 enum Type { | 48 enum Type { |
| 49 FOR_SERVER, | 49 FOR_SERVER, |
| 50 FOR_CLIENT, | 50 FOR_CLIENT, |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 WebSocketEncoder(Type type, | 53 WebSocketEncoder(Type type, |
| 54 scoped_ptr<WebSocketDeflater> deflater, | 54 scoped_ptr<WebSocketDeflater> deflater, |
| 55 scoped_ptr<WebSocketInflater> inflater); | 55 scoped_ptr<WebSocketInflater> inflater); |
| 56 | 56 |
| 57 bool Inflate(std::string* message); | 57 bool Inflate(std::string* message); |
| 58 bool Deflate(const std::string& message, std::string* output); | 58 bool Deflate(const std::string& message, std::string* output); |
| 59 | 59 |
| 60 Type type_; | 60 Type type_; |
| 61 scoped_ptr<WebSocketDeflater> deflater_; | 61 scoped_ptr<WebSocketDeflater> deflater_; |
| 62 scoped_ptr<WebSocketInflater> inflater_; | 62 scoped_ptr<WebSocketInflater> inflater_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder); | 64 DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace net | 67 } // namespace net |
| 68 | 68 |
| 69 #endif // NET_SERVER_WEB_SOCKET_ENCODER_H_ | 69 #endif // NET_SERVER_WEB_SOCKET_ENCODER_H_ |
| OLD | NEW |