OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "net/websockets/websocket_channel.h" | 5 #include "net/websockets/websocket_channel.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" // for size_t | 9 #include "base/basictypes.h" // for size_t |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/safe_numerics.h" | 12 #include "base/numerics/safe_conversions.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "net/base/big_endian.h" | 15 #include "net/base/big_endian.h" |
16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
17 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
18 #include "net/http/http_util.h" | 18 #include "net/http/http_util.h" |
19 #include "net/websockets/websocket_errors.h" | 19 #include "net/websockets/websocket_errors.h" |
20 #include "net/websockets/websocket_event_interface.h" | 20 #include "net/websockets/websocket_event_interface.h" |
21 #include "net/websockets/websocket_frame.h" | 21 #include "net/websockets/websocket_frame.h" |
22 #include "net/websockets/websocket_mux.h" | 22 #include "net/websockets/websocket_mux.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 183 } |
184 if (InClosingState()) { | 184 if (InClosingState()) { |
185 VLOG(1) << "SendFrame called in state " << state_ | 185 VLOG(1) << "SendFrame called in state " << state_ |
186 << ". This may be a bug, or a harmless race."; | 186 << ". This may be a bug, or a harmless race."; |
187 return; | 187 return; |
188 } | 188 } |
189 if (state_ != CONNECTED) { | 189 if (state_ != CONNECTED) { |
190 NOTREACHED() << "SendFrame() called in state " << state_; | 190 NOTREACHED() << "SendFrame() called in state " << state_; |
191 return; | 191 return; |
192 } | 192 } |
193 if (data.size() > base::checked_numeric_cast<size_t>(current_send_quota_)) { | 193 if (data.size() > base::checked_cast<size_t>(current_send_quota_)) { |
194 AllowUnused(FailChannel(SEND_GOING_AWAY, | 194 AllowUnused(FailChannel(SEND_GOING_AWAY, |
195 kWebSocketMuxErrorSendQuotaViolation, | 195 kWebSocketMuxErrorSendQuotaViolation, |
196 "Send quota exceeded")); | 196 "Send quota exceeded")); |
197 // |this| has been deleted. | 197 // |this| has been deleted. |
198 return; | 198 return; |
199 } | 199 } |
200 if (!WebSocketFrameHeader::IsKnownDataOpCode(op_code)) { | 200 if (!WebSocketFrameHeader::IsKnownDataOpCode(op_code)) { |
201 LOG(DFATAL) << "Got SendFrame with bogus op_code " << op_code | 201 LOG(DFATAL) << "Got SendFrame with bogus op_code " << op_code |
202 << "; misbehaving renderer? fin=" << fin | 202 << "; misbehaving renderer? fin=" << fin |
203 << " data.size()=" << data.size(); | 203 << " data.size()=" << data.size(); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 void WebSocketChannel::CloseTimeout() { | 712 void WebSocketChannel::CloseTimeout() { |
713 stream_->Close(); | 713 stream_->Close(); |
714 DCHECK_NE(CLOSED, state_); | 714 DCHECK_NE(CLOSED, state_); |
715 state_ = CLOSED; | 715 state_ = CLOSED; |
716 AllowUnused(event_interface_->OnDropChannel(kWebSocketErrorAbnormalClosure, | 716 AllowUnused(event_interface_->OnDropChannel(kWebSocketErrorAbnormalClosure, |
717 "Abnormal Closure")); | 717 "Abnormal Closure")); |
718 // |this| has been deleted. | 718 // |this| has been deleted. |
719 } | 719 } |
720 | 720 |
721 } // namespace net | 721 } // namespace net |
OLD | NEW |