OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_job.h" | 5 #include "net/websockets/websocket_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 return OK; | 590 return OK; |
591 scoped_refptr<HttpNetworkSession> session = factory->GetSession(); | 591 scoped_refptr<HttpNetworkSession> session = factory->GetSession(); |
592 if (!session.get()) | 592 if (!session.get()) |
593 return OK; | 593 return OK; |
594 SpdySessionPool* spdy_pool = session->spdy_session_pool(); | 594 SpdySessionPool* spdy_pool = session->spdy_session_pool(); |
595 PrivacyMode privacy_mode = socket_->privacy_mode(); | 595 PrivacyMode privacy_mode = socket_->privacy_mode(); |
596 const SpdySessionKey key(HostPortPair::FromURL(socket_->url()), | 596 const SpdySessionKey key(HostPortPair::FromURL(socket_->url()), |
597 socket_->proxy_server(), privacy_mode); | 597 socket_->proxy_server(), privacy_mode); |
598 // Forbid wss downgrade to SPDY without SSL. | 598 // Forbid wss downgrade to SPDY without SSL. |
599 // TODO(toyoshim): Does it realize the same policy with HTTP? | 599 // TODO(toyoshim): Does it realize the same policy with HTTP? |
600 scoped_refptr<SpdySession> spdy_session = | 600 base::WeakPtr<SpdySession> spdy_session = |
601 spdy_pool->FindAvailableSession(key, *socket_->net_log()); | 601 spdy_pool->FindAvailableSession(key, *socket_->net_log()); |
602 if (!spdy_session) | 602 if (!spdy_session) |
603 return OK; | 603 return OK; |
604 | 604 |
605 SSLInfo ssl_info; | 605 SSLInfo ssl_info; |
606 bool was_npn_negotiated; | 606 bool was_npn_negotiated; |
607 NextProto protocol_negotiated = kProtoUnknown; | 607 NextProto protocol_negotiated = kProtoUnknown; |
608 bool use_ssl = spdy_session->GetSSLInfo( | 608 bool use_ssl = spdy_session->GetSSLInfo( |
609 &ssl_info, &was_npn_negotiated, &protocol_negotiated); | 609 &ssl_info, &was_npn_negotiated, &protocol_negotiated); |
610 if (socket_->is_secure() && !use_ssl) | 610 if (socket_->is_secure() && !use_ssl) |
611 return OK; | 611 return OK; |
612 | 612 |
613 // Create SpdyWebSocketStream. | 613 // Create SpdyWebSocketStream. |
614 spdy_protocol_version_ = spdy_session->GetProtocolVersion(); | 614 spdy_protocol_version_ = spdy_session->GetProtocolVersion(); |
615 spdy_websocket_stream_.reset( | 615 spdy_websocket_stream_.reset(new SpdyWebSocketStream(spdy_session, this)); |
616 new SpdyWebSocketStream(spdy_session.get(), this)); | |
617 | 616 |
618 int result = spdy_websocket_stream_->InitializeStream( | 617 int result = spdy_websocket_stream_->InitializeStream( |
619 socket_->url(), MEDIUM, *socket_->net_log()); | 618 socket_->url(), MEDIUM, *socket_->net_log()); |
620 if (result == OK) { | 619 if (result == OK) { |
621 OnConnected(socket_.get(), kMaxPendingSendAllowed); | 620 OnConnected(socket_.get(), kMaxPendingSendAllowed); |
622 return ERR_PROTOCOL_SWITCHED; | 621 return ERR_PROTOCOL_SWITCHED; |
623 } | 622 } |
624 if (result != ERR_IO_PENDING) { | 623 if (result != ERR_IO_PENDING) { |
625 spdy_websocket_stream_.reset(); | 624 spdy_websocket_stream_.reset(); |
626 return OK; | 625 return OK; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 | 695 |
697 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front(); | 696 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front(); |
698 send_buffer_queue_.pop_front(); | 697 send_buffer_queue_.pop_front(); |
699 current_send_buffer_ = | 698 current_send_buffer_ = |
700 new DrainableIOBuffer(next_buffer.get(), next_buffer->size()); | 699 new DrainableIOBuffer(next_buffer.get(), next_buffer->size()); |
701 SendDataInternal(current_send_buffer_->data(), | 700 SendDataInternal(current_send_buffer_->data(), |
702 current_send_buffer_->BytesRemaining()); | 701 current_send_buffer_->BytesRemaining()); |
703 } | 702 } |
704 | 703 |
705 } // namespace net | 704 } // namespace net |
OLD | NEW |