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

Unified Diff: remoting/protocol/connection_to_client.cc

Issue 7508044: Remove video_channel() from 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/connection_to_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/connection_to_client.cc
diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
index f5cf592e444f42b5e4ca99ff805cffcf4eba562e..433098453b57a068506795c573238a73fa9c4910 100644
--- a/remoting/protocol/connection_to_client.cc
+++ b/remoting/protocol/connection_to_client.cc
@@ -4,6 +4,7 @@
#include "remoting/protocol/connection_to_client.h"
+#include "base/bind.h"
#include "google/protobuf/message.h"
#include "net/base/io_buffer.h"
#include "remoting/protocol/client_control_sender.h"
@@ -26,7 +27,10 @@ ConnectionToClient::ConnectionToClient(MessageLoop* message_loop,
: loop_(message_loop),
handler_(handler),
host_stub_(NULL),
- input_stub_(NULL) {
+ input_stub_(NULL),
+ control_connected_(false),
+ input_connected_(false),
+ video_connected_(false) {
DCHECK(loop_);
DCHECK(handler_);
}
@@ -90,33 +94,63 @@ void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) {
DCHECK(handler_);
switch(state) {
case protocol::Session::CONNECTING:
+ // Don't care about this message.
break;
- // Don't care about this message.
+
case protocol::Session::CONNECTED:
- client_control_sender_.reset(
- new ClientControlSender(session_->control_channel()));
video_writer_.reset(VideoWriter::Create(session_->config()));
- video_writer_->Init(session_.get());
+ video_writer_->Init(
+ session_.get(), base::Bind(&ConnectionToClient::OnVideoInitialized,
+ base::Unretained(this)));
+ break;
+ case protocol::Session::CONNECTED_CHANNELS:
+ client_control_sender_.reset(
+ new ClientControlSender(session_->control_channel()));
dispatcher_.reset(new HostMessageDispatcher());
dispatcher_->Initialize(this, host_stub_, input_stub_);
- handler_->OnConnectionOpened(this);
+ control_connected_ = true;
+ input_connected_ = true;
+ NotifyIfChannelsReady();
break;
+
case protocol::Session::CLOSED:
CloseChannels();
handler_->OnConnectionClosed(this);
break;
+
case protocol::Session::FAILED:
- CloseChannels();
- handler_->OnConnectionFailed(this);
+ CloseOnError();
break;
+
default:
// We shouldn't receive other states.
NOTREACHED();
}
}
+void ConnectionToClient::OnVideoInitialized(bool successful) {
+ if (!successful) {
+ LOG(ERROR) << "Failed to connect video channel";
+ CloseOnError();
+ return;
+ }
+
+ video_connected_ = true;
+ NotifyIfChannelsReady();
+}
+
+void ConnectionToClient::NotifyIfChannelsReady() {
+ if (control_connected_ && input_connected_ && video_connected_)
+ handler_->OnConnectionOpened(this);
+}
+
+void ConnectionToClient::CloseOnError() {
+ CloseChannels();
+ handler_->OnConnectionFailed(this);
+}
+
void ConnectionToClient::CloseChannels() {
if (video_writer_.get())
video_writer_->Close();
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/connection_to_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698