OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
7 | 7 |
8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 void SocketStream::Finish(int result) { | 283 void SocketStream::Finish(int result) { |
284 DCHECK(MessageLoop::current()) << | 284 DCHECK(MessageLoop::current()) << |
285 "The current MessageLoop must exist"; | 285 "The current MessageLoop must exist"; |
286 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << | 286 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << |
287 "The current MessageLoop must be TYPE_IO"; | 287 "The current MessageLoop must be TYPE_IO"; |
288 DCHECK_LE(result, OK); | 288 DCHECK_LE(result, OK); |
289 if (result == OK) | 289 if (result == OK) |
290 result = ERR_CONNECTION_CLOSED; | 290 result = ERR_CONNECTION_CLOSED; |
291 DCHECK_EQ(next_state_, STATE_NONE); | 291 DCHECK_EQ(next_state_, STATE_NONE); |
292 DVLOG(1) << "Finish result=" << ErrorToString(result); | 292 DVLOG(1) << "Finish result=" << ErrorToString(result); |
293 if (delegate_) | |
294 delegate_->OnError(this, result); | |
295 | 293 |
296 metrics_->OnClose(); | 294 metrics_->OnClose(); |
297 Delegate* delegate = delegate_; | 295 Delegate* delegate = delegate_; |
298 delegate_ = NULL; | 296 delegate_ = NULL; |
299 if (delegate) { | 297 if (delegate) { |
300 delegate->OnClose(this); | 298 delegate->OnError(this, result); |
Yuta Kitamura
2011/07/08 07:40:21
delegate->OnError() is called after delegate_ is s
Takashi Toyoshima
2011/07/08 08:35:14
Yes.
It will be better than calling it without cle
| |
299 if (result != ERR_PROTOCOL_SWITCHED) | |
300 delegate->OnClose(this); | |
301 } | 301 } |
302 Release(); | 302 Release(); |
303 } | 303 } |
304 | 304 |
305 int SocketStream::DidEstablishConnection() { | 305 int SocketStream::DidEstablishConnection() { |
306 if (!socket_.get() || !socket_->IsConnected()) { | 306 if (!socket_.get() || !socket_->IsConnected()) { |
307 next_state_ = STATE_CLOSE; | 307 next_state_ = STATE_CLOSE; |
308 return ERR_CONNECTION_FAILED; | 308 return ERR_CONNECTION_FAILED; |
309 } | 309 } |
310 next_state_ = STATE_READ_WRITE; | 310 next_state_ = STATE_READ_WRITE; |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1078 | 1078 |
1079 SSLConfigService* SocketStream::ssl_config_service() const { | 1079 SSLConfigService* SocketStream::ssl_config_service() const { |
1080 return context_->ssl_config_service(); | 1080 return context_->ssl_config_service(); |
1081 } | 1081 } |
1082 | 1082 |
1083 ProxyService* SocketStream::proxy_service() const { | 1083 ProxyService* SocketStream::proxy_service() const { |
1084 return context_->proxy_service(); | 1084 return context_->proxy_service(); |
1085 } | 1085 } |
1086 | 1086 |
1087 } // namespace net | 1087 } // namespace net |
OLD | NEW |