OLD | NEW |
---|---|
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 "remoting/protocol/jingle_session_manager.h" | 5 #include "remoting/protocol/jingle_session_manager.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 } | 115 } |
116 | 116 |
117 void JingleSessionManager::set_authenticator_factory( | 117 void JingleSessionManager::set_authenticator_factory( |
118 scoped_ptr<AuthenticatorFactory> authenticator_factory) { | 118 scoped_ptr<AuthenticatorFactory> authenticator_factory) { |
119 DCHECK(CalledOnValidThread()); | 119 DCHECK(CalledOnValidThread()); |
120 DCHECK(authenticator_factory.get()); | 120 DCHECK(authenticator_factory.get()); |
121 DCHECK(!authenticator_factory_.get()); | 121 DCHECK(!authenticator_factory_.get()); |
122 authenticator_factory_ = authenticator_factory.Pass(); | 122 authenticator_factory_ = authenticator_factory.Pass(); |
123 } | 123 } |
124 | 124 |
125 Session* JingleSessionManager::Connect( | 125 scoped_ptr<Session> JingleSessionManager::Connect( |
126 const std::string& host_jid, | 126 const std::string& host_jid, |
127 Authenticator* authenticator, | 127 scoped_ptr<Authenticator> authenticator, |
128 CandidateSessionConfig* candidate_config, | 128 scoped_ptr<CandidateSessionConfig> config, |
129 const Session::StateChangeCallback& state_change_callback) { | 129 const Session::StateChangeCallback& state_change_callback) { |
130 DCHECK(CalledOnValidThread()); | 130 DCHECK(CalledOnValidThread()); |
131 | 131 |
132 cricket::Session* cricket_session = cricket_session_manager_->CreateSession( | 132 cricket::Session* cricket_session = cricket_session_manager_->CreateSession( |
133 signal_strategy_->GetLocalJid(), kChromotingXmlNamespace); | 133 signal_strategy_->GetLocalJid(), kChromotingXmlNamespace); |
134 cricket_session->set_remote_name(host_jid); | 134 cricket_session->set_remote_name(host_jid); |
135 | 135 |
136 JingleSession* jingle_session = | 136 JingleSession* jingle_session = |
Wez
2012/01/19 03:18:17
Shouldn't this become a scoped_ptr, and the return
Sergey Ulanov
2012/01/19 20:11:42
Done. This is a case when Pass() doesn't work well
Wez
2012/01/19 23:23:41
Ah... the RValue template classes don't mirror the
| |
137 new JingleSession(this, cricket_session, authenticator); | 137 new JingleSession(this, cricket_session, authenticator.Pass()); |
138 jingle_session->set_candidate_config(candidate_config); | 138 jingle_session->set_candidate_config(config.Pass()); |
139 jingle_session->SetStateChangeCallback(state_change_callback); | 139 jingle_session->SetStateChangeCallback(state_change_callback); |
140 sessions_.push_back(jingle_session); | 140 sessions_.push_back(jingle_session); |
141 | 141 |
142 jingle_session->SendSessionInitiate(); | 142 jingle_session->SendSessionInitiate(); |
143 | 143 |
144 return jingle_session; | 144 return scoped_ptr<Session>(jingle_session); |
145 } | 145 } |
146 | 146 |
147 void JingleSessionManager::OnSessionCreate( | 147 void JingleSessionManager::OnSessionCreate( |
148 cricket::Session* cricket_session, bool incoming) { | 148 cricket::Session* cricket_session, bool incoming) { |
149 DCHECK(CalledOnValidThread()); | 149 DCHECK(CalledOnValidThread()); |
150 | 150 |
151 // Allow local connections. | 151 // Allow local connections. |
152 cricket_session->set_allow_local_ips(true); | 152 cricket_session->set_allow_local_ips(true); |
153 | 153 |
154 if (incoming) { | 154 if (incoming) { |
155 JingleSession* jingle_session = | 155 JingleSession* jingle_session = |
156 new JingleSession(this, cricket_session, NULL); | 156 new JingleSession(this, cricket_session, scoped_ptr<Authenticator>()); |
Wez
2012/01/19 03:18:17
nit: Ouch; unfortunate. :-/
Sergey Ulanov
2012/01/19 20:11:42
I was considering removing that last parameter fro
Wez
2012/01/19 23:23:41
Agreed.
| |
157 sessions_.push_back(jingle_session); | 157 sessions_.push_back(jingle_session); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void JingleSessionManager::OnSessionDestroy(cricket::Session* cricket_session) { | 161 void JingleSessionManager::OnSessionDestroy(cricket::Session* cricket_session) { |
162 DCHECK(CalledOnValidThread()); | 162 DCHECK(CalledOnValidThread()); |
163 | 163 |
164 std::list<JingleSession*>::iterator it; | 164 std::list<JingleSession*>::iterator it; |
165 for (it = sessions_.begin(); it != sessions_.end(); ++it) { | 165 for (it = sessions_.begin(); it != sessions_.end(); ++it) { |
166 if ((*it)->HasSession(cricket_session)) { | 166 if ((*it)->HasSession(cricket_session)) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 cricket::WriteError* error) { | 261 cricket::WriteError* error) { |
262 const ContentDescription* desc = | 262 const ContentDescription* desc = |
263 static_cast<const ContentDescription*>(content); | 263 static_cast<const ContentDescription*>(content); |
264 | 264 |
265 *elem = desc->ToXml(); | 265 *elem = desc->ToXml(); |
266 return true; | 266 return true; |
267 } | 267 } |
268 | 268 |
269 } // namespace protocol | 269 } // namespace protocol |
270 } // namespace remoting | 270 } // namespace remoting |
OLD | NEW |