| 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/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 DCHECK_LE(1u, port_suggester->call_count()); | 715 DCHECK_LE(1u, port_suggester->call_count()); |
| 716 } else { | 716 } else { |
| 717 DCHECK_EQ(0u, port_suggester->call_count()); | 717 DCHECK_EQ(0u, port_suggester->call_count()); |
| 718 } | 718 } |
| 719 | 719 |
| 720 // We should adaptively set this buffer size, but for now, we'll use a size | 720 // We should adaptively set this buffer size, but for now, we'll use a size |
| 721 // that is more than large enough for a full receive window, and yet | 721 // that is more than large enough for a full receive window, and yet |
| 722 // does not consume "too much" memory. If we see bursty packet loss, we may | 722 // does not consume "too much" memory. If we see bursty packet loss, we may |
| 723 // revisit this setting and test for its impact. | 723 // revisit this setting and test for its impact. |
| 724 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP); | 724 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP); |
| 725 rv = socket->SetReceiveBufferSize(kSocketBufferSize); | 725 if (!socket->SetReceiveBufferSize(kSocketBufferSize)) { |
| 726 if (rv != OK) { | |
| 727 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER); | 726 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER); |
| 728 return rv; | 727 return ERR_SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR; |
| 729 } | 728 } |
| 730 // Set a buffer large enough to contain the initial CWND's worth of packet | 729 // Set a buffer large enough to contain the initial CWND's worth of packet |
| 731 // to work around the problem with CHLO packets being sent out with the | 730 // to work around the problem with CHLO packets being sent out with the |
| 732 // wrong encryption level, when the send buffer is full. | 731 // wrong encryption level, when the send buffer is full. |
| 733 rv = socket->SetSendBufferSize(kMaxPacketSize * 20); | 732 if (!socket->SetSendBufferSize(kMaxPacketSize * 20)) { |
| 734 if (rv != OK) { | |
| 735 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); | 733 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); |
| 736 return rv; | 734 return ERR_SOCKET_SET_SEND_BUFFER_SIZE_ERROR; |
| 737 } | 735 } |
| 738 | 736 |
| 739 scoped_ptr<QuicDefaultPacketWriter> writer( | 737 scoped_ptr<QuicDefaultPacketWriter> writer( |
| 740 new QuicDefaultPacketWriter(socket.get())); | 738 new QuicDefaultPacketWriter(socket.get())); |
| 741 | 739 |
| 742 if (!helper_.get()) { | 740 if (!helper_.get()) { |
| 743 helper_.reset(new QuicConnectionHelper( | 741 helper_.reset(new QuicConnectionHelper( |
| 744 base::MessageLoop::current()->message_loop_proxy().get(), | 742 base::MessageLoop::current()->message_loop_proxy().get(), |
| 745 clock_.get(), random_generator_)); | 743 clock_.get(), random_generator_)); |
| 746 } | 744 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 base::TimeTicks when = broken_alternate_protocol_list_.front().when; | 833 base::TimeTicks when = broken_alternate_protocol_list_.front().when; |
| 836 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 834 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 837 base::MessageLoop::current()->PostDelayedTask( | 835 base::MessageLoop::current()->PostDelayedTask( |
| 838 FROM_HERE, | 836 FROM_HERE, |
| 839 base::Bind(&QuicStreamFactory::ExpireBrokenAlternateProtocolMappings, | 837 base::Bind(&QuicStreamFactory::ExpireBrokenAlternateProtocolMappings, |
| 840 weak_factory_.GetWeakPtr()), | 838 weak_factory_.GetWeakPtr()), |
| 841 delay); | 839 delay); |
| 842 } | 840 } |
| 843 | 841 |
| 844 } // namespace net | 842 } // namespace net |
| OLD | NEW |