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

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

Issue 706203003: Update from https://crrev.com/303153 (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
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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 std::string message_copy = message; 575 std::string message_copy = message;
576 576
577 SetState(CLOSED); 577 SetState(CLOSED);
578 stream_request_.reset(); 578 stream_request_.reset();
579 579
580 if (CHANNEL_DELETED == 580 if (CHANNEL_DELETED ==
581 notification_sender_->SendImmediately(event_interface_.get())) { 581 notification_sender_->SendImmediately(event_interface_.get())) {
582 // |this| has been deleted. 582 // |this| has been deleted.
583 return; 583 return;
584 } 584 }
585 ignore_result(event_interface_->OnFailChannel(message_copy)); 585 ChannelState result = event_interface_->OnFailChannel(message_copy);
586 DCHECK_EQ(CHANNEL_DELETED, result);
586 // |this| has been deleted. 587 // |this| has been deleted.
587 } 588 }
588 589
589 void WebSocketChannel::OnSSLCertificateError( 590 void WebSocketChannel::OnSSLCertificateError(
590 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks, 591 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks,
591 const SSLInfo& ssl_info, 592 const SSLInfo& ssl_info,
592 bool fatal) { 593 bool fatal) {
593 ignore_result(event_interface_->OnSSLCertificateError( 594 ignore_result(event_interface_->OnSSLCertificateError(
594 ssl_error_callbacks.Pass(), socket_url_, ssl_info, fatal)); 595 ssl_error_callbacks.Pass(), socket_url_, ssl_info, fatal));
595 } 596 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 if (state_ == CONNECTED) { 994 if (state_ == CONNECTED) {
994 if (SendClose(code, reason) == CHANNEL_DELETED) 995 if (SendClose(code, reason) == CHANNEL_DELETED)
995 return CHANNEL_DELETED; 996 return CHANNEL_DELETED;
996 } 997 }
997 998
998 // Careful study of RFC6455 section 7.1.7 and 7.1.1 indicates the browser 999 // Careful study of RFC6455 section 7.1.7 and 7.1.1 indicates the browser
999 // should close the connection itself without waiting for the closing 1000 // should close the connection itself without waiting for the closing
1000 // handshake. 1001 // handshake.
1001 stream_->Close(); 1002 stream_->Close();
1002 SetState(CLOSED); 1003 SetState(CLOSED);
1003 return event_interface_->OnFailChannel(message); 1004 ChannelState result = event_interface_->OnFailChannel(message);
1005 DCHECK_EQ(CHANNEL_DELETED, result);
1006 return result;
1004 } 1007 }
1005 1008
1006 ChannelState WebSocketChannel::SendClose(uint16 code, 1009 ChannelState WebSocketChannel::SendClose(uint16 code,
1007 const std::string& reason) { 1010 const std::string& reason) {
1008 DCHECK(state_ == CONNECTED || state_ == RECV_CLOSED); 1011 DCHECK(state_ == CONNECTED || state_ == RECV_CLOSED);
1009 DCHECK_LE(reason.size(), kMaximumCloseReasonLength); 1012 DCHECK_LE(reason.size(), kMaximumCloseReasonLength);
1010 scoped_refptr<IOBuffer> body; 1013 scoped_refptr<IOBuffer> body;
1011 uint64 size = 0; 1014 uint64 size = 0;
1012 if (code == kWebSocketErrorNoStatusReceived) { 1015 if (code == kWebSocketErrorNoStatusReceived) {
1013 // Special case: translate kWebSocketErrorNoStatusReceived into a Close 1016 // Special case: translate kWebSocketErrorNoStatusReceived into a Close
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 } 1106 }
1104 1107
1105 void WebSocketChannel::CloseTimeout() { 1108 void WebSocketChannel::CloseTimeout() {
1106 stream_->Close(); 1109 stream_->Close();
1107 SetState(CLOSED); 1110 SetState(CLOSED);
1108 DoDropChannel(false, kWebSocketErrorAbnormalClosure, ""); 1111 DoDropChannel(false, kWebSocketErrorAbnormalClosure, "");
1109 // |this| has been deleted. 1112 // |this| has been deleted.
1110 } 1113 }
1111 1114
1112 } // namespace net 1115 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_basic_handshake_stream.cc ('k') | net/websockets/websocket_handshake_stream_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698