summaryrefslogtreecommitdiffstats
path: root/remoting/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/protocol')
-rw-r--r--remoting/protocol/buffered_socket_writer.cc2
-rw-r--r--remoting/protocol/connection_to_host.cc35
-rw-r--r--remoting/protocol/connection_to_host.h37
-rw-r--r--remoting/protocol/input_sender.cc2
-rw-r--r--remoting/protocol/jingle_connection_to_host.cc11
-rw-r--r--remoting/protocol/jingle_connection_to_host.h4
-rw-r--r--remoting/protocol/message_decoder.h7
-rw-r--r--remoting/protocol/message_reader.h2
-rw-r--r--remoting/protocol/stream_writer.cc2
-rw-r--r--remoting/protocol/stream_writer.h2
10 files changed, 79 insertions, 25 deletions
diff --git a/remoting/protocol/buffered_socket_writer.cc b/remoting/protocol/buffered_socket_writer.cc
index 555d4e6..0cf39bc 100644
--- a/remoting/protocol/buffered_socket_writer.cc
+++ b/remoting/protocol/buffered_socket_writer.cc
@@ -24,9 +24,11 @@ BufferedSocketWriterBase::~BufferedSocketWriterBase() { }
void BufferedSocketWriterBase::Init(net::Socket* socket,
WriteFailedCallback* callback) {
+ // TODO(garykac) Save copy of WriteFailedCallback.
AutoLock auto_lock(lock_);
message_loop_ = MessageLoop::current();
socket_ = socket;
+ DCHECK(socket_);
}
bool BufferedSocketWriterBase::Write(
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc
new file mode 100644
index 0000000..162dfdf
--- /dev/null
+++ b/remoting/protocol/connection_to_host.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/connection_to_host.h"
+
+#include "base/callback.h"
+#include "base/message_loop.h"
+#include "remoting/base/constants.h"
+#include "remoting/jingle_glue/jingle_thread.h"
+#include "remoting/protocol/client_stub.h"
+#include "remoting/protocol/jingle_session_manager.h"
+#include "remoting/protocol/video_reader.h"
+#include "remoting/protocol/video_stub.h"
+#include "remoting/protocol/util.h"
+
+namespace remoting {
+namespace protocol {
+
+ConnectionToHost::ConnectionToHost() {
+}
+
+ConnectionToHost::~ConnectionToHost() {
+}
+
+InputStub* ConnectionToHost::input_stub() {
+ return input_stub_.get();
+}
+
+HostStub* ConnectionToHost::host_stub() {
+ return host_stub_.get();
+}
+
+} // namespace protocol
+} // namespace remoting
diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h
index d34b9ee..0d1c602 100644
--- a/remoting/protocol/connection_to_host.h
+++ b/remoting/protocol/connection_to_host.h
@@ -10,10 +10,14 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "remoting/proto/internal.pb.h"
+#include "remoting/protocol/host_stub.h"
+#include "remoting/protocol/input_stub.h"
+#include "remoting/protocol/stream_writer.h"
namespace remoting {
namespace protocol {
+class ClientStub;
class SessionConfig;
class VideoStub;
@@ -33,23 +37,48 @@ class ConnectionToHost {
virtual void OnConnectionFailed(ConnectionToHost* conn) = 0;
};
- virtual ~ConnectionToHost() {}
+ virtual ~ConnectionToHost();
// TODO(ajwong): We need to generalize this API.
virtual void Connect(const std::string& username,
const std::string& auth_token,
const std::string& host_jid,
HostEventCallback* event_callback,
+ ClientStub* client_stub,
VideoStub* video_stub) = 0;
virtual void Disconnect() = 0;
virtual const SessionConfig* config() = 0;
- // Send an input event to the host.
- virtual void SendEvent(const ChromotingClientMessage& msg) = 0;
+ virtual InputStub* input_stub();
+
+ virtual HostStub* host_stub();
protected:
- ConnectionToHost() {}
+ ConnectionToHost();
+
+ //private: TODO(garykac). Merge jingle_connection_to_host up into this class
+ // and then make these private again.
+ ////////////////////////////////////////////////////////////////////////////
+ // User input event channel interface
+
+ // Stub for sending input event messages to the host.
+ scoped_ptr<InputStub> input_stub_;
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Protocol control channel interface
+
+ // Stub for sending control messages to the host.
+ scoped_ptr<HostStub> host_stub_;
+
+ // Stub for receiving control messages from the host.
+ ClientStub* client_stub_;
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Video channel interface
+
+ // Stub for receiving video packets from the host.
+ VideoStub* video_stub_;
private:
DISALLOW_COPY_AND_ASSIGN(ConnectionToHost);
diff --git a/remoting/protocol/input_sender.cc b/remoting/protocol/input_sender.cc
index d7d5236..e45149e 100644
--- a/remoting/protocol/input_sender.cc
+++ b/remoting/protocol/input_sender.cc
@@ -17,6 +17,8 @@ namespace protocol {
InputSender::InputSender(net::Socket* socket)
: buffered_writer_(new BufferedSocketWriter()) {
+ // TODO(garykac) Set write failed callback.
+ DCHECK(socket);
buffered_writer_->Init(socket, NULL);
}
diff --git a/remoting/protocol/jingle_connection_to_host.cc b/remoting/protocol/jingle_connection_to_host.cc
index a11a8fb..a551f17 100644
--- a/remoting/protocol/jingle_connection_to_host.cc
+++ b/remoting/protocol/jingle_connection_to_host.cc
@@ -9,6 +9,8 @@
#include "remoting/base/constants.h"
#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/proto/auth.pb.h"
+#include "remoting/protocol/client_stub.h"
+#include "remoting/protocol/input_sender.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/video_reader.h"
#include "remoting/protocol/video_stub.h"
@@ -29,6 +31,7 @@ void JingleConnectionToHost::Connect(const std::string& username,
const std::string& auth_token,
const std::string& host_jid,
HostEventCallback* event_callback,
+ ClientStub* client_stub,
VideoStub* video_stub) {
event_callback_ = event_callback;
video_stub_ = video_stub;
@@ -52,7 +55,6 @@ void JingleConnectionToHost::Disconnect() {
}
control_reader_.Close();
- event_writer_.Close();
video_reader_->Close();
if (session_) {
@@ -126,11 +128,6 @@ const SessionConfig* JingleConnectionToHost::config() {
return session_->config();
}
-void JingleConnectionToHost::SendEvent(const ChromotingClientMessage& msg) {
- // This drops the message if we are not connected yet.
- event_writer_.SendMessage(msg);
-}
-
// JingleClient::Callback interface.
void JingleConnectionToHost::OnStateChange(JingleClient* client,
JingleClient::State state) {
@@ -173,9 +170,9 @@ void JingleConnectionToHost::OnSessionStateChange(
control_reader_.Init<ControlMessage>(
session_->control_channel(),
NewCallback(this, &JingleConnectionToHost::OnControlMessage));
- event_writer_.Init(session_->event_channel());
video_reader_.reset(VideoReader::Create(session_->config()));
video_reader_->Init(session_, video_stub_);
+ input_stub_.reset(new InputSender(session_->event_channel()));
event_callback_->OnConnectionOpened(this);
break;
diff --git a/remoting/protocol/jingle_connection_to_host.h b/remoting/protocol/jingle_connection_to_host.h
index c25d872..b006022 100644
--- a/remoting/protocol/jingle_connection_to_host.h
+++ b/remoting/protocol/jingle_connection_to_host.h
@@ -52,13 +52,12 @@ class JingleConnectionToHost : public ConnectionToHost,
const std::string& auth_token,
const std::string& host_jid,
HostEventCallback* event_callback,
+ ClientStub* client_stub,
VideoStub* video_stub);
virtual void Disconnect();
virtual const SessionConfig* config();
- virtual void SendEvent(const ChromotingClientMessage& msg);
-
// JingleClient::Callback interface.
virtual void OnStateChange(JingleClient* client, JingleClient::State state);
@@ -96,7 +95,6 @@ class JingleConnectionToHost : public ConnectionToHost,
scoped_refptr<protocol::Session> session_;
MessageReader control_reader_;
- EventStreamWriter event_writer_;
scoped_ptr<VideoReader> video_reader_;
HostEventCallback* event_callback_;
diff --git a/remoting/protocol/message_decoder.h b/remoting/protocol/message_decoder.h
index 1978dc2..d2ba80a 100644
--- a/remoting/protocol/message_decoder.h
+++ b/remoting/protocol/message_decoder.h
@@ -16,13 +16,6 @@
namespace remoting {
-class ChromotingClientMessage;
-class ChromotingHostMessage;
-class ClientControlMessage;
-class ClientEventMessage;
-class HostControlMessage;
-class HostEventMessage;
-
// MessageDecoder uses CompoundBuffer to decode bytes into protocol
// buffer messages. This can be used to decode bytes received from the
// network.
diff --git a/remoting/protocol/message_reader.h b/remoting/protocol/message_reader.h
index 44e6a5c..93a7f92 100644
--- a/remoting/protocol/message_reader.h
+++ b/remoting/protocol/message_reader.h
@@ -20,8 +20,6 @@ class Socket;
namespace remoting {
class ChromotocolConnection;
-class ChromotingClientMessage;
-class ChromotingHostMessage;
class MessageReader;
namespace internal {
diff --git a/remoting/protocol/stream_writer.cc b/remoting/protocol/stream_writer.cc
index 9e1ddd4..4ceb1c4 100644
--- a/remoting/protocol/stream_writer.cc
+++ b/remoting/protocol/stream_writer.cc
@@ -35,7 +35,7 @@ void StreamWriterBase::Close() {
buffered_writer_->Close();
}
-bool EventStreamWriter::SendMessage(const ChromotingClientMessage& message) {
+bool EventStreamWriter::SendMessage(const EventMessage& message) {
return buffered_writer_->Write(SerializeAndFrameMessage(message));
}
diff --git a/remoting/protocol/stream_writer.h b/remoting/protocol/stream_writer.h
index 15b9bdd..dbf026c 100644
--- a/remoting/protocol/stream_writer.h
+++ b/remoting/protocol/stream_writer.h
@@ -43,7 +43,7 @@ class EventStreamWriter : public StreamWriterBase {
public:
// Sends the |message| or returns false if called before Init().
// Can be called on any thread.
- bool SendMessage(const ChromotingClientMessage& message);
+ bool SendMessage(const EventMessage& message);
};
class ControlStreamWriter : public StreamWriterBase {