OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pepper_session.h" | 5 #include "remoting/protocol/pepper_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 void PepperSession::set_config(const SessionConfig& config) { | 157 void PepperSession::set_config(const SessionConfig& config) { |
158 DCHECK(CalledOnValidThread()); | 158 DCHECK(CalledOnValidThread()); |
159 // set_config() should never be called on the client. | 159 // set_config() should never be called on the client. |
160 NOTREACHED(); | 160 NOTREACHED(); |
161 } | 161 } |
162 | 162 |
163 void PepperSession::Close() { | 163 void PepperSession::Close() { |
164 DCHECK(CalledOnValidThread()); | 164 DCHECK(CalledOnValidThread()); |
165 | 165 |
166 if (state_ == CONNECTING || state_ == CONNECTED) { | 166 if (state_ == CONNECTING || state_ == CONNECTED || state_ == AUTHENTICATED) { |
167 // Send session-terminate message. | 167 // Send session-terminate message. |
168 JingleMessage message(peer_jid_, JingleMessage::SESSION_TERMINATE, | 168 JingleMessage message(peer_jid_, JingleMessage::SESSION_TERMINATE, |
169 session_id_); | 169 session_id_); |
170 scoped_ptr<IqRequest> terminate_request( | 170 scoped_ptr<IqRequest> terminate_request( |
171 session_manager_->iq_sender()->SendIq( | 171 session_manager_->iq_sender()->SendIq( |
172 message.ToXml(), IqSender::ReplyCallback())); | 172 message.ToXml(), IqSender::ReplyCallback())); |
173 } | 173 } |
174 | 174 |
175 CloseInternal(false); | 175 CloseInternal(false); |
176 } | 176 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 return; | 230 return; |
231 } | 231 } |
232 | 232 |
233 if (!InitializeConfigFromDescription(message.description.get())) { | 233 if (!InitializeConfigFromDescription(message.description.get())) { |
234 OnError(INCOMPATIBLE_PROTOCOL); | 234 OnError(INCOMPATIBLE_PROTOCOL); |
235 return; | 235 return; |
236 } | 236 } |
237 | 237 |
238 SetState(CONNECTED); | 238 SetState(CONNECTED); |
239 | 239 |
| 240 if (authenticator_->state() == Authenticator::ACCEPTED) |
| 241 SetState(AUTHENTICATED); |
| 242 |
240 // In case there is transport information in the accept message. | 243 // In case there is transport information in the accept message. |
241 ProcessTransportInfo(message); | 244 ProcessTransportInfo(message); |
242 } | 245 } |
243 | 246 |
244 void PepperSession::ProcessTransportInfo(const JingleMessage& message) { | 247 void PepperSession::ProcessTransportInfo(const JingleMessage& message) { |
245 for (std::list<cricket::Candidate>::const_iterator it = | 248 for (std::list<cricket::Candidate>::const_iterator it = |
246 message.candidates.begin(); | 249 message.candidates.begin(); |
247 it != message.candidates.end(); ++it) { | 250 it != message.candidates.end(); ++it) { |
248 ChannelsMap::iterator channel = channels_.find(it->name()); | 251 ChannelsMap::iterator channel = channels_.find(it->name()); |
249 if (channel == channels_.end()) { | 252 if (channel == channels_.end()) { |
(...skipping 17 matching lines...) Expand all Loading... |
267 break; | 270 break; |
268 | 271 |
269 default: | 272 default: |
270 LOG(WARNING) << "Received session-terminate message " | 273 LOG(WARNING) << "Received session-terminate message " |
271 "with an unexpected reason."; | 274 "with an unexpected reason."; |
272 OnError(SESSION_REJECTED); | 275 OnError(SESSION_REJECTED); |
273 } | 276 } |
274 return; | 277 return; |
275 } | 278 } |
276 | 279 |
277 if (state_ == CONNECTED) { | 280 if (state_ == CONNECTED || state_ == AUTHENTICATED) { |
278 if (message.reason == JingleMessage::GENERAL_ERROR) { | 281 if (message.reason == JingleMessage::GENERAL_ERROR) { |
279 OnError(CHANNEL_CONNECTION_ERROR); | 282 OnError(CHANNEL_CONNECTION_ERROR); |
280 } else { | 283 } else { |
281 CloseInternal(false); | 284 CloseInternal(false); |
282 } | 285 } |
283 return; | 286 return; |
284 } | 287 } |
285 | 288 |
286 LOG(WARNING) << "Received unexpected session-terminate message."; | 289 LOG(WARNING) << "Received unexpected session-terminate message."; |
287 } | 290 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 DCHECK_NE(state_, FAILED); | 368 DCHECK_NE(state_, FAILED); |
366 | 369 |
367 state_ = new_state; | 370 state_ = new_state; |
368 if (!state_change_callback_.is_null()) | 371 if (!state_change_callback_.is_null()) |
369 state_change_callback_.Run(new_state); | 372 state_change_callback_.Run(new_state); |
370 } | 373 } |
371 } | 374 } |
372 | 375 |
373 } // namespace protocol | 376 } // namespace protocol |
374 } // namespace remoting | 377 } // namespace remoting |
OLD | NEW |