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