| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_WEBSOCKETS_WEBSOCKET_DEFLATE_PARAMETERS_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PARAMETERS_H_ |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PARAMETERS_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PARAMETERS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 void SetClientMaxWindowBits() { | 87 void SetClientMaxWindowBits() { |
| 88 client_max_window_bits_ = WindowBits(0, true, false); | 88 client_max_window_bits_ = WindowBits(0, true, false); |
| 89 } | 89 } |
| 90 // |bits| must be valid as a max_window_bits value. | 90 // |bits| must be valid as a max_window_bits value. |
| 91 void SetClientMaxWindowBits(int bits) { | 91 void SetClientMaxWindowBits(int bits) { |
| 92 DCHECK(IsValidWindowBits(bits)); | 92 DCHECK(IsValidWindowBits(bits)); |
| 93 client_max_window_bits_ = WindowBits(bits, true, true); | 93 client_max_window_bits_ = WindowBits(bits, true, true); |
| 94 } | 94 } |
| 95 | 95 |
| 96 int PermissiveServerMaxWindowBits() const { |
| 97 return server_max_window_bits_.PermissiveBits(); |
| 98 } |
| 99 int PermissiveClientMaxWindowBits() const { |
| 100 return client_max_window_bits_.PermissiveBits(); |
| 101 } |
| 102 |
| 96 // Return true if |bits| is valid as a max_window_bits value. | 103 // Return true if |bits| is valid as a max_window_bits value. |
| 97 static bool IsValidWindowBits(int bits) { return 8 <= bits && bits <= 15; } | 104 static bool IsValidWindowBits(int bits) { return 8 <= bits && bits <= 15; } |
| 98 | 105 |
| 99 private: | 106 private: |
| 100 struct WindowBits { | 107 struct WindowBits { |
| 101 WindowBits() : WindowBits(0, false, false) {} | 108 WindowBits() : WindowBits(0, false, false) {} |
| 102 WindowBits(int16 bits, bool is_specified, bool has_value) | 109 WindowBits(int16 bits, bool is_specified, bool has_value) |
| 103 : bits(bits), is_specified(is_specified), has_value(has_value) {} | 110 : bits(bits), is_specified(is_specified), has_value(has_value) {} |
| 104 | 111 |
| 112 int PermissiveBits() const { return is_specified && has_value ? bits : 15; } |
| 113 |
| 105 int16 bits; | 114 int16 bits; |
| 106 // True when "window bits" parameter appears in the parameters. | 115 // True when "window bits" parameter appears in the parameters. |
| 107 bool is_specified; | 116 bool is_specified; |
| 108 // True when "window bits" parameter has the value. | 117 // True when "window bits" parameter has the value. |
| 109 bool has_value; | 118 bool has_value; |
| 110 }; | 119 }; |
| 111 | 120 |
| 112 // |server_context_take_over_mode| is set to DO_NOT_TAKE_OVER_CONTEXT if and | 121 // |server_context_take_over_mode| is set to DO_NOT_TAKE_OVER_CONTEXT if and |
| 113 // only if |server_no_context_takeover| is set in the parameters. | 122 // only if |server_no_context_takeover| is set in the parameters. |
| 114 ContextTakeOverMode server_context_take_over_mode_ = | 123 ContextTakeOverMode server_context_take_over_mode_ = |
| 115 WebSocketDeflater::TAKE_OVER_CONTEXT; | 124 WebSocketDeflater::TAKE_OVER_CONTEXT; |
| 116 // |client_context_take_over_mode| is set to DO_NOT_TAKE_OVER_CONTEXT if and | 125 // |client_context_take_over_mode| is set to DO_NOT_TAKE_OVER_CONTEXT if and |
| 117 // only if |client_no_context_takeover| is set in the parameters. | 126 // only if |client_no_context_takeover| is set in the parameters. |
| 118 ContextTakeOverMode client_context_take_over_mode_ = | 127 ContextTakeOverMode client_context_take_over_mode_ = |
| 119 WebSocketDeflater::TAKE_OVER_CONTEXT; | 128 WebSocketDeflater::TAKE_OVER_CONTEXT; |
| 120 WindowBits server_max_window_bits_; | 129 WindowBits server_max_window_bits_; |
| 121 WindowBits client_max_window_bits_; | 130 WindowBits client_max_window_bits_; |
| 122 }; | 131 }; |
| 123 | 132 |
| 124 } // namespace net | 133 } // namespace net |
| 125 | 134 |
| 126 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PARAMETERS_H_ | 135 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATE_PARAMETERS_H_ |
| OLD | NEW |