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

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

Issue 7605018: Simplify channel creation callbacks in remoting::Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
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/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 481 }
482 482
483 void JingleSession::OnChannelConnectorFinished( 483 void JingleSession::OnChannelConnectorFinished(
484 const std::string& name, JingleChannelConnector* connector) { 484 const std::string& name, JingleChannelConnector* connector) {
485 DCHECK(CalledOnValidThread()); 485 DCHECK(CalledOnValidThread());
486 DCHECK_EQ(channel_connectors_[name], connector); 486 DCHECK_EQ(channel_connectors_[name], connector);
487 channel_connectors_[name] = NULL; 487 channel_connectors_[name] = NULL;
488 } 488 }
489 489
490 void JingleSession::CreateChannels() { 490 void JingleSession::CreateChannels() {
491 StreamChannelCallback stream_callback( 491 CreateStreamChannel(
492 base::Bind(&JingleSession::OnStreamChannelConnected, 492 kControlChannelName,
493 base::Unretained(this))); 493 base::Bind(&JingleSession::OnChannelConnected,
494 CreateStreamChannel(kControlChannelName, stream_callback); 494 base::Unretained(this), &control_channel_socket_));
495 CreateStreamChannel(kEventChannelName, stream_callback); 495 CreateStreamChannel(
496 kEventChannelName,
497 base::Bind(&JingleSession::OnChannelConnected,
498 base::Unretained(this), &event_channel_socket_));
496 } 499 }
497 500
498 void JingleSession::OnStreamChannelConnected(const std::string& name, 501 void JingleSession::OnChannelConnected(
499 net::StreamSocket* socket) { 502 scoped_ptr<net::Socket>* socket_container,
500 OnChannelConnected(name, socket); 503 net::StreamSocket* socket) {
501 }
502
503 void JingleSession::OnChannelConnected(const std::string& name,
504 net::Socket* socket) {
505 if (!socket) { 504 if (!socket) {
506 LOG(ERROR) << "Failed to connect channel " << name 505 LOG(ERROR) << "Failed to connect control or events channel. "
507 << ". Terminating connection"; 506 << "Terminating connection";
508 CloseInternal(net::ERR_CONNECTION_CLOSED, true); 507 CloseInternal(net::ERR_CONNECTION_CLOSED, true);
509 return; 508 return;
510 } 509 }
511 510
512 if (name == kControlChannelName) { 511 socket_container->reset(socket);
513 control_channel_socket_.reset(socket);
514 } else if (name == kEventChannelName) {
515 event_channel_socket_.reset(socket);
516 } else {
517 NOTREACHED();
518 }
519 512
520 if (control_channel_socket_.get() && event_channel_socket_.get()) { 513 if (control_channel_socket_.get() && event_channel_socket_.get()) {
521 // TODO(sergeyu): State should be set to CONNECTED in OnAccept 514 // TODO(sergeyu): State should be set to CONNECTED in OnAccept
522 // independent of the channels state. 515 // independent of the channels state.
523 SetState(CONNECTED); 516 SetState(CONNECTED);
524 } 517 }
525 } 518 }
526 519
527 const cricket::ContentInfo* JingleSession::GetContentInfo() const { 520 const cricket::ContentInfo* JingleSession::GetContentInfo() const {
528 const cricket::SessionDescription* session_description; 521 const cricket::SessionDescription* session_description;
(...skipping 19 matching lines...) Expand all
548 541
549 state_ = new_state; 542 state_ = new_state;
550 if (!closed_ && state_change_callback_.get()) 543 if (!closed_ && state_change_callback_.get())
551 state_change_callback_->Run(new_state); 544 state_change_callback_->Run(new_state);
552 } 545 }
553 } 546 }
554 547
555 } // namespace protocol 548 } // namespace protocol
556 549
557 } // namespace remoting 550 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698