Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: net/quic/quic_stream_factory.cc

Issue 217573002: make SetReceiveBufferSize and SetSendBufferSize return net error codes (instead of bools) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: process error code in quic_stream_factory Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 DCHECK_LE(1u, port_suggester->call_count()); 698 DCHECK_LE(1u, port_suggester->call_count());
699 } else { 699 } else {
700 DCHECK_EQ(0u, port_suggester->call_count()); 700 DCHECK_EQ(0u, port_suggester->call_count());
701 } 701 }
702 702
703 // We should adaptively set this buffer size, but for now, we'll use a size 703 // We should adaptively set this buffer size, but for now, we'll use a size
704 // that is more than large enough for a full receive window, and yet 704 // that is more than large enough for a full receive window, and yet
705 // does not consume "too much" memory. If we see bursty packet loss, we may 705 // does not consume "too much" memory. If we see bursty packet loss, we may
706 // revisit this setting and test for its impact. 706 // revisit this setting and test for its impact.
707 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP); 707 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP);
708 if (!socket->SetReceiveBufferSize(kSocketBufferSize)) { 708 rv = socket->SetReceiveBufferSize(kSocketBufferSize);
709 if (rv != OK) {
709 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER); 710 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER);
710 return ERR_SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR; 711 return rv;
711 } 712 }
712 // Set a buffer large enough to contain the initial CWND's worth of packet 713 // Set a buffer large enough to contain the initial CWND's worth of packet
713 // to work around the problem with CHLO packets being sent out with the 714 // to work around the problem with CHLO packets being sent out with the
714 // wrong encryption level, when the send buffer is full. 715 // wrong encryption level, when the send buffer is full.
715 if (!socket->SetSendBufferSize(kMaxPacketSize * 20)) { 716 rv = socket->SetSendBufferSize(kMaxPacketSize * 20);
717 if (rv != OK) {
716 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); 718 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER);
717 return ERR_SOCKET_SET_SEND_BUFFER_SIZE_ERROR; 719 return rv;
718 } 720 }
719 721
720 scoped_ptr<QuicDefaultPacketWriter> writer( 722 scoped_ptr<QuicDefaultPacketWriter> writer(
721 new QuicDefaultPacketWriter(socket.get())); 723 new QuicDefaultPacketWriter(socket.get()));
722 724
723 if (!helper_.get()) { 725 if (!helper_.get()) {
724 helper_.reset(new QuicConnectionHelper( 726 helper_.reset(new QuicConnectionHelper(
725 base::MessageLoop::current()->message_loop_proxy().get(), 727 base::MessageLoop::current()->message_loop_proxy().get(),
726 clock_.get(), random_generator_)); 728 clock_.get(), random_generator_));
727 } 729 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 base::TimeTicks when = broken_alternate_protocol_list_.front().when; 819 base::TimeTicks when = broken_alternate_protocol_list_.front().when;
818 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 820 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
819 base::MessageLoop::current()->PostDelayedTask( 821 base::MessageLoop::current()->PostDelayedTask(
820 FROM_HERE, 822 FROM_HERE,
821 base::Bind(&QuicStreamFactory::ExpireBrokenAlternateProtocolMappings, 823 base::Bind(&QuicStreamFactory::ExpireBrokenAlternateProtocolMappings,
822 weak_factory_.GetWeakPtr()), 824 weak_factory_.GetWeakPtr()),
823 delay); 825 delay);
824 } 826 }
825 827
826 } // namespace net 828 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698