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

Unified Diff: remoting/protocol/jingle_session.cc

Issue 7312013: Minor cleanups in JingleSession and JingleSessionManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments. Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/jingle_session.cc
diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
index f97a73ad228c5c90bc975ef055ffc9a1e04d32e1..feebe2914cfa35157034f96ebfe7295c624e1675 100644
--- a/remoting/protocol/jingle_session.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -159,7 +159,9 @@ JingleSession::JingleSession(
}
JingleSession::~JingleSession() {
- DCHECK(closed_);
+ // Reset the callback so that it's not called from Close().
+ state_change_callback_.reset();
+ Close();
jingle_session_manager_->SessionDestroyed(this);
}
@@ -447,13 +449,20 @@ void JingleSession::OnInitiate() {
video_channel_.reset(
new jingle_glue::TransportChannelSocketAdapter(raw_video_channel_));
- if (!cricket_session_->initiator())
- jingle_session_manager_->AcceptConnection(this, cricket_session_);
-
- if (!closed_) {
- // Set state to CONNECTING if the session is being accepted.
- SetState(CONNECTING);
+ if (!cricket_session_->initiator()) {
+ if (!jingle_session_manager_->AcceptConnection(this, cricket_session_)) {
+ Close();
+ // Release session so that
+ // JingleSessionManager::SessionDestroyed() doesn't try to call
+ // cricket::SessionManager::DestroySession() for it.
+ ReleaseSession();
+ delete this;
+ return;
+ }
}
+
+ // Set state to CONNECTING if the session is being accepted.
+ SetState(CONNECTING);
}
bool JingleSession::EstablishPseudoTcp(

Powered by Google App Engine
This is Rietveld 408576698