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 <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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 frames_.push_back(frame.release()); | 149 frames_.push_back(frame.release()); |
150 } | 150 } |
151 | 151 |
152 // Implementation of WebSocketStream::ConnectDelegate that simply forwards the | 152 // Implementation of WebSocketStream::ConnectDelegate that simply forwards the |
153 // calls on to the WebSocketChannel that created it. | 153 // calls on to the WebSocketChannel that created it. |
154 class WebSocketChannel::ConnectDelegate | 154 class WebSocketChannel::ConnectDelegate |
155 : public WebSocketStream::ConnectDelegate { | 155 : public WebSocketStream::ConnectDelegate { |
156 public: | 156 public: |
157 explicit ConnectDelegate(WebSocketChannel* creator) : creator_(creator) {} | 157 explicit ConnectDelegate(WebSocketChannel* creator) : creator_(creator) {} |
158 | 158 |
159 virtual void OnSuccess(scoped_ptr<WebSocketStream> stream) OVERRIDE { | 159 virtual void OnSuccess(scoped_ptr<WebSocketStream> stream) override { |
160 creator_->OnConnectSuccess(stream.Pass()); | 160 creator_->OnConnectSuccess(stream.Pass()); |
161 // |this| may have been deleted. | 161 // |this| may have been deleted. |
162 } | 162 } |
163 | 163 |
164 virtual void OnFailure(const std::string& message) OVERRIDE { | 164 virtual void OnFailure(const std::string& message) override { |
165 creator_->OnConnectFailure(message); | 165 creator_->OnConnectFailure(message); |
166 // |this| has been deleted. | 166 // |this| has been deleted. |
167 } | 167 } |
168 | 168 |
169 virtual void OnStartOpeningHandshake( | 169 virtual void OnStartOpeningHandshake( |
170 scoped_ptr<WebSocketHandshakeRequestInfo> request) OVERRIDE { | 170 scoped_ptr<WebSocketHandshakeRequestInfo> request) override { |
171 creator_->OnStartOpeningHandshake(request.Pass()); | 171 creator_->OnStartOpeningHandshake(request.Pass()); |
172 } | 172 } |
173 | 173 |
174 virtual void OnFinishOpeningHandshake( | 174 virtual void OnFinishOpeningHandshake( |
175 scoped_ptr<WebSocketHandshakeResponseInfo> response) OVERRIDE { | 175 scoped_ptr<WebSocketHandshakeResponseInfo> response) override { |
176 creator_->OnFinishOpeningHandshake(response.Pass()); | 176 creator_->OnFinishOpeningHandshake(response.Pass()); |
177 } | 177 } |
178 | 178 |
179 virtual void OnSSLCertificateError( | 179 virtual void OnSSLCertificateError( |
180 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> | 180 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> |
181 ssl_error_callbacks, | 181 ssl_error_callbacks, |
182 const SSLInfo& ssl_info, | 182 const SSLInfo& ssl_info, |
183 bool fatal) OVERRIDE { | 183 bool fatal) override { |
184 creator_->OnSSLCertificateError( | 184 creator_->OnSSLCertificateError( |
185 ssl_error_callbacks.Pass(), ssl_info, fatal); | 185 ssl_error_callbacks.Pass(), ssl_info, fatal); |
186 } | 186 } |
187 | 187 |
188 private: | 188 private: |
189 // A pointer to the WebSocketChannel that created this object. There is no | 189 // A pointer to the WebSocketChannel that created this object. There is no |
190 // danger of this pointer being stale, because deleting the WebSocketChannel | 190 // danger of this pointer being stale, because deleting the WebSocketChannel |
191 // cancels the connect process, deleting this object and preventing its | 191 // cancels the connect process, deleting this object and preventing its |
192 // callbacks from being called. | 192 // callbacks from being called. |
193 WebSocketChannel* const creator_; | 193 WebSocketChannel* const creator_; |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 } | 1107 } |
1108 | 1108 |
1109 void WebSocketChannel::CloseTimeout() { | 1109 void WebSocketChannel::CloseTimeout() { |
1110 stream_->Close(); | 1110 stream_->Close(); |
1111 SetState(CLOSED); | 1111 SetState(CLOSED); |
1112 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, "")); | 1112 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, "")); |
1113 // |this| has been deleted. | 1113 // |this| has been deleted. |
1114 } | 1114 } |
1115 | 1115 |
1116 } // namespace net | 1116 } // namespace net |
OLD | NEW |