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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 http_auth_handler_factory_(NULL), | 62 http_auth_handler_factory_(NULL), |
63 factory_(ClientSocketFactory::GetDefaultFactory()), | 63 factory_(ClientSocketFactory::GetDefaultFactory()), |
64 proxy_mode_(kDirectConnection), | 64 proxy_mode_(kDirectConnection), |
65 proxy_url_(url), | 65 proxy_url_(url), |
66 pac_request_(NULL), | 66 pac_request_(NULL), |
67 // Unretained() is required; without it, Bind() creates a circular | 67 // Unretained() is required; without it, Bind() creates a circular |
68 // dependency and the SocketStream object will not be freed. | 68 // dependency and the SocketStream object will not be freed. |
69 ALLOW_THIS_IN_INITIALIZER_LIST( | 69 ALLOW_THIS_IN_INITIALIZER_LIST( |
70 io_callback_(base::Bind(&SocketStream::OnIOCompleted, | 70 io_callback_(base::Bind(&SocketStream::OnIOCompleted, |
71 base::Unretained(this)))), | 71 base::Unretained(this)))), |
72 ALLOW_THIS_IN_INITIALIZER_LIST( | |
73 io_callback_old_(this, &SocketStream::OnIOCompleted)), | |
74 read_buf_(NULL), | 72 read_buf_(NULL), |
75 write_buf_(NULL), | 73 write_buf_(NULL), |
76 current_write_buf_(NULL), | 74 current_write_buf_(NULL), |
77 write_buf_offset_(0), | 75 write_buf_offset_(0), |
78 write_buf_size_(0), | 76 write_buf_size_(0), |
79 closing_(false), | 77 closing_(false), |
80 server_closed_(false), | 78 server_closed_(false), |
81 metrics_(new SocketStreamMetrics(url)) { | 79 metrics_(new SocketStreamMetrics(url)) { |
82 DCHECK(MessageLoop::current()) << | 80 DCHECK(MessageLoop::current()) << |
83 "The current MessageLoop must exist"; | 81 "The current MessageLoop must exist"; |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 | 542 |
545 // TODO(toyoshim): Check server advertisement of SPDY through the HTTP | 543 // TODO(toyoshim): Check server advertisement of SPDY through the HTTP |
546 // Alternate-Protocol header, then switch to SPDY if SPDY is available. | 544 // Alternate-Protocol header, then switch to SPDY if SPDY is available. |
547 // Usually we already have a session to the SPDY server because JavaScript | 545 // Usually we already have a session to the SPDY server because JavaScript |
548 // running WebSocket itself would be served by SPDY. But, in some situation | 546 // running WebSocket itself would be served by SPDY. But, in some situation |
549 // (E.g. Used by Chrome Extensions or used for cross origin connection), this | 547 // (E.g. Used by Chrome Extensions or used for cross origin connection), this |
550 // connection might be the first one. At that time, we should check | 548 // connection might be the first one. At that time, we should check |
551 // Alternate-Protocol header here for ws:// or TLS NPN extension for wss:// . | 549 // Alternate-Protocol header here for ws:// or TLS NPN extension for wss:// . |
552 | 550 |
553 return proxy_service()->ResolveProxy( | 551 return proxy_service()->ResolveProxy( |
554 proxy_url_, &proxy_info_, &io_callback_old_, &pac_request_, net_log_); | 552 proxy_url_, &proxy_info_, io_callback_, &pac_request_, net_log_); |
555 } | 553 } |
556 | 554 |
557 int SocketStream::DoResolveProxyComplete(int result) { | 555 int SocketStream::DoResolveProxyComplete(int result) { |
558 pac_request_ = NULL; | 556 pac_request_ = NULL; |
559 if (result != OK) { | 557 if (result != OK) { |
560 LOG(ERROR) << "Failed to resolve proxy: " << result; | 558 LOG(ERROR) << "Failed to resolve proxy: " << result; |
561 if (delegate_) | 559 if (delegate_) |
562 delegate_->OnError(this, result); | 560 delegate_->OnError(this, result); |
563 proxy_info_.UseDirect(); | 561 proxy_info_.UseDirect(); |
564 } | 562 } |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1185 |
1188 SSLConfigService* SocketStream::ssl_config_service() const { | 1186 SSLConfigService* SocketStream::ssl_config_service() const { |
1189 return context_->ssl_config_service(); | 1187 return context_->ssl_config_service(); |
1190 } | 1188 } |
1191 | 1189 |
1192 ProxyService* SocketStream::proxy_service() const { | 1190 ProxyService* SocketStream::proxy_service() const { |
1193 return context_->proxy_service(); | 1191 return context_->proxy_service(); |
1194 } | 1192 } |
1195 | 1193 |
1196 } // namespace net | 1194 } // namespace net |
OLD | NEW |