diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 18:23:31 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 18:23:31 +0000 |
commit | ee910fdf741ad7ef27465b8f85bdd10e3ecd7eda (patch) | |
tree | 032993a2faa4937d82062071690084d805f78c73 /remoting/protocol | |
parent | cd38cd872d1caf641ccf7d59f3c2cb3eedfaf47a (diff) | |
download | chromium_src-ee910fdf741ad7ef27465b8f85bdd10e3ecd7eda.zip chromium_src-ee910fdf741ad7ef27465b8f85bdd10e3ecd7eda.tar.gz chromium_src-ee910fdf741ad7ef27465b8f85bdd10e3ecd7eda.tar.bz2 |
Move ConnectionToClient::EventHandler from ChromotingHost to ClientSession
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/8476018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/connection_to_client.cc | 23 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client.h | 17 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client_unittest.cc | 4 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.cc | 5 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.h | 2 |
5 files changed, 22 insertions, 29 deletions
diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc index 9c92856..6b2bbd1 100644 --- a/remoting/protocol/connection_to_client.cc +++ b/remoting/protocol/connection_to_client.cc @@ -14,27 +14,23 @@ #include "remoting/protocol/host_stub.h" #include "remoting/protocol/input_stub.h" -// TODO(hclam): Remove this header once MessageDispatcher is used. -#include "remoting/base/compound_buffer.h" - namespace remoting { namespace protocol { -// Determine how many update streams we should count to find the size of -// average update stream. -static const size_t kAverageUpdateStream = 10; - ConnectionToClient::ConnectionToClient(base::MessageLoopProxy* message_loop, - EventHandler* handler) + protocol::Session* session) : message_loop_(message_loop), - handler_(handler), + handler_(NULL), host_stub_(NULL), input_stub_(NULL), + session_(session), control_connected_(false), input_connected_(false), video_connected_(false) { DCHECK(message_loop_); - DCHECK(handler_); + session_->SetStateChangeCallback( + base::Bind(&ConnectionToClient::OnSessionStateChange, + base::Unretained(this))); } ConnectionToClient::~ConnectionToClient() { @@ -42,12 +38,9 @@ ConnectionToClient::~ConnectionToClient() { // connection. } -void ConnectionToClient::Init(protocol::Session* session) { +void ConnectionToClient::SetEventHandler(EventHandler* event_handler) { DCHECK(message_loop_->BelongsToCurrentThread()); - session_.reset(session); - session_->SetStateChangeCallback( - base::Bind(&ConnectionToClient::OnSessionStateChange, - base::Unretained(this))); + handler_ = event_handler; } protocol::Session* ConnectionToClient::session() { diff --git a/remoting/protocol/connection_to_client.h b/remoting/protocol/connection_to_client.h index fc892d0..3f34702 100644 --- a/remoting/protocol/connection_to_client.h +++ b/remoting/protocol/connection_to_client.h @@ -53,14 +53,15 @@ class ConnectionToClient : int64 sequence_number) = 0; }; - // Constructs a ConnectionToClient object. |message_loop| is the message loop - // that this object runs on. A viewer object receives events and messages from - // a libjingle channel, these events are delegated to |handler|. - // It is guaranteed that |handler| is called only on the |message_loop|. - ConnectionToClient(base::MessageLoopProxy* message_loop, - EventHandler* handler); - - virtual void Init(Session* session); + // Constructs a ConnectionToClient object for the + // |session|. |message_loop| is the message loop that this object + // runs on. + ConnectionToClient(base::MessageLoopProxy* message_loop, Session* session); + + // Set |event_handler| for connection events. |event_handler| is + // guaranteed to be used only on the network thread. Must be called + // once when this object is created. + void SetEventHandler(EventHandler* event_handler); // Returns the connection in use. virtual Session* session(); diff --git a/remoting/protocol/connection_to_client_unittest.cc b/remoting/protocol/connection_to_client_unittest.cc index ce14b96..d3d1aed 100644 --- a/remoting/protocol/connection_to_client_unittest.cc +++ b/remoting/protocol/connection_to_client_unittest.cc @@ -31,10 +31,10 @@ class ConnectionToClientTest : public testing::Test { // Allocate a ClientConnection object with the mock objects. viewer_ = new ConnectionToClient( - base::MessageLoopProxy::current(), &handler_); + base::MessageLoopProxy::current(), session_); viewer_->set_host_stub(&host_stub_); viewer_->set_input_stub(&input_stub_); - viewer_->Init(session_); + viewer_->SetEventHandler(&handler_); EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); session_->state_change_callback().Run( protocol::Session::CONNECTED); diff --git a/remoting/protocol/protocol_mock_objects.cc b/remoting/protocol/protocol_mock_objects.cc index 3ce8d31..897b34d 100644 --- a/remoting/protocol/protocol_mock_objects.cc +++ b/remoting/protocol/protocol_mock_objects.cc @@ -10,11 +10,10 @@ namespace remoting { namespace protocol { MockConnectionToClient::MockConnectionToClient( - EventHandler* handler, + Session* session, HostStub* host_stub, InputStub* input_stub) - : ConnectionToClient(base::MessageLoopProxy::current(), - handler) { + : ConnectionToClient(base::MessageLoopProxy::current(), session) { set_host_stub(host_stub); set_input_stub(input_stub); } diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h index 92dc7af..9a3f50d 100644 --- a/remoting/protocol/protocol_mock_objects.h +++ b/remoting/protocol/protocol_mock_objects.h @@ -21,7 +21,7 @@ class ChromotocolConnection; class MockConnectionToClient : public ConnectionToClient { public: - MockConnectionToClient(EventHandler* handler, + MockConnectionToClient(Session* session, HostStub* host_stub, InputStub* input_stub); virtual ~MockConnectionToClient(); |