summaryrefslogtreecommitdiffstats
path: root/remoting/protocol
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 18:58:48 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 18:58:48 +0000
commit39549bf8f876b17f481e753161166370064458bd (patch)
tree302372219ac8b011e61d9cb2f8af1bfec00afe9a /remoting/protocol
parentfbee5cb8c9797b4fe08afae83ac758a9aec7f7f5 (diff)
downloadchromium_src-39549bf8f876b17f481e753161166370064458bd.zip
chromium_src-39549bf8f876b17f481e753161166370064458bd.tar.gz
chromium_src-39549bf8f876b17f481e753161166370064458bd.tar.bz2
Implementation of ClientStubImpl
Implementing ClientStubImpl using socket and BufferedSocketWriter. BUG=none TEST=none Review URL: http://codereview.chromium.org/4440001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-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
3 files changed, 90 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_