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

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

Issue 127113003: Do not delete a QuicSession in StartReading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « no previous file | net/quic/quic_network_transaction_unittest.cc » ('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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 read_buffer_ = new IOBufferWithSize(kMaxPacketSize); 530 read_buffer_ = new IOBufferWithSize(kMaxPacketSize);
531 QuicEncryptedPacket packet(buffer->data(), result); 531 QuicEncryptedPacket packet(buffer->data(), result);
532 IPEndPoint local_address; 532 IPEndPoint local_address;
533 IPEndPoint peer_address; 533 IPEndPoint peer_address;
534 socket_->GetLocalAddress(&local_address); 534 socket_->GetLocalAddress(&local_address);
535 socket_->GetPeerAddress(&peer_address); 535 socket_->GetPeerAddress(&peer_address);
536 // ProcessUdpPacket might result in |this| being deleted, so we 536 // ProcessUdpPacket might result in |this| being deleted, so we
537 // use a weak pointer to be safe. 537 // use a weak pointer to be safe.
538 connection()->ProcessUdpPacket(local_address, peer_address, packet); 538 connection()->ProcessUdpPacket(local_address, peer_address, packet);
539 if (!connection()->connected()) { 539 if (!connection()->connected()) {
540 stream_factory_->OnSessionClosed(this); 540 NotifyFactoryOfSessionClosedLater();
541 return; 541 return;
542 } 542 }
543 StartReading(); 543 StartReading();
544 } 544 }
545 545
546 void QuicClientSession::NotifyFactoryOfSessionGoingAway() { 546 void QuicClientSession::NotifyFactoryOfSessionGoingAway() {
547 if (stream_factory_) 547 if (stream_factory_)
548 stream_factory_->OnSessionGoingAway(this); 548 stream_factory_->OnSessionGoingAway(this);
549 } 549 }
550 550
551 void QuicClientSession::NotifyFactoryOfSessionClosedLater() { 551 void QuicClientSession::NotifyFactoryOfSessionClosedLater() {
552 DCHECK_EQ(0u, GetNumOpenStreams()); 552 DCHECK_EQ(0u, GetNumOpenStreams());
553 DCHECK(!connection()->connected()); 553 DCHECK(!connection()->connected());
554 base::MessageLoop::current()->PostTask( 554 base::MessageLoop::current()->PostTask(
555 FROM_HERE, 555 FROM_HERE,
556 base::Bind(&QuicClientSession::NotifyFactoryOfSessionClosed, 556 base::Bind(&QuicClientSession::NotifyFactoryOfSessionClosed,
557 weak_factory_.GetWeakPtr())); 557 weak_factory_.GetWeakPtr()));
558 } 558 }
559 559
560 void QuicClientSession::NotifyFactoryOfSessionClosed() { 560 void QuicClientSession::NotifyFactoryOfSessionClosed() {
561 DCHECK_EQ(0u, GetNumOpenStreams()); 561 DCHECK_EQ(0u, GetNumOpenStreams());
562 // Will delete |this|. 562 // Will delete |this|.
563 if (stream_factory_) 563 if (stream_factory_)
564 stream_factory_->OnSessionClosed(this); 564 stream_factory_->OnSessionClosed(this);
565 } 565 }
566 566
567 } // namespace net 567 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698