OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 10 #include <string> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 void SocketStream::Close() { | 137 void SocketStream::Close() { |
138 DCHECK(MessageLoop::current()) << | 138 DCHECK(MessageLoop::current()) << |
139 "The current MessageLoop must exist"; | 139 "The current MessageLoop must exist"; |
140 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << | 140 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << |
141 "The current MessageLoop must be TYPE_IO"; | 141 "The current MessageLoop must be TYPE_IO"; |
142 if (!socket_.get()) | 142 if (!socket_.get()) |
143 return; | 143 return; |
144 if (socket_->IsConnected()) | 144 if (socket_->IsConnected()) |
145 socket_->Disconnect(); | 145 socket_->Disconnect(); |
146 next_state_ = STATE_NONE; | |
147 // Close asynchronously, so that delegate won't be called | 146 // Close asynchronously, so that delegate won't be called |
148 // back before returning Close(). | 147 // back before returning Close(). |
149 MessageLoop::current()->PostTask( | 148 MessageLoop::current()->PostTask( |
150 FROM_HERE, | 149 FROM_HERE, |
151 NewRunnableMethod(this, &SocketStream::DoLoop, OK)); | 150 NewRunnableMethod(this, &SocketStream::DoLoop, OK)); |
152 } | 151 } |
153 | 152 |
154 void SocketStream::RestartWithAuth( | 153 void SocketStream::RestartWithAuth( |
155 const std::wstring& username, const std::wstring& password) { | 154 const std::wstring& username, const std::wstring& password) { |
156 DCHECK(MessageLoop::current()) << | 155 DCHECK(MessageLoop::current()) << |
(...skipping 19 matching lines...) Expand all Loading... |
176 NewRunnableMethod(this, &SocketStream::DoRestartWithAuth)); | 175 NewRunnableMethod(this, &SocketStream::DoRestartWithAuth)); |
177 } | 176 } |
178 | 177 |
179 void SocketStream::DetachDelegate() { | 178 void SocketStream::DetachDelegate() { |
180 if (!delegate_) | 179 if (!delegate_) |
181 return; | 180 return; |
182 delegate_ = NULL; | 181 delegate_ = NULL; |
183 Close(); | 182 Close(); |
184 } | 183 } |
185 | 184 |
186 void SocketStream::Finish(int result) { | 185 void SocketStream::Finish() { |
187 DCHECK(MessageLoop::current()) << | 186 DCHECK(MessageLoop::current()) << |
188 "The current MessageLoop must exist"; | 187 "The current MessageLoop must exist"; |
189 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << | 188 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << |
190 "The current MessageLoop must be TYPE_IO"; | 189 "The current MessageLoop must be TYPE_IO"; |
191 DCHECK_LT(result, 0); | |
192 DLOG(INFO) << "Finish"; | 190 DLOG(INFO) << "Finish"; |
193 if (delegate_) | |
194 delegate_->OnError(this, result); | |
195 | |
196 Delegate* delegate = delegate_; | 191 Delegate* delegate = delegate_; |
197 delegate_ = NULL; | 192 delegate_ = NULL; |
198 if (delegate) { | 193 if (delegate) { |
199 delegate->OnClose(this); | 194 delegate->OnClose(this); |
| 195 Release(); |
200 } | 196 } |
201 Release(); | |
202 } | 197 } |
203 | 198 |
204 void SocketStream::SetHostResolver(HostResolver* host_resolver) { | 199 void SocketStream::SetHostResolver(HostResolver* host_resolver) { |
205 DCHECK(host_resolver); | 200 DCHECK(host_resolver); |
206 host_resolver_ = host_resolver; | 201 host_resolver_ = host_resolver; |
207 } | 202 } |
208 | 203 |
209 void SocketStream::SetClientSocketFactory( | 204 void SocketStream::SetClientSocketFactory( |
210 ClientSocketFactory* factory) { | 205 ClientSocketFactory* factory) { |
211 DCHECK(factory); | 206 DCHECK(factory); |
212 factory_ = factory; | 207 factory_ = factory; |
213 } | 208 } |
214 | 209 |
215 int SocketStream::DidEstablishConnection() { | 210 void SocketStream::DidEstablishConnection() { |
216 if (!socket_.get() || !socket_->IsConnected()) { | 211 if (!socket_.get() || !socket_->IsConnected()) { |
217 return ERR_CONNECTION_FAILED; | 212 Finish(); |
| 213 return; |
218 } | 214 } |
219 next_state_ = STATE_READ_WRITE; | 215 next_state_ = STATE_READ_WRITE; |
220 | 216 |
221 if (delegate_) | 217 if (delegate_) |
222 delegate_->OnConnected(this, max_pending_send_allowed_); | 218 delegate_->OnConnected(this, max_pending_send_allowed_); |
223 | 219 |
224 return OK; | 220 return; |
225 } | 221 } |
226 | 222 |
227 void SocketStream::DidReceiveData(int result) { | 223 void SocketStream::DidReceiveData(int result) { |
228 DCHECK(read_buf_); | 224 DCHECK(read_buf_); |
229 DCHECK_GT(result, 0); | 225 DCHECK_GT(result, 0); |
230 if (!delegate_) | 226 if (!delegate_) |
231 return; | 227 return; |
232 // Notify recevied data to delegate. | 228 // Notify recevied data to delegate. |
233 delegate_->OnReceivedData(this, read_buf_->data(), result); | 229 delegate_->OnReceivedData(this, read_buf_->data(), result); |
234 read_buf_ = NULL; | 230 read_buf_ = NULL; |
(...skipping 17 matching lines...) Expand all Loading... |
252 write_buf_ = NULL; | 248 write_buf_ = NULL; |
253 } | 249 } |
254 write_buf_offset_ = 0; | 250 write_buf_offset_ = 0; |
255 } else { | 251 } else { |
256 write_buf_offset_ += result; | 252 write_buf_offset_ += result; |
257 } | 253 } |
258 } | 254 } |
259 | 255 |
260 void SocketStream::OnIOCompleted(int result) { | 256 void SocketStream::OnIOCompleted(int result) { |
261 DoLoop(result); | 257 DoLoop(result); |
| 258 // TODO(ukai): notify error. |
262 } | 259 } |
263 | 260 |
264 void SocketStream::OnReadCompleted(int result) { | 261 void SocketStream::OnReadCompleted(int result) { |
| 262 // TODO(ukai): notify error. |
265 if (result == 0) { | 263 if (result == 0) { |
266 // 0 indicates end-of-file, so socket was closed. | 264 // 0 indicates end-of-file, so socket was closed. |
267 next_state_ = STATE_NONE; | 265 next_state_ = STATE_NONE; |
268 } else if (result > 0 && read_buf_) { | 266 } else if (result > 0 && read_buf_) { |
269 DidReceiveData(result); | 267 DidReceiveData(result); |
270 result = OK; | 268 result = OK; |
271 } | 269 } |
272 DoLoop(result); | 270 DoLoop(result); |
273 } | 271 } |
274 | 272 |
275 void SocketStream::OnWriteCompleted(int result) { | 273 void SocketStream::OnWriteCompleted(int result) { |
276 // TODO(ukai): notify error. | 274 // TODO(ukai): notify error. |
277 if (result >= 0 && write_buf_) { | 275 if (result >= 0 && write_buf_) { |
278 DidSendData(result); | 276 DidSendData(result); |
279 result = OK; | 277 result = OK; |
280 } | 278 } |
281 DoLoop(result); | 279 DoLoop(result); |
282 } | 280 } |
283 | 281 |
284 void SocketStream::DoLoop(int result) { | 282 int SocketStream::DoLoop(int result) { |
| 283 if (next_state_ == STATE_NONE) { |
| 284 Finish(); |
| 285 return ERR_CONNECTION_CLOSED; |
| 286 } |
| 287 |
285 do { | 288 do { |
286 State state = next_state_; | 289 State state = next_state_; |
287 next_state_ = STATE_NONE; | 290 next_state_ = STATE_NONE; |
288 switch (state) { | 291 switch (state) { |
289 case STATE_NONE: | |
290 DCHECK_LE(result, OK); | |
291 if (result == OK) | |
292 result = ERR_CONNECTION_CLOSED; | |
293 Finish(result); | |
294 return; | |
295 case STATE_RESOLVE_PROXY: | 292 case STATE_RESOLVE_PROXY: |
296 DCHECK_EQ(OK, result); | 293 DCHECK_EQ(OK, result); |
297 result = DoResolveProxy(); | 294 result = DoResolveProxy(); |
298 break; | 295 break; |
299 case STATE_RESOLVE_PROXY_COMPLETE: | 296 case STATE_RESOLVE_PROXY_COMPLETE: |
300 result = DoResolveProxyComplete(result); | 297 result = DoResolveProxyComplete(result); |
301 break; | 298 break; |
302 case STATE_RESOLVE_HOST: | 299 case STATE_RESOLVE_HOST: |
303 DCHECK_EQ(OK, result); | 300 DCHECK_EQ(OK, result); |
304 result = DoResolveHost(); | 301 result = DoResolveHost(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 result = DoSSLConnectComplete(result); | 339 result = DoSSLConnectComplete(result); |
343 break; | 340 break; |
344 case STATE_READ_WRITE: | 341 case STATE_READ_WRITE: |
345 result = DoReadWrite(result); | 342 result = DoReadWrite(result); |
346 break; | 343 break; |
347 default: | 344 default: |
348 NOTREACHED() << "bad state"; | 345 NOTREACHED() << "bad state"; |
349 result = ERR_UNEXPECTED; | 346 result = ERR_UNEXPECTED; |
350 break; | 347 break; |
351 } | 348 } |
352 } while (result != ERR_IO_PENDING); | 349 } while (result != ERR_IO_PENDING && next_state_ != STATE_NONE); |
| 350 |
| 351 if (result != ERR_IO_PENDING) |
| 352 Finish(); |
| 353 |
| 354 return result; |
353 } | 355 } |
354 | 356 |
355 int SocketStream::DoResolveProxy() { | 357 int SocketStream::DoResolveProxy() { |
356 DCHECK(!pac_request_); | 358 DCHECK(!pac_request_); |
357 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 359 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
358 | 360 |
359 return proxy_service()->ResolveProxy( | 361 return proxy_service()->ResolveProxy( |
360 url_, &proxy_info_, &io_callback_, &pac_request_, NULL); | 362 url_, &proxy_info_, &io_callback_, &pac_request_, NULL); |
361 } | 363 } |
362 | 364 |
363 int SocketStream::DoResolveProxyComplete(int result) { | 365 int SocketStream::DoResolveProxyComplete(int result) { |
364 next_state_ = STATE_RESOLVE_HOST; | 366 next_state_ = STATE_RESOLVE_HOST; |
365 | 367 |
366 pac_request_ = NULL; | 368 pac_request_ = NULL; |
367 if (result != OK) { | 369 if (result != OK) { |
368 LOG(ERROR) << "Failed to resolve proxy: " << result; | 370 LOG(ERROR) << "Failed to resolve proxy: " << result; |
369 if (delegate_) | |
370 delegate_->OnError(this, result); | |
371 proxy_info_.UseDirect(); | 371 proxy_info_.UseDirect(); |
372 } | 372 } |
373 | 373 |
374 return OK; | 374 return OK; |
375 } | 375 } |
376 | 376 |
377 int SocketStream::DoResolveHost() { | 377 int SocketStream::DoResolveHost() { |
378 next_state_ = STATE_RESOLVE_HOST_COMPLETE; | 378 next_state_ = STATE_RESOLVE_HOST_COMPLETE; |
379 | 379 |
380 if (proxy_info_.is_direct()) | 380 if (proxy_info_.is_direct()) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 if (result != OK) | 421 if (result != OK) |
422 return result; | 422 return result; |
423 | 423 |
424 if (proxy_mode_ == kTunnelProxy) | 424 if (proxy_mode_ == kTunnelProxy) |
425 next_state_ = STATE_WRITE_TUNNEL_HEADERS; | 425 next_state_ = STATE_WRITE_TUNNEL_HEADERS; |
426 else if (proxy_mode_ == kSOCKSProxy) | 426 else if (proxy_mode_ == kSOCKSProxy) |
427 next_state_ = STATE_SOCKS_CONNECT; | 427 next_state_ = STATE_SOCKS_CONNECT; |
428 else if (is_secure()) { | 428 else if (is_secure()) { |
429 next_state_ = STATE_SSL_CONNECT; | 429 next_state_ = STATE_SSL_CONNECT; |
430 } else { | 430 } else { |
431 result = DidEstablishConnection(); | 431 DidEstablishConnection(); |
432 } | 432 } |
433 return result; | 433 return OK; |
434 } | 434 } |
435 | 435 |
436 int SocketStream::DoWriteTunnelHeaders() { | 436 int SocketStream::DoWriteTunnelHeaders() { |
437 DCHECK_EQ(kTunnelProxy, proxy_mode_); | 437 DCHECK_EQ(kTunnelProxy, proxy_mode_); |
438 | 438 |
439 next_state_ = STATE_WRITE_TUNNEL_HEADERS_COMPLETE; | 439 next_state_ = STATE_WRITE_TUNNEL_HEADERS_COMPLETE; |
440 | 440 |
441 if (!tunnel_request_headers_.get()) { | 441 if (!tunnel_request_headers_.get()) { |
442 tunnel_request_headers_ = new RequestHeaders(); | 442 tunnel_request_headers_ = new RequestHeaders(); |
443 tunnel_request_headers_bytes_sent_ = 0; | 443 tunnel_request_headers_bytes_sent_ = 0; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 525 } |
526 | 526 |
527 int SocketStream::DoReadTunnelHeadersComplete(int result) { | 527 int SocketStream::DoReadTunnelHeadersComplete(int result) { |
528 DCHECK_EQ(kTunnelProxy, proxy_mode_); | 528 DCHECK_EQ(kTunnelProxy, proxy_mode_); |
529 | 529 |
530 if (result < 0) | 530 if (result < 0) |
531 return result; | 531 return result; |
532 | 532 |
533 if (result == 0) { | 533 if (result == 0) { |
534 // 0 indicates end-of-file, so socket was closed. | 534 // 0 indicates end-of-file, so socket was closed. |
535 DCHECK_EQ(next_state_, STATE_NONE); | 535 Finish(); |
536 return ERR_CONNECTION_CLOSED; | 536 return result; |
537 } | 537 } |
538 | 538 |
539 tunnel_response_headers_len_ += result; | 539 tunnel_response_headers_len_ += result; |
540 DCHECK(tunnel_response_headers_len_ <= tunnel_response_headers_capacity_); | 540 DCHECK(tunnel_response_headers_len_ <= tunnel_response_headers_capacity_); |
541 | 541 |
542 int eoh = HttpUtil::LocateEndOfHeaders( | 542 int eoh = HttpUtil::LocateEndOfHeaders( |
543 tunnel_response_headers_->headers(), tunnel_response_headers_len_, 0); | 543 tunnel_response_headers_->headers(), tunnel_response_headers_len_, 0); |
544 if (eoh == -1) { | 544 if (eoh == -1) { |
545 if (tunnel_response_headers_len_ >= kMaxTunnelResponseHeadersSize) { | 545 if (tunnel_response_headers_len_ >= kMaxTunnelResponseHeadersSize) |
546 DCHECK_EQ(next_state_, STATE_NONE); | |
547 return ERR_RESPONSE_HEADERS_TOO_BIG; | 546 return ERR_RESPONSE_HEADERS_TOO_BIG; |
548 } | |
549 | 547 |
550 next_state_ = STATE_READ_TUNNEL_HEADERS; | 548 next_state_ = STATE_READ_TUNNEL_HEADERS; |
551 return OK; | 549 return OK; |
552 } | 550 } |
553 // DidReadResponseHeaders | 551 // DidReadResponseHeaders |
554 scoped_refptr<HttpResponseHeaders> headers; | 552 scoped_refptr<HttpResponseHeaders> headers; |
555 headers = new HttpResponseHeaders( | 553 headers = new HttpResponseHeaders( |
556 HttpUtil::AssembleRawHeaders(tunnel_response_headers_->headers(), eoh)); | 554 HttpUtil::AssembleRawHeaders(tunnel_response_headers_->headers(), eoh)); |
557 if (headers->GetParsedHttpVersion() < HttpVersion(1, 0)) { | 555 if (headers->GetParsedHttpVersion() < HttpVersion(1, 0)) { |
558 // Require the "HTTP/1.x" status line. | 556 // Require the "HTTP/1.x" status line. |
559 DCHECK_EQ(next_state_, STATE_NONE); | |
560 return ERR_TUNNEL_CONNECTION_FAILED; | 557 return ERR_TUNNEL_CONNECTION_FAILED; |
561 } | 558 } |
562 switch (headers->response_code()) { | 559 switch (headers->response_code()) { |
563 case 200: // OK | 560 case 200: // OK |
564 if (is_secure()) { | 561 if (is_secure()) { |
565 DCHECK_EQ(eoh, tunnel_response_headers_len_); | 562 DCHECK_EQ(eoh, tunnel_response_headers_len_); |
566 next_state_ = STATE_SSL_CONNECT; | 563 next_state_ = STATE_SSL_CONNECT; |
567 } else { | 564 } else { |
568 result = DidEstablishConnection(); | 565 DidEstablishConnection(); |
569 if (result < 0) { | |
570 DCHECK_EQ(next_state_, STATE_NONE); | |
571 return result; | |
572 } | |
573 if ((eoh < tunnel_response_headers_len_) && delegate_) | 566 if ((eoh < tunnel_response_headers_len_) && delegate_) |
574 delegate_->OnReceivedData( | 567 delegate_->OnReceivedData( |
575 this, tunnel_response_headers_->headers() + eoh, | 568 this, tunnel_response_headers_->headers() + eoh, |
576 tunnel_response_headers_len_ - eoh); | 569 tunnel_response_headers_len_ - eoh); |
577 } | 570 } |
578 return OK; | 571 return OK; |
579 case 407: // Proxy Authentication Required. | 572 case 407: // Proxy Authentication Required. |
580 result = HandleAuthChallenge(headers.get()); | 573 result = HandleAuthChallenge(headers.get()); |
581 if (result == ERR_PROXY_AUTH_REQUESTED && | 574 if (result == ERR_PROXY_AUTH_REQUESTED && |
582 auth_handler_.get() && delegate_) { | 575 auth_handler_.get() && delegate_) { |
583 auth_info_ = new AuthChallengeInfo; | 576 auth_info_ = new AuthChallengeInfo; |
584 auth_info_->is_proxy = true; | 577 auth_info_->is_proxy = true; |
585 auth_info_->host_and_port = | 578 auth_info_->host_and_port = |
586 ASCIIToWide(proxy_info_.proxy_server().host_and_port()); | 579 ASCIIToWide(proxy_info_.proxy_server().host_and_port()); |
587 auth_info_->scheme = ASCIIToWide(auth_handler_->scheme()); | 580 auth_info_->scheme = ASCIIToWide(auth_handler_->scheme()); |
588 auth_info_->realm = ASCIIToWide(auth_handler_->realm()); | 581 auth_info_->realm = ASCIIToWide(auth_handler_->realm()); |
589 // Wait until RestartWithAuth or Close is called. | 582 // Wait until RestartWithAuth or Close is called. |
590 MessageLoop::current()->PostTask( | 583 MessageLoop::current()->PostTask( |
591 FROM_HERE, | 584 FROM_HERE, |
592 NewRunnableMethod(this, &SocketStream::DoAuthRequired)); | 585 NewRunnableMethod(this, &SocketStream::DoAuthRequired)); |
593 next_state_ = STATE_AUTH_REQUIRED; | |
594 return ERR_IO_PENDING; | 586 return ERR_IO_PENDING; |
595 } | 587 } |
596 default: | 588 default: |
597 break; | 589 break; |
598 } | 590 } |
599 return ERR_TUNNEL_CONNECTION_FAILED; | 591 return ERR_TUNNEL_CONNECTION_FAILED; |
600 } | 592 } |
601 | 593 |
602 int SocketStream::DoSOCKSConnect() { | 594 int SocketStream::DoSOCKSConnect() { |
603 DCHECK_EQ(kSOCKSProxy, proxy_mode_); | 595 DCHECK_EQ(kSOCKSProxy, proxy_mode_); |
(...skipping 30 matching lines...) Expand all Loading... |
634 socket_.release(), url_.HostNoBrackets(), ssl_config_)); | 626 socket_.release(), url_.HostNoBrackets(), ssl_config_)); |
635 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 627 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
636 return socket_->Connect(&io_callback_); | 628 return socket_->Connect(&io_callback_); |
637 } | 629 } |
638 | 630 |
639 int SocketStream::DoSSLConnectComplete(int result) { | 631 int SocketStream::DoSSLConnectComplete(int result) { |
640 if (IsCertificateError(result)) | 632 if (IsCertificateError(result)) |
641 result = HandleCertificateError(result); | 633 result = HandleCertificateError(result); |
642 | 634 |
643 if (result == OK) | 635 if (result == OK) |
644 result = DidEstablishConnection(); | 636 DidEstablishConnection(); |
645 return result; | 637 return result; |
646 } | 638 } |
647 | 639 |
648 int SocketStream::DoReadWrite(int result) { | 640 int SocketStream::DoReadWrite(int result) { |
649 if (result < OK) { | 641 if (result < OK) { |
| 642 Finish(); |
650 return result; | 643 return result; |
651 } | 644 } |
652 if (!socket_.get() || !socket_->IsConnected()) { | 645 if (!socket_.get() || !socket_->IsConnected()) { |
| 646 Finish(); |
653 return ERR_CONNECTION_CLOSED; | 647 return ERR_CONNECTION_CLOSED; |
654 } | 648 } |
655 | 649 |
656 next_state_ = STATE_READ_WRITE; | 650 next_state_ = STATE_READ_WRITE; |
657 | 651 |
658 if (!read_buf_) { | 652 if (!read_buf_) { |
659 // No read pending. | 653 // No read pending. |
660 read_buf_ = new IOBuffer(kReadBufferSize); | 654 read_buf_ = new IOBuffer(kReadBufferSize); |
661 result = socket_->Read(read_buf_, kReadBufferSize, &read_callback_); | 655 result = socket_->Read(read_buf_, kReadBufferSize, &read_callback_); |
662 if (result > 0) { | 656 if (result > 0) { |
663 DidReceiveData(result); | 657 DidReceiveData(result); |
664 return OK; | 658 return OK; |
665 } else if (result == 0) { | 659 } else if (result == 0) { |
666 // 0 indicates end-of-file, so socket was closed. | 660 // 0 indicates end-of-file, so socket was closed. |
| 661 Finish(); |
667 return ERR_CONNECTION_CLOSED; | 662 return ERR_CONNECTION_CLOSED; |
668 } | 663 } |
669 // If read is pending, try write as well. | 664 // If read is pending, try write as well. |
670 // Otherwise, return the result and do next loop. | 665 // Otherwise, return the result and do next loop. |
671 if (result != ERR_IO_PENDING) | 666 if (result != ERR_IO_PENDING) |
672 return result; | 667 return result; |
673 } | 668 } |
674 // Read is pending. | 669 // Read is pending. |
675 DCHECK(read_buf_); | 670 DCHECK(read_buf_); |
676 | 671 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 739 } |
745 | 740 |
746 void SocketStream::DoAuthRequired() { | 741 void SocketStream::DoAuthRequired() { |
747 if (delegate_ && auth_info_.get()) | 742 if (delegate_ && auth_info_.get()) |
748 delegate_->OnAuthRequired(this, auth_info_.get()); | 743 delegate_->OnAuthRequired(this, auth_info_.get()); |
749 else | 744 else |
750 DoLoop(net::ERR_UNEXPECTED); | 745 DoLoop(net::ERR_UNEXPECTED); |
751 } | 746 } |
752 | 747 |
753 void SocketStream::DoRestartWithAuth() { | 748 void SocketStream::DoRestartWithAuth() { |
754 DCHECK_EQ(next_state_, STATE_AUTH_REQUIRED); | |
755 auth_cache_.Add(ProxyAuthOrigin(), auth_handler_, | 749 auth_cache_.Add(ProxyAuthOrigin(), auth_handler_, |
756 auth_identity_.username, auth_identity_.password, | 750 auth_identity_.username, auth_identity_.password, |
757 std::string()); | 751 std::string()); |
758 | 752 |
759 tunnel_request_headers_ = NULL; | 753 tunnel_request_headers_ = NULL; |
760 tunnel_request_headers_bytes_sent_ = 0; | 754 tunnel_request_headers_bytes_sent_ = 0; |
761 tunnel_response_headers_ = NULL; | 755 tunnel_response_headers_ = NULL; |
762 tunnel_response_headers_capacity_ = 0; | 756 tunnel_response_headers_capacity_ = 0; |
763 tunnel_response_headers_len_ = 0; | 757 tunnel_response_headers_len_ = 0; |
764 | 758 |
(...skipping 21 matching lines...) Expand all Loading... |
786 | 780 |
787 SSLConfigService* SocketStream::ssl_config_service() const { | 781 SSLConfigService* SocketStream::ssl_config_service() const { |
788 return context_->ssl_config_service(); | 782 return context_->ssl_config_service(); |
789 } | 783 } |
790 | 784 |
791 ProxyService* SocketStream::proxy_service() const { | 785 ProxyService* SocketStream::proxy_service() const { |
792 return context_->proxy_service(); | 786 return context_->proxy_service(); |
793 } | 787 } |
794 | 788 |
795 } // namespace net | 789 } // namespace net |
OLD | NEW |