diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 03:39:41 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 03:39:41 +0000 |
commit | 086870fa2983dd7e00fbccbce03a6728976c2a36 (patch) | |
tree | 6b61fb170c04e90861141ee584b172291801f0f0 /remoting/protocol | |
parent | d1b290804b850db6960d39773acfb171ca61a4c5 (diff) | |
download | chromium_src-086870fa2983dd7e00fbccbce03a6728976c2a36.zip chromium_src-086870fa2983dd7e00fbccbce03a6728976c2a36.tar.gz chromium_src-086870fa2983dd7e00fbccbce03a6728976c2a36.tar.bz2 |
Move ConnectionToHost parameters out from Connect() call.
Connect() has ended up acquiring all of the ConnectionToHost's
configuration settings as parameters, making calling code harder to read
especially as more new parameters are added.
Review URL: https://codereview.chromium.org/279273002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272074 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/connection_to_client.h | 4 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 71 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.h | 36 |
3 files changed, 64 insertions, 47 deletions
diff --git a/remoting/protocol/connection_to_client.h b/remoting/protocol/connection_to_client.h index 9a64dcd..b80e9fd 100644 --- a/remoting/protocol/connection_to_client.h +++ b/remoting/protocol/connection_to_client.h @@ -16,10 +16,6 @@ #include "remoting/protocol/session.h" #include "remoting/protocol/video_writer.h" -namespace net { -class IPEndPoint; -} // namespace net - namespace remoting { namespace protocol { diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index d2ce7ff..d09eaa1 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -51,40 +51,18 @@ ConnectionToHost::~ConnectionToHost() { signal_strategy_->RemoveListener(this); } -ClipboardStub* ConnectionToHost::clipboard_stub() { - return &clipboard_forwarder_; -} - -HostStub* ConnectionToHost::host_stub() { - // TODO(wez): Add a HostFilter class, equivalent to input filter. - return control_dispatcher_.get(); -} - -InputStub* ConnectionToHost::input_stub() { - return &event_forwarder_; -} - void ConnectionToHost::Connect(SignalStrategy* signal_strategy, - const std::string& host_jid, - const std::string& host_public_key, scoped_ptr<TransportFactory> transport_factory, scoped_ptr<Authenticator> authenticator, - HostEventCallback* event_callback, - ClientStub* client_stub, - ClipboardStub* clipboard_stub, - VideoStub* video_stub, - AudioStub* audio_stub) { + const std::string& host_jid, + const std::string& host_public_key, + HostEventCallback* event_callback) { + DCHECK(client_stub_); + DCHECK(clipboard_stub_); + DCHECK(monitored_video_stub_); + signal_strategy_ = signal_strategy; event_callback_ = event_callback; - client_stub_ = client_stub; - clipboard_stub_ = clipboard_stub; - monitored_video_stub_.reset(new MonitoredVideoStub( - video_stub, - base::TimeDelta::FromSeconds( - MonitoredVideoStub::kConnectivityCheckDelaySeconds), - base::Bind(&ConnectionToHost::OnVideoChannelStatus, - base::Unretained(this)))); - audio_stub_ = audio_stub; authenticator_ = authenticator.Pass(); // Save jid of the host. The actual connection is created later after @@ -105,6 +83,41 @@ const SessionConfig& ConnectionToHost::config() { return session_->config(); } +ClipboardStub* ConnectionToHost::clipboard_forwarder() { + return &clipboard_forwarder_; +} + +HostStub* ConnectionToHost::host_stub() { + // TODO(wez): Add a HostFilter class, equivalent to input filter. + return control_dispatcher_.get(); +} + +InputStub* ConnectionToHost::input_stub() { + return &event_forwarder_; +} + +void ConnectionToHost::set_client_stub(ClientStub* client_stub) { + client_stub_ = client_stub; +} + +void ConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) { + clipboard_stub_ = clipboard_stub; +} + +void ConnectionToHost::set_video_stub(VideoStub* video_stub) { + DCHECK(video_stub); + monitored_video_stub_.reset(new MonitoredVideoStub( + video_stub, + base::TimeDelta::FromSeconds( + MonitoredVideoStub::kConnectivityCheckDelaySeconds), + base::Bind(&ConnectionToHost::OnVideoChannelStatus, + base::Unretained(this)))); +} + +void ConnectionToHost::set_audio_stub(AudioStub* audio_stub) { + audio_stub_ = audio_stub; +} + void ConnectionToHost::OnSignalStrategyStateChange( SignalStrategy::State state) { DCHECK(CalledOnValidThread()); diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index e50e041..d1e1313 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -23,10 +23,6 @@ #include "remoting/protocol/session.h" #include "remoting/protocol/session_manager.h" -namespace pp { -class Instance; -} // namespace pp - namespace remoting { class XmppProxy; @@ -87,23 +83,35 @@ class ConnectionToHost : public SignalStrategy::Listener, ConnectionToHost(bool allow_nat_traversal); virtual ~ConnectionToHost(); - // |signal_strategy| must outlive connection. |audio_stub| may be - // null, in which case audio will not be requested. + // Set the stubs which will handle messages from the host. + // The caller must ensure that stubs out-live the connection. + // Unless otherwise specified, all stubs must be set before Connect() + // is called. + void set_client_stub(ClientStub* client_stub); + void set_clipboard_stub(ClipboardStub* clipboard_stub); + void set_video_stub(VideoStub* video_stub); + // If no audio stub is specified then audio will not be requested. + void set_audio_stub(AudioStub* audio_stub); + + // Initiates a connection to the host specified by |host_jid|. + // |signal_strategy| is used to signal to the host, and must outlive the + // connection. Data channels will be negotiated over |transport_factory|. + // |authenticator| will be used to authenticate the session and data channels. + // |event_callback| will be notified of changes in the state of the connection + // and must outlive the ConnectionToHost. + // Caller must set stubs (see below) before calling Connect. virtual void Connect(SignalStrategy* signal_strategy, - const std::string& host_jid, - const std::string& host_public_key, scoped_ptr<TransportFactory> transport_factory, scoped_ptr<Authenticator> authenticator, - HostEventCallback* event_callback, - ClientStub* client_stub, - ClipboardStub* clipboard_stub, - VideoStub* video_stub, - AudioStub* audio_stub); + const std::string& host_jid, + const std::string& host_public_key, + HostEventCallback* event_callback); + // Returns the session configuration that was negotiated with the host. virtual const SessionConfig& config(); // Stubs for sending data to the host. - virtual ClipboardStub* clipboard_stub(); + virtual ClipboardStub* clipboard_forwarder(); virtual HostStub* host_stub(); virtual InputStub* input_stub(); |