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

Unified Diff: remoting/protocol/jingle_session.cc

Issue 4313001: Rename classes for Chromoting: (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Resolve merge conflicts Created 10 years, 1 month 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
« no previous file with comments | « remoting/protocol/jingle_session.h ('k') | remoting/protocol/jingle_session_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/jingle_session.cc
diff --git a/remoting/protocol/jingle_chromotocol_connection.cc b/remoting/protocol/jingle_session.cc
similarity index 55%
rename from remoting/protocol/jingle_chromotocol_connection.cc
rename to remoting/protocol/jingle_session.cc
index 01b7bace685b3e38a08ec1f84fa2c72c29e6bc16..4ed6b4fd7e696bd683543c1110417b504bf9f5ef 100644
--- a/remoting/protocol/jingle_chromotocol_connection.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/protocol/jingle_chromotocol_connection.h"
+#include "remoting/protocol/jingle_session.h"
#include "base/message_loop.h"
#include "net/base/net_errors.h"
@@ -10,17 +10,18 @@
#include "remoting/jingle_glue/channel_socket_adapter.h"
#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/jingle_glue/stream_socket_adapter.h"
-#include "remoting/protocol/jingle_chromotocol_server.h"
+#include "remoting/protocol/jingle_session_manager.h"
#include "third_party/libjingle/source/talk/base/thread.h"
#include "third_party/libjingle/source/talk/p2p/base/session.h"
#include "third_party/libjingle/source/talk/session/tunnel/pseudotcpchannel.h"
using cricket::BaseSession;
using cricket::PseudoTcpChannel;
-using cricket::Session;
namespace remoting {
+namespace protocol {
+
namespace {
const char kControlChannelName[] = "control";
const char kEventChannelName[] = "event";
@@ -29,118 +30,118 @@ const char kVideoRtpChannelName[] = "videortp";
const char kVideoRtcpChannelName[] = "videortcp";
} // namespace
-const char JingleChromotocolConnection::kChromotingContentName[] = "chromoting";
+const char JingleSession::kChromotingContentName[] = "chromoting";
-JingleChromotocolConnection::JingleChromotocolConnection(
- JingleChromotocolServer* server)
- : server_(server),
+JingleSession::JingleSession(
+ JingleSessionManager* jingle_session_manager)
+ : jingle_session_manager_(jingle_session_manager),
state_(INITIALIZING),
closed_(false),
- session_(NULL),
+ cricket_session_(NULL),
event_channel_(NULL),
video_channel_(NULL) {
}
-JingleChromotocolConnection::~JingleChromotocolConnection() {
+JingleSession::~JingleSession() {
DCHECK(closed_);
}
-void JingleChromotocolConnection::Init(Session* session) {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+void JingleSession::Init(cricket::Session* cricket_session) {
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
- session_ = session;
- jid_ = session_->remote_name();
- session_->SignalState.connect(
- this, &JingleChromotocolConnection::OnSessionState);
+ cricket_session_ = cricket_session;
+ jid_ = cricket_session_->remote_name();
+ cricket_session_->SignalState.connect(
+ this, &JingleSession::OnSessionState);
}
-bool JingleChromotocolConnection::HasSession(cricket::Session* session) {
- return session_ == session;
+bool JingleSession::HasSession(cricket::Session* cricket_session) {
+ return cricket_session_ == cricket_session;
}
-Session* JingleChromotocolConnection::ReleaseSession() {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+cricket::Session* JingleSession::ReleaseSession() {
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
SetState(CLOSED);
- Session* session = session_;
- if (session_)
- session_->SignalState.disconnect(this);
- session_ = NULL;
+ cricket::Session* session = cricket_session_;
+ if (cricket_session_)
+ cricket_session_->SignalState.disconnect(this);
+ cricket_session_ = NULL;
closed_ = true;
return session;
}
-void JingleChromotocolConnection::SetStateChangeCallback(
+void JingleSession::SetStateChangeCallback(
StateChangeCallback* callback) {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
DCHECK(callback);
state_change_callback_.reset(callback);
}
-net::Socket* JingleChromotocolConnection::control_channel() {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+net::Socket* JingleSession::control_channel() {
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
return control_channel_adapter_.get();
}
-net::Socket* JingleChromotocolConnection::event_channel() {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+net::Socket* JingleSession::event_channel() {
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
return event_channel_adapter_.get();
}
// TODO(sergeyu): Remove this method after we switch to RTP.
-net::Socket* JingleChromotocolConnection::video_channel() {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+net::Socket* JingleSession::video_channel() {
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
return video_channel_adapter_.get();
}
-net::Socket* JingleChromotocolConnection::video_rtp_channel() {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+net::Socket* JingleSession::video_rtp_channel() {
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
return video_rtp_channel_.get();
}
-net::Socket* JingleChromotocolConnection::video_rtcp_channel() {
- DCHECK_EQ(server_->message_loop(), MessageLoop::current());
+net::Socket* JingleSession::video_rtcp_channel() {
+ DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current());
return video_rtcp_channel_.get();
}
-const std::string& JingleChromotocolConnection::jid() {
+const std::string& JingleSession::jid() {
// No synchronization is needed because jid_ is not changed
// after new connection is passed to JingleChromotocolServer callback.
return jid_;
}
-MessageLoop* JingleChromotocolConnection::message_loop() {
- return server_->message_loop();
+MessageLoop* JingleSession::message_loop() {
+ return jingle_session_manager_->message_loop();
}
const CandidateChromotocolConfig*
-JingleChromotocolConnection::candidate_config() {
+JingleSession::candidate_config() {
DCHECK(candidate_config_.get());
return candidate_config_.get();
}
-void JingleChromotocolConnection::set_candidate_config(
+void JingleSession::set_candidate_config(
const CandidateChromotocolConfig* candidate_config) {
DCHECK(!candidate_config_.get());
DCHECK(candidate_config);
candidate_config_.reset(candidate_config);
}
-const ChromotocolConfig* JingleChromotocolConnection::config() {
+const ChromotocolConfig* JingleSession::config() {
DCHECK(config_.get());
return config_.get();
}
-void JingleChromotocolConnection::set_config(const ChromotocolConfig* config) {
+void JingleSession::set_config(const ChromotocolConfig* config) {
DCHECK(!config_.get());
DCHECK(config);
config_.reset(config);
}
-void JingleChromotocolConnection::Close(Task* closed_task) {
- if (MessageLoop::current() != server_->message_loop()) {
- server_->message_loop()->PostTask(
- FROM_HERE, NewRunnableMethod(this, &JingleChromotocolConnection::Close,
+void JingleSession::Close(Task* closed_task) {
+ if (MessageLoop::current() != jingle_session_manager_->message_loop()) {
+ jingle_session_manager_->message_loop()->PostTask(
+ FROM_HERE, NewRunnableMethod(this, &JingleSession::Close,
closed_task));
return;
}
@@ -150,7 +151,7 @@ void JingleChromotocolConnection::Close(Task* closed_task) {
control_channel_adapter_->Close(net::ERR_CONNECTION_CLOSED);
if (control_channel_) {
- control_channel_->OnSessionTerminate(session_);
+ control_channel_->OnSessionTerminate(cricket_session_);
control_channel_ = NULL;
}
@@ -158,7 +159,7 @@ void JingleChromotocolConnection::Close(Task* closed_task) {
event_channel_adapter_->Close(net::ERR_CONNECTION_CLOSED);
if (event_channel_) {
- event_channel_->OnSessionTerminate(session_);
+ event_channel_->OnSessionTerminate(cricket_session_);
event_channel_ = NULL;
}
@@ -166,7 +167,7 @@ void JingleChromotocolConnection::Close(Task* closed_task) {
video_channel_adapter_->Close(net::ERR_CONNECTION_CLOSED);
if (video_channel_) {
- video_channel_->OnSessionTerminate(session_);
+ video_channel_->OnSessionTerminate(cricket_session_);
video_channel_ = NULL;
}
@@ -175,8 +176,8 @@ void JingleChromotocolConnection::Close(Task* closed_task) {
if (video_rtcp_channel_.get())
video_rtcp_channel_->Close(net::ERR_CONNECTION_CLOSED);
- if (session_)
- session_->Terminate();
+ if (cricket_session_)
+ cricket_session_->Terminate();
SetState(CLOSED);
@@ -187,29 +188,29 @@ void JingleChromotocolConnection::Close(Task* closed_task) {
delete closed_task;
}
-void JingleChromotocolConnection::OnSessionState(
+void JingleSession::OnSessionState(
BaseSession* session, BaseSession::State state) {
- DCHECK_EQ(session_, session);
+ DCHECK_EQ(cricket_session_, session);
switch (state) {
- case Session::STATE_SENTINITIATE:
- case Session::STATE_RECEIVEDINITIATE:
+ case cricket::Session::STATE_SENTINITIATE:
+ case cricket::Session::STATE_RECEIVEDINITIATE:
OnInitiate();
break;
- case Session::STATE_SENTACCEPT:
- case Session::STATE_RECEIVEDACCEPT:
+ case cricket::Session::STATE_SENTACCEPT:
+ case cricket::Session::STATE_RECEIVEDACCEPT:
OnAccept();
break;
- case Session::STATE_SENTTERMINATE:
- case Session::STATE_RECEIVEDTERMINATE:
- case Session::STATE_SENTREJECT:
- case Session::STATE_RECEIVEDREJECT:
+ case cricket::Session::STATE_SENTTERMINATE:
+ case cricket::Session::STATE_RECEIVEDTERMINATE:
+ case cricket::Session::STATE_SENTREJECT:
+ case cricket::Session::STATE_RECEIVEDREJECT:
OnTerminate();
break;
- case Session::STATE_DEINIT:
+ case cricket::Session::STATE_DEINIT:
// Close() must have been called before this.
NOTREACHED();
break;
@@ -220,17 +221,17 @@ void JingleChromotocolConnection::OnSessionState(
}
}
-void JingleChromotocolConnection::OnInitiate() {
- jid_ = session_->remote_name();
+void JingleSession::OnInitiate() {
+ jid_ = cricket_session_->remote_name();
std::string content_name;
- // If we initiate the connection, we get to specify the content name. When
+ // If we initiate the session, we get to specify the content name. When
// accepting one, the remote end specifies it.
- if (session_->initiator()) {
+ if (cricket_session_->initiator()) {
content_name = kChromotingContentName;
} else {
const cricket::ContentInfo* content;
- content = session_->remote_description()->FirstContentByType(
+ content = cricket_session_->remote_description()->FirstContentByType(
kChromotingXmlNamespace);
CHECK(content);
content_name = content->name;
@@ -238,45 +239,48 @@ void JingleChromotocolConnection::OnInitiate() {
// Create video RTP channels.
video_rtp_channel_.reset(new TransportChannelSocketAdapter(
- session_->CreateChannel(content_name, kVideoRtpChannelName)));
+ cricket_session_->CreateChannel(content_name, kVideoRtpChannelName)));
video_rtcp_channel_.reset(new TransportChannelSocketAdapter(
- session_->CreateChannel(content_name, kVideoRtcpChannelName)));
+ cricket_session_->CreateChannel(content_name, kVideoRtcpChannelName)));
// Create control channel.
- control_channel_ = new PseudoTcpChannel(server_->jingle_thread(), session_);
+ control_channel_ = new PseudoTcpChannel(
+ jingle_session_manager_->jingle_thread(), cricket_session_);
control_channel_->Connect(content_name, kControlChannelName);
control_channel_adapter_.reset(new StreamSocketAdapter(
control_channel_->GetStream()));
// Create event channel.
- event_channel_ = new PseudoTcpChannel(server_->jingle_thread(), session_);
+ event_channel_ = new PseudoTcpChannel(
+ jingle_session_manager_->jingle_thread(), cricket_session_);
event_channel_->Connect(content_name, kEventChannelName);
event_channel_adapter_.reset(new StreamSocketAdapter(
event_channel_->GetStream()));
// Create video channel.
// TODO(sergeyu): Remove video channel when we are ready to switch to RTP.
- video_channel_ = new PseudoTcpChannel(server_->jingle_thread(), session_);
+ video_channel_ = new PseudoTcpChannel(
+ jingle_session_manager_->jingle_thread(), cricket_session_);
video_channel_->Connect(content_name, kVideoChannelName);
video_channel_adapter_.reset(new StreamSocketAdapter(
video_channel_->GetStream()));
- if (!session_->initiator())
- server_->AcceptConnection(this, session_);
+ if (!cricket_session_->initiator())
+ jingle_session_manager_->AcceptConnection(this, cricket_session_);
SetState(CONNECTING);
}
-void JingleChromotocolConnection::OnAccept() {
- // Set config for outgoing connections.
- if (session_->initiator()) {
+void JingleSession::OnAccept() {
+ // Set the config if we are the one who initiated the session.
+ if (cricket_session_->initiator()) {
const cricket::ContentInfo* content =
- session_->remote_description()->FirstContentByType(
+ cricket_session_->remote_description()->FirstContentByType(
kChromotingXmlNamespace);
CHECK(content);
- const ChromotocolContentDescription* content_description =
- static_cast<const ChromotocolContentDescription*>(content->description);
+ const protocol::ContentDescription* content_description =
+ static_cast<const protocol::ContentDescription*>(content->description);
ChromotocolConfig* config = content_description->config()->GetFinalConfig();
// Terminate the session if the config we received is invalid.
@@ -284,7 +288,7 @@ void JingleChromotocolConnection::OnAccept() {
// TODO(sergeyu): Inform the user that the host is misbehaving?
LOG(ERROR) << "Terminating outgoing session after an "
"invalid session description has been received.";
- session_->Terminate();
+ cricket_session_->Terminate();
return;
}
@@ -294,25 +298,25 @@ void JingleChromotocolConnection::OnAccept() {
SetState(CONNECTED);
}
-void JingleChromotocolConnection::OnTerminate() {
+void JingleSession::OnTerminate() {
if (control_channel_adapter_.get())
control_channel_adapter_->Close(net::ERR_CONNECTION_ABORTED);
if (control_channel_) {
- control_channel_->OnSessionTerminate(session_);
+ control_channel_->OnSessionTerminate(cricket_session_);
control_channel_ = NULL;
}
if (event_channel_adapter_.get())
event_channel_adapter_->Close(net::ERR_CONNECTION_ABORTED);
if (event_channel_) {
- event_channel_->OnSessionTerminate(session_);
+ event_channel_->OnSessionTerminate(cricket_session_);
event_channel_ = NULL;
}
if (video_channel_adapter_.get())
video_channel_adapter_->Close(net::ERR_CONNECTION_ABORTED);
if (video_channel_) {
- video_channel_->OnSessionTerminate(session_);
+ video_channel_->OnSessionTerminate(cricket_session_);
video_channel_ = NULL;
}
@@ -326,7 +330,7 @@ void JingleChromotocolConnection::OnTerminate() {
closed_ = true;
}
-void JingleChromotocolConnection::SetState(State new_state) {
+void JingleSession::SetState(State new_state) {
if (new_state != state_) {
state_ = new_state;
if (!closed_ && state_change_callback_.get())
@@ -334,4 +338,6 @@ void JingleChromotocolConnection::SetState(State new_state) {
}
}
+} // namespace protocol
+
} // namespace remoting
« no previous file with comments | « remoting/protocol/jingle_session.h ('k') | remoting/protocol/jingle_session_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698