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

Unified Diff: remoting/protocol/client_event_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
« no previous file with comments | « remoting/protocol/client_event_dispatcher.h ('k') | remoting/protocol/client_message_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/client_event_dispatcher.cc
diff --git a/remoting/protocol/client_event_dispatcher.cc b/remoting/protocol/client_event_dispatcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..60c5d43e9383b43fd23df5f54ee9d0ae77a52858
--- /dev/null
+++ b/remoting/protocol/client_event_dispatcher.cc
@@ -0,0 +1,49 @@
+// 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_event_dispatcher.h"
+
+#include "base/message_loop_proxy.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 {
+
+ClientEventDispatcher::ClientEventDispatcher()
+ : writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) {
+}
+
+ClientEventDispatcher::~ClientEventDispatcher() {
+ writer_->Close();
+}
+
+void ClientEventDispatcher::Init(Session* session) {
+ DCHECK(session);
+
+ // TODO(garykac): Set write failed callback.
+ writer_->Init(session->event_channel(),
+ BufferedSocketWriter::WriteFailedCallback());
+}
+
+void ClientEventDispatcher::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 ClientEventDispatcher::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());
+}
+
+} // namespace protocol
+} // namespace remoting
« no previous file with comments | « remoting/protocol/client_event_dispatcher.h ('k') | remoting/protocol/client_message_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698