summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rw-r--r--remoting/protocol/client_stub.h6
-rw-r--r--remoting/protocol/client_stub_impl.cc38
-rw-r--r--remoting/protocol/client_stub_impl.h49
-rw-r--r--remoting/remoting.gyp3
4 files changed, 93 insertions, 3 deletions
diff --git a/remoting/protocol/client_stub.h b/remoting/protocol/client_stub.h
index 8873a13..ac1caaa 100644
--- a/remoting/protocol/client_stub.h
+++ b/remoting/protocol/client_stub.h
@@ -17,15 +17,15 @@ class Task;
namespace remoting {
namespace protocol {
-class NotifyScreenResolution;
+class NotifyResolutionRequest;
class ClientStub {
public:
ClientStub() {}
virtual ~ClientStub() {}
- virtual void NotifyScreenResolution(const NotifyScreenResolution& msg,
- Task* done) = 0;
+ virtual void NotifyResolution(const NotifyResolutionRequest& msg,
+ Task* done) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ClientStub);
diff --git a/remoting/protocol/client_stub_impl.cc b/remoting/protocol/client_stub_impl.cc
new file mode 100644
index 0000000..2c8fedb
--- /dev/null
+++ b/remoting/protocol/client_stub_impl.cc
@@ -0,0 +1,38 @@
+// 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.
+
+// This stub is thread safe because of the use of BufferedSocketWriter.
+// BufferedSocketWriter buffers messages and send them on them right thread.
+
+#include "remoting/protocol/client_stub_impl.h"
+
+#include "base/task.h"
+#include "remoting/protocol/buffered_socket_writer.h"
+#include "remoting/proto/control.pb.h"
+#include "remoting/protocol/util.h"
+
+namespace remoting {
+namespace protocol {
+
+ClientStubImpl::ClientStubImpl(net::Socket* socket)
+ : buffered_writer_(new BufferedSocketWriter()) {
+ buffered_writer_->Init(socket, NULL);
+}
+
+ClientStubImpl::~ClientStubImpl() {
+}
+
+void ClientStubImpl::NotifyResolution(
+ const NotifyResolutionRequest& msg, Task* done) {
+ ControlMessage message;
+ message.mutable_notify_resolution()->CopyFrom(msg);
+ buffered_writer_->Write(SerializeAndFrameMessage(message));
+ if (done) {
+ done->Run();
+ delete done;
+ }
+}
+
+} // namespace protocol
+} // namespace remoting
diff --git a/remoting/protocol/client_stub_impl.h b/remoting/protocol/client_stub_impl.h
new file mode 100644
index 0000000..d953be7
--- /dev/null
+++ b/remoting/protocol/client_stub_impl.h
@@ -0,0 +1,49 @@
+// 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.
+
+// Implementation of ClientStub using sockets created from jingle connection.
+// It sends messages through the socket after serializing it.
+//
+// Object of this class can only be created by ConnectionToClient.
+//
+// This class can be used on any thread.
+
+#ifndef REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_
+#define REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_
+
+#include "base/basictypes.h"
+#include "base/ref_counted.h"
+#include "remoting/protocol/client_stub.h"
+
+class Task;
+
+namespace net {
+class Socket;
+} // namespace net
+
+namespace remoting {
+namespace protocol {
+
+class BufferedSocketWriter;
+
+class ClientStubImpl : public ClientStub {
+ public:
+ // Create a stub using a socket.
+ explicit ClientStubImpl(net::Socket* socket);
+ virtual ~ClientStubImpl();
+
+ virtual void NotifyResolution(const NotifyResolutionRequest& msg,
+ Task* done) = 0;
+ private:
+ // Buffered socket writer holds the serialized message and send it on the
+ // right thread.
+ scoped_refptr<BufferedSocketWriter> buffered_writer_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClientStubImpl);
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 53a7d57..d651037 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -360,6 +360,9 @@
'protocol/buffered_socket_writer.h',
'protocol/chromotocol_config.cc',
'protocol/chromotocol_config.h',
+ 'protocol/client_stub.h',
+ 'protocol/client_stub_impl.cc',
+ 'protocol/client_stub_impl.h',
'protocol/connection_to_client.cc',
'protocol/connection_to_client.h',
'protocol/connection_to_host.h',