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

Side by Side Diff: remoting/protocol/jingle_session.cc

Issue 8743023: Separate Authenticator and Session unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years 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
OLDNEW
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/jingle_session.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 27 matching lines...) Expand all
38 authenticator_(authenticator), 38 authenticator_(authenticator),
39 state_(INITIALIZING), 39 state_(INITIALIZING),
40 error_(OK), 40 error_(OK),
41 closing_(false), 41 closing_(false),
42 cricket_session_(cricket_session), 42 cricket_session_(cricket_session),
43 config_set_(false), 43 config_set_(false),
44 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { 44 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
45 jid_ = cricket_session_->remote_name(); 45 jid_ = cricket_session_->remote_name();
46 cricket_session_->SignalState.connect(this, &JingleSession::OnSessionState); 46 cricket_session_->SignalState.connect(this, &JingleSession::OnSessionState);
47 cricket_session_->SignalError.connect(this, &JingleSession::OnSessionError); 47 cricket_session_->SignalError.connect(this, &JingleSession::OnSessionError);
48 cricket_session_->SignalReceivedTerminateReason.connect(
49 this, &JingleSession::OnTerminateReason);
48 } 50 }
49 51
50 JingleSession::~JingleSession() { 52 JingleSession::~JingleSession() {
51 // Reset the callback so that it's not called from Close(). 53 // Reset the callback so that it's not called from Close().
52 state_change_callback_.Reset(); 54 state_change_callback_.Reset();
53 Close(); 55 Close();
54 jingle_session_manager_->SessionDestroyed(this); 56 jingle_session_manager_->SessionDestroyed(this);
55 DCHECK(channel_connectors_.empty()); 57 DCHECK(channel_connectors_.empty());
56 } 58 }
57 59
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 BaseSession* session, BaseSession::Error error) { 239 BaseSession* session, BaseSession::Error error) {
238 DCHECK(CalledOnValidThread()); 240 DCHECK(CalledOnValidThread());
239 DCHECK_EQ(cricket_session_, session); 241 DCHECK_EQ(cricket_session_, session);
240 242
241 if (error != cricket::Session::ERROR_NONE) { 243 if (error != cricket::Session::ERROR_NONE) {
242 // TODO(sergeyu): Report different errors depending on |error|. 244 // TODO(sergeyu): Report different errors depending on |error|.
243 CloseInternal(net::ERR_CONNECTION_ABORTED, CHANNEL_CONNECTION_ERROR); 245 CloseInternal(net::ERR_CONNECTION_ABORTED, CHANNEL_CONNECTION_ERROR);
244 } 246 }
245 } 247 }
246 248
249 void JingleSession::OnTerminateReason(cricket::Session* session,
250 const std::string& reason) {
251 terminate_reason_ = reason;
252 }
253
254
247 void JingleSession::OnInitiate() { 255 void JingleSession::OnInitiate() {
248 DCHECK(CalledOnValidThread()); 256 DCHECK(CalledOnValidThread());
249 jid_ = cricket_session_->remote_name(); 257 jid_ = cricket_session_->remote_name();
250 258
251 if (cricket_session_->initiator()) { 259 if (cricket_session_->initiator()) {
252 // Set state to CONNECTING if this is an outgoing message. We need 260 // Set state to CONNECTING if this is an outgoing message. We need
253 // to post this task because channel creation works only after we 261 // to post this task because channel creation works only after we
254 // return from this method. This is because 262 // return from this method. This is because
255 // JingleChannelConnector::Connect() needs to call 263 // JingleChannelConnector::Connect() needs to call
256 // set_incoming_only() on P2PTransportChannel, but 264 // set_incoming_only() on P2PTransportChannel, but
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 333 }
326 334
327 SetState(CONNECTED); 335 SetState(CONNECTED);
328 336
329 if (authenticator_->state() == Authenticator::ACCEPTED) 337 if (authenticator_->state() == Authenticator::ACCEPTED)
330 SetState(AUTHENTICATED); 338 SetState(AUTHENTICATED);
331 } 339 }
332 340
333 void JingleSession::OnTerminate() { 341 void JingleSession::OnTerminate() {
334 DCHECK(CalledOnValidThread()); 342 DCHECK(CalledOnValidThread());
335 CloseInternal(net::ERR_CONNECTION_ABORTED, OK); 343
344 if (terminate_reason_ == "decline") {
345 CloseInternal(net::ERR_CONNECTION_ABORTED, AUTHENTICATION_FAILED);
346 } else if (terminate_reason_ == "incompatible-protocol") {
347 CloseInternal(net::ERR_CONNECTION_ABORTED, INCOMPATIBLE_PROTOCOL);
348 } else {
349 CloseInternal(net::ERR_CONNECTION_ABORTED, OK);
Wez 2011/12/13 00:12:38 This looks like a fix to JingleSession, presumably
Sergey Ulanov 2011/12/13 02:31:55 Done.
350 }
336 } 351 }
337 352
338 void JingleSession::AcceptConnection() { 353 void JingleSession::AcceptConnection() {
339 SetState(CONNECTING); 354 SetState(CONNECTING);
340 355
341 const cricket::SessionDescription* session_description = 356 const cricket::SessionDescription* session_description =
342 cricket_session_->remote_description(); 357 cricket_session_->remote_description();
343 const cricket::ContentInfo* content = 358 const cricket::ContentInfo* content =
344 session_description->FirstContentByType(kChromotingXmlNamespace); 359 session_description->FirstContentByType(kChromotingXmlNamespace);
345 360
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 const buzz::XmlElement* authenticator_message) { 483 const buzz::XmlElement* authenticator_message) {
469 cricket::SessionDescription* desc = new cricket::SessionDescription(); 484 cricket::SessionDescription* desc = new cricket::SessionDescription();
470 desc->AddContent( 485 desc->AddContent(
471 ContentDescription::kChromotingContentName, kChromotingXmlNamespace, 486 ContentDescription::kChromotingContentName, kChromotingXmlNamespace,
472 new ContentDescription(config, authenticator_message)); 487 new ContentDescription(config, authenticator_message));
473 return desc; 488 return desc;
474 } 489 }
475 490
476 } // namespace protocol 491 } // namespace protocol
477 } // namespace remoting 492 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698