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

Unified Diff: remoting/protocol/client_input_dispatcher.cc

Issue 8574025: Refactor client channel dispatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
Index: remoting/protocol/client_input_dispatcher.cc
diff --git a/remoting/protocol/client_input_dispatcher.cc b/remoting/protocol/client_input_dispatcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4c9f54783f0a2da222534884500d4e113a627fba
--- /dev/null
+++ b/remoting/protocol/client_input_dispatcher.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 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/client_input_dispatcher.h"
+
+#include "base/time.h"
+#include "remoting/proto/event.pb.h"
+#include "remoting/proto/internal.pb.h"
+#include "remoting/protocol/buffered_socket_writer.h"
+#include "remoting/protocol/session.h"
+#include "remoting/protocol/util.h"
+
+namespace remoting {
+namespace protocol {
+
+ClientInputDispatcher::ClientInputDispatcher(
+ base::MessageLoopProxy* message_loop)
+ : writer_(new BufferedSocketWriter(message_loop)) {
+}
+
+ClientInputDispatcher::~ClientInputDispatcher() {
+ Close();
+}
+
+void ClientInputDispatcher::Init(Session* session) {
+ DCHECK(session);
+
+ // TODO(garykac) Set write failed callback.
Wez 2011/11/17 01:51:56 This TODO applies equally to the ClientControlDisp
Sergey Ulanov 2011/11/17 19:29:06 Done.
+ writer_->Init(session->event_channel(),
+ BufferedSocketWriter::WriteFailedCallback());
+}
+
+void ClientInputDispatcher::InjectKeyEvent(const KeyEvent& event) {
+ EventMessage message;
+ message.set_sequence_number(base::Time::Now().ToInternalValue());
+ message.mutable_key_event()->CopyFrom(event);
+ writer_->Write(SerializeAndFrameMessage(message), base::Closure());
+}
+
+void ClientInputDispatcher::InjectMouseEvent(const MouseEvent& event) {
+ EventMessage message;
+ message.set_sequence_number(base::Time::Now().ToInternalValue());
+ message.mutable_mouse_event()->CopyFrom(event);
+ writer_->Write(SerializeAndFrameMessage(message), base::Closure());
+}
+
+void ClientInputDispatcher::Close() {
+ writer_->Close();
Wez 2011/11/17 01:51:56 Fold this into dtor?
Sergey Ulanov 2011/11/17 19:29:06 Done.
+}
+
+} // namespace protocol
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698