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

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

Issue 23532042: Report a more specific QUIC error when reading from the socket fails. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « net/quic/quic_client_session.h ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Schedule the work through the message loop to avoid recursive 327 // Schedule the work through the message loop to avoid recursive
328 // callbacks. 328 // callbacks.
329 base::MessageLoop::current()->PostTask( 329 base::MessageLoop::current()->PostTask(
330 FROM_HERE, 330 FROM_HERE,
331 base::Bind(&QuicClientSession::OnReadComplete, 331 base::Bind(&QuicClientSession::OnReadComplete,
332 weak_factory_.GetWeakPtr(), rv)); 332 weak_factory_.GetWeakPtr(), rv));
333 } 333 }
334 334
335 void QuicClientSession::CloseSessionOnError(int error) { 335 void QuicClientSession::CloseSessionOnError(int error) {
336 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.CloseSessionOnError", -error); 336 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.CloseSessionOnError", -error);
337 CloseSessionOnErrorInner(error); 337 CloseSessionOnErrorInner(error, QUIC_INTERNAL_ERROR);
338 NotifyFactoryOfSessionClose(); 338 NotifyFactoryOfSessionClose();
339 } 339 }
340 340
341 void QuicClientSession::CloseSessionOnErrorInner(int error) { 341 void QuicClientSession::CloseSessionOnErrorInner(int net_error,
342 QuicErrorCode quic_error) {
342 if (!callback_.is_null()) { 343 if (!callback_.is_null()) {
343 base::ResetAndReturn(&callback_).Run(error); 344 base::ResetAndReturn(&callback_).Run(net_error);
344 } 345 }
345 while (!streams()->empty()) { 346 while (!streams()->empty()) {
346 ReliableQuicStream* stream = streams()->begin()->second; 347 ReliableQuicStream* stream = streams()->begin()->second;
347 QuicStreamId id = stream->id(); 348 QuicStreamId id = stream->id();
348 static_cast<QuicReliableClientStream*>(stream)->OnError(error); 349 static_cast<QuicReliableClientStream*>(stream)->OnError(net_error);
349 CloseStream(id); 350 CloseStream(id);
350 } 351 }
351 net_log_.AddEvent( 352 net_log_.AddEvent(
352 NetLog::TYPE_QUIC_SESSION_CLOSE_ON_ERROR, 353 NetLog::TYPE_QUIC_SESSION_CLOSE_ON_ERROR,
353 NetLog::IntegerCallback("net_error", error)); 354 NetLog::IntegerCallback("net_error", net_error));
354 355
355 connection()->CloseConnection(QUIC_INTERNAL_ERROR, false); 356 connection()->CloseConnection(quic_error, false);
356 DCHECK(!connection()->connected()); 357 DCHECK(!connection()->connected());
357 } 358 }
358 359
359 base::Value* QuicClientSession::GetInfoAsValue(const HostPortPair& pair) const { 360 base::Value* QuicClientSession::GetInfoAsValue(const HostPortPair& pair) const {
360 base::DictionaryValue* dict = new base::DictionaryValue(); 361 base::DictionaryValue* dict = new base::DictionaryValue();
361 dict->SetString("host_port_pair", pair.ToString()); 362 dict->SetString("host_port_pair", pair.ToString());
362 dict->SetString("version", QuicVersionToString(connection()->version())); 363 dict->SetString("version", QuicVersionToString(connection()->version()));
363 dict->SetInteger("open_streams", GetNumOpenStreams()); 364 dict->SetInteger("open_streams", GetNumOpenStreams());
364 dict->SetInteger("total_streams", num_total_streams_); 365 dict->SetInteger("total_streams", num_total_streams_);
365 dict->SetString("peer_address", peer_address().ToString()); 366 dict->SetString("peer_address", peer_address().ToString());
366 dict->SetString("guid", base::Uint64ToString(guid())); 367 dict->SetString("guid", base::Uint64ToString(guid()));
367 return dict; 368 return dict;
368 } 369 }
369 370
370 base::WeakPtr<QuicClientSession> QuicClientSession::GetWeakPtr() { 371 base::WeakPtr<QuicClientSession> QuicClientSession::GetWeakPtr() {
371 return weak_factory_.GetWeakPtr(); 372 return weak_factory_.GetWeakPtr();
372 } 373 }
373 374
374 void QuicClientSession::OnReadComplete(int result) { 375 void QuicClientSession::OnReadComplete(int result) {
375 read_pending_ = false; 376 read_pending_ = false;
376 if (result == 0) 377 if (result == 0)
377 result = ERR_CONNECTION_CLOSED; 378 result = ERR_CONNECTION_CLOSED;
378 379
379 if (result < 0) { 380 if (result < 0) {
380 DLOG(INFO) << "Closing session on read error: " << result; 381 DLOG(INFO) << "Closing session on read error: " << result;
381 CloseSessionOnErrorInner(result); 382 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.ReadError", -result);
383 CloseSessionOnErrorInner(result, QUIC_PACKET_READ_ERROR);
382 NotifyFactoryOfSessionCloseLater(); 384 NotifyFactoryOfSessionCloseLater();
383 return; 385 return;
384 } 386 }
385 387
386 scoped_refptr<IOBufferWithSize> buffer(read_buffer_); 388 scoped_refptr<IOBufferWithSize> buffer(read_buffer_);
387 read_buffer_ = new IOBufferWithSize(kMaxPacketSize); 389 read_buffer_ = new IOBufferWithSize(kMaxPacketSize);
388 QuicEncryptedPacket packet(buffer->data(), result); 390 QuicEncryptedPacket packet(buffer->data(), result);
389 IPEndPoint local_address; 391 IPEndPoint local_address;
390 IPEndPoint peer_address; 392 IPEndPoint peer_address;
391 socket_->GetLocalAddress(&local_address); 393 socket_->GetLocalAddress(&local_address);
(...skipping 18 matching lines...) Expand all
410 } 412 }
411 413
412 void QuicClientSession::NotifyFactoryOfSessionClose() { 414 void QuicClientSession::NotifyFactoryOfSessionClose() {
413 DCHECK_EQ(0u, GetNumOpenStreams()); 415 DCHECK_EQ(0u, GetNumOpenStreams());
414 DCHECK(stream_factory_); 416 DCHECK(stream_factory_);
415 // Will delete |this|. 417 // Will delete |this|.
416 stream_factory_->OnSessionClose(this); 418 stream_factory_->OnSessionClose(this);
417 } 419 }
418 420
419 } // namespace net 421 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_client_session.h ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698