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

Side by Side Diff: net/websockets/websocket_channel.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/websockets/websocket_channel.h ('k') | sandbox/linux/bpf_dsl/bpf_dsl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits.h> // for INT_MAX 7 #include <limits.h> // for INT_MAX
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <deque> 10 #include <deque>
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 WebSocketChannel::WebSocketChannel( 290 WebSocketChannel::WebSocketChannel(
291 scoped_ptr<WebSocketEventInterface> event_interface, 291 scoped_ptr<WebSocketEventInterface> event_interface,
292 URLRequestContext* url_request_context) 292 URLRequestContext* url_request_context)
293 : event_interface_(event_interface.Pass()), 293 : event_interface_(event_interface.Pass()),
294 url_request_context_(url_request_context), 294 url_request_context_(url_request_context),
295 send_quota_low_water_mark_(kDefaultSendQuotaLowWaterMark), 295 send_quota_low_water_mark_(kDefaultSendQuotaLowWaterMark),
296 send_quota_high_water_mark_(kDefaultSendQuotaHighWaterMark), 296 send_quota_high_water_mark_(kDefaultSendQuotaHighWaterMark),
297 current_send_quota_(0), 297 current_send_quota_(0),
298 current_receive_quota_(0), 298 current_receive_quota_(0),
299 timeout_(base::TimeDelta::FromSeconds(kClosingHandshakeTimeoutSeconds)), 299 timeout_(base::TimeDelta::FromSeconds(kClosingHandshakeTimeoutSeconds)),
300 has_received_close_frame_(false),
300 received_close_code_(0), 301 received_close_code_(0),
301 state_(FRESHLY_CONSTRUCTED), 302 state_(FRESHLY_CONSTRUCTED),
302 notification_sender_(new HandshakeNotificationSender(this)), 303 notification_sender_(new HandshakeNotificationSender(this)),
303 sending_text_message_(false), 304 sending_text_message_(false),
304 receiving_text_message_(false), 305 receiving_text_message_(false),
305 expecting_to_handle_continuation_(false), 306 expecting_to_handle_continuation_(false),
306 initial_frame_forwarded_(false) {} 307 initial_frame_forwarded_(false) {}
307 308
308 WebSocketChannel::~WebSocketChannel() { 309 WebSocketChannel::~WebSocketChannel() {
309 // The stream may hold a pointer to read_frames_, and so it needs to be 310 // The stream may hold a pointer to read_frames_, and so it needs to be
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 default: 738 default:
738 DCHECK_LT(result, 0) 739 DCHECK_LT(result, 0)
739 << "ReadFrames() should only return OK or ERR_ codes"; 740 << "ReadFrames() should only return OK or ERR_ codes";
740 741
741 stream_->Close(); 742 stream_->Close();
742 SetState(CLOSED); 743 SetState(CLOSED);
743 744
744 uint16 code = kWebSocketErrorAbnormalClosure; 745 uint16 code = kWebSocketErrorAbnormalClosure;
745 std::string reason = ""; 746 std::string reason = "";
746 bool was_clean = false; 747 bool was_clean = false;
747 if (received_close_code_ != 0) { 748 if (has_received_close_frame_) {
748 code = received_close_code_; 749 code = received_close_code_;
749 reason = received_close_reason_; 750 reason = received_close_reason_;
750 was_clean = (result == ERR_CONNECTION_CLOSED); 751 was_clean = (result == ERR_CONNECTION_CLOSED);
751 } 752 }
752 753
753 return DoDropChannel(was_clean, code, reason); 754 return DoDropChannel(was_clean, code, reason);
754 } 755 }
755 } 756 }
756 757
757 ChannelState WebSocketChannel::HandleFrame(scoped_ptr<WebSocketFrame> frame) { 758 ChannelState WebSocketChannel::HandleFrame(scoped_ptr<WebSocketFrame> frame) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 switch (state_) { 838 switch (state_) {
838 case CONNECTED: 839 case CONNECTED:
839 SetState(RECV_CLOSED); 840 SetState(RECV_CLOSED);
840 if (SendClose(code, reason) == CHANNEL_DELETED) 841 if (SendClose(code, reason) == CHANNEL_DELETED)
841 return CHANNEL_DELETED; 842 return CHANNEL_DELETED;
842 DCHECK_EQ(RECV_CLOSED, state_); 843 DCHECK_EQ(RECV_CLOSED, state_);
843 SetState(CLOSE_WAIT); 844 SetState(CLOSE_WAIT);
844 845
845 if (event_interface_->OnClosingHandshake() == CHANNEL_DELETED) 846 if (event_interface_->OnClosingHandshake() == CHANNEL_DELETED)
846 return CHANNEL_DELETED; 847 return CHANNEL_DELETED;
848 has_received_close_frame_ = true;
847 received_close_code_ = code; 849 received_close_code_ = code;
848 received_close_reason_ = reason; 850 received_close_reason_ = reason;
849 break; 851 break;
850 852
851 case SEND_CLOSED: 853 case SEND_CLOSED:
852 SetState(CLOSE_WAIT); 854 SetState(CLOSE_WAIT);
853 // From RFC6455 section 7.1.5: "Each endpoint 855 // From RFC6455 section 7.1.5: "Each endpoint
854 // will see the status code sent by the other end as _The WebSocket 856 // will see the status code sent by the other end as _The WebSocket
855 // Connection Close Code_." 857 // Connection Close Code_."
858 has_received_close_frame_ = true;
856 received_close_code_ = code; 859 received_close_code_ = code;
857 received_close_reason_ = reason; 860 received_close_reason_ = reason;
858 break; 861 break;
859 862
860 default: 863 default:
861 LOG(DFATAL) << "Got Close in unexpected state " << state_; 864 LOG(DFATAL) << "Got Close in unexpected state " << state_;
862 break; 865 break;
863 } 866 }
864 return CHANNEL_ALIVE; 867 return CHANNEL_ALIVE;
865 } 868 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 } 1103 }
1101 1104
1102 void WebSocketChannel::CloseTimeout() { 1105 void WebSocketChannel::CloseTimeout() {
1103 stream_->Close(); 1106 stream_->Close();
1104 SetState(CLOSED); 1107 SetState(CLOSED);
1105 DoDropChannel(false, kWebSocketErrorAbnormalClosure, ""); 1108 DoDropChannel(false, kWebSocketErrorAbnormalClosure, "");
1106 // |this| has been deleted. 1109 // |this| has been deleted.
1107 } 1110 }
1108 1111
1109 } // namespace net 1112 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_channel.h ('k') | sandbox/linux/bpf_dsl/bpf_dsl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698