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

Unified Diff: remoting/protocol/connection_to_host_impl.cc

Issue 1520323007: Simplify ConnectionToHost interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sm_cleanup
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/connection_to_host_impl.h ('k') | remoting/protocol/fake_connection_to_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/connection_to_host_impl.cc
diff --git a/remoting/protocol/connection_to_host_impl.cc b/remoting/protocol/connection_to_host_impl.cc
index c17b41efffe74b5a0ded0a187d7e520e8bcc8f23..96f84c95822be167aaed0f4e405315b6cf9ce8bd 100644
--- a/remoting/protocol/connection_to_host_impl.cc
+++ b/remoting/protocol/connection_to_host_impl.cc
@@ -11,7 +11,6 @@
#include "remoting/protocol/audio_reader.h"
#include "remoting/protocol/audio_stub.h"
#include "remoting/protocol/auth_util.h"
-#include "remoting/protocol/authenticator.h"
#include "remoting/protocol/client_control_dispatcher.h"
#include "remoting/protocol/client_event_dispatcher.h"
#include "remoting/protocol/client_stub.h"
@@ -19,35 +18,14 @@
#include "remoting/protocol/clipboard_stub.h"
#include "remoting/protocol/errors.h"
#include "remoting/protocol/ice_transport.h"
-#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/transport.h"
-#include "remoting/protocol/transport_context.h"
#include "remoting/protocol/video_stub.h"
namespace remoting {
namespace protocol {
-ConnectionToHostImpl::ConnectionToHostImpl()
- : event_callback_(nullptr),
- client_stub_(nullptr),
- clipboard_stub_(nullptr),
- audio_stub_(nullptr),
- signal_strategy_(nullptr),
- state_(INITIALIZING),
- error_(OK) {}
-
-ConnectionToHostImpl::~ConnectionToHostImpl() {
- CloseChannels();
-
- if (session_.get())
- session_.reset();
-
- if (session_manager_.get())
- session_manager_.reset();
-
- if (signal_strategy_)
- signal_strategy_->RemoveListener(this);
-}
+ConnectionToHostImpl::ConnectionToHostImpl() {}
+ConnectionToHostImpl::~ConnectionToHostImpl() {}
#define RETURN_STRING_LITERAL(x) \
case x: \
@@ -66,59 +44,18 @@ const char* ConnectionToHost::StateToString(State state) {
return nullptr;
}
-void ConnectionToHostImpl::Connect(
- SignalStrategy* signal_strategy,
- scoped_refptr<TransportContext> transport_context,
- scoped_ptr<Authenticator> authenticator,
- const std::string& host_jid,
- HostEventCallback* event_callback) {
+void ConnectionToHostImpl::Connect(scoped_ptr<Session> session,
+ HostEventCallback* event_callback) {
DCHECK(client_stub_);
DCHECK(clipboard_stub_);
DCHECK(monitored_video_stub_);
- // Initialize default |candidate_config_| if set_candidate_config() wasn't
- // called.
- if (!candidate_config_)
- candidate_config_ = CandidateSessionConfig::CreateDefault();
- if (!audio_stub_)
- candidate_config_->DisableAudioChannel();
+ session_ = session.Pass();
+ session_->SetEventHandler(this);
- signal_strategy_ = signal_strategy;
event_callback_ = event_callback;
- authenticator_ = authenticator.Pass();
-
- // Save jid of the host. The actual connection is created later after
- // |signal_strategy_| is connected.
- host_jid_ = host_jid;
-
- signal_strategy_->AddListener(this);
-
- session_manager_.reset(new JingleSessionManager(
- make_scoped_ptr(new IceTransportFactory(transport_context)),
- signal_strategy));
- session_manager_->set_protocol_config(candidate_config_->Clone());
SetState(CONNECTING, OK);
-
- switch (signal_strategy_->GetState()) {
- case SignalStrategy::CONNECTING:
- // Nothing to do here. Just need to wait until |signal_strategy_| becomes
- // connected.
- break;
- case SignalStrategy::CONNECTED:
- StartSession();
- break;
- case SignalStrategy::DISCONNECTED:
- signal_strategy_->Connect();
- break;
- }
-}
-
-void ConnectionToHostImpl::set_candidate_config(
- scoped_ptr<CandidateSessionConfig> config) {
- DCHECK_EQ(state_, INITIALIZING);
-
- candidate_config_ = config.Pass();
}
const SessionConfig& ConnectionToHostImpl::config() {
@@ -159,35 +96,6 @@ void ConnectionToHostImpl::set_audio_stub(AudioStub* audio_stub) {
audio_stub_ = audio_stub;
}
-void ConnectionToHostImpl::StartSession() {
- DCHECK(CalledOnValidThread());
- DCHECK_EQ(state_, CONNECTING);
-
- session_ = session_manager_->Connect(host_jid_, authenticator_.Pass());
- session_->SetEventHandler(this);
-}
-
-void ConnectionToHostImpl::OnSignalStrategyStateChange(
- SignalStrategy::State state) {
- DCHECK(CalledOnValidThread());
- DCHECK(event_callback_);
-
- if (state == SignalStrategy::CONNECTED) {
- VLOG(1) << "Connected as: " << signal_strategy_->GetLocalJid();
- // After signaling has been connected we can try connecting to the host.
- if (state_ == CONNECTING)
- StartSession();
- } else if (state == SignalStrategy::DISCONNECTED) {
- VLOG(1) << "Connection closed.";
- CloseOnError(SIGNALING_ERROR);
- }
-}
-
-bool ConnectionToHostImpl::OnSignalStrategyIncomingStanza(
- const buzz::XmlElement* stanza) {
- return false;
-}
-
void ConnectionToHostImpl::OnSessionStateChange(Session::State state) {
DCHECK(CalledOnValidThread());
DCHECK(event_callback_);
« no previous file with comments | « remoting/protocol/connection_to_host_impl.h ('k') | remoting/protocol/fake_connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698