diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-27 02:24:25 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-27 02:24:25 +0000 |
commit | 41451d5ea9f5e1863c0a51d4f07901aaaf7709ef (patch) | |
tree | 8aeea1115fc3bb76ac23e6a8ad41acda8b97fc48 /net/quic | |
parent | 5e73cf7331a1b9314939e65fde56753b1d7b2ad6 (diff) | |
download | chromium_src-41451d5ea9f5e1863c0a51d4f07901aaaf7709ef.zip chromium_src-41451d5ea9f5e1863c0a51d4f07901aaaf7709ef.tar.gz chromium_src-41451d5ea9f5e1863c0a51d4f07901aaaf7709ef.tar.bz2 |
Read and process up to 32 QUIC packets before yielding to the message loop.
Review URL: https://codereview.chromium.org/44633004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic')
-rw-r--r-- | net/quic/quic_client_session.cc | 21 | ||||
-rw-r--r-- | net/quic/quic_client_session.h | 2 |
2 files changed, 16 insertions, 7 deletions
diff --git a/net/quic/quic_client_session.cc b/net/quic/quic_client_session.cc index dfff3a0..36f7dc0 100644 --- a/net/quic/quic_client_session.cc +++ b/net/quic/quic_client_session.cc @@ -100,6 +100,7 @@ QuicClientSession::QuicClientSession( num_total_streams_(0), net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), logger_(net_log_), + num_packets_read_(0), weak_factory_(this) { crypto_stream_.reset( crypto_client_stream_factory ? @@ -390,16 +391,22 @@ void QuicClientSession::StartReading() { base::Bind(&QuicClientSession::OnReadComplete, weak_factory_.GetWeakPtr())); if (rv == ERR_IO_PENDING) { + num_packets_read_ = 0; return; } - // Data was read, process it. - // Schedule the work through the message loop to avoid recursive - // callbacks. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&QuicClientSession::OnReadComplete, - weak_factory_.GetWeakPtr(), rv)); + if (++num_packets_read_ > 32) { + num_packets_read_ = 0; + // Data was read, process it. + // Schedule the work through the message loop to avoid recursive + // callbacks. + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&QuicClientSession::OnReadComplete, + weak_factory_.GetWeakPtr(), rv)); + } else { + OnReadComplete(rv); + } } void QuicClientSession::CloseSessionOnError(int error) { diff --git a/net/quic/quic_client_session.h b/net/quic/quic_client_session.h index 959dda9..583ba96 100644 --- a/net/quic/quic_client_session.h +++ b/net/quic/quic_client_session.h @@ -208,6 +208,8 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicSession { size_t num_total_streams_; BoundNetLog net_log_; QuicConnectionLogger logger_; + // Number of packets read in the current read loop. + size_t num_packets_read_; base::WeakPtrFactory<QuicClientSession> weak_factory_; DISALLOW_COPY_AND_ASSIGN(QuicClientSession); |